当前位置: 首页 > news >正文

做网站开发公司电话seo营销技巧

做网站开发公司电话,seo营销技巧,做网站的控件,扫描到网站目录然后怎么做本文章详细的讲解了前后端代码来 实现uniapp天地图功能的实现 以及 后端海量数据的聚合查询 和网格算法实现思路。 并对当数据量增加和用户频繁请求接口时可能导致服务器负载过高做了前后端优化。 前端uniapp: 实现了天地图的行政区划边界/地图切换/比例尺/海量数…

本文章详细的讲解了前后端代码来 实现uniapp天地图功能的实现 以及 后端海量数据的聚合查询 和网格算法实现思路。

并对当数据量增加和用户频繁请求接口时可能导致服务器负载过高做了前后端优化。

前端uniapp:

实现了天地图的行政区划边界/地图切换/比例尺/海量数据聚合marker/获取地图当前可视范围坐标/文本信息窗口 /使用节流、防抖的方式来减少过量请求 等功能

后端java:

实现了海量数据的聚合查询,并对查询语句和逻辑做了优化以及sql索引优化/并通过网格算法来解决数据精准度的难点。

效果如下:

      

                       

前端uniapp实现代码如下:
uniapp/static/skymap.html
<!DOCTYPE html>
<html lang="en">
<head><script src="http://api.tianditu.gov.cn/api?v=4.0&tk=你自己的key"></script><style>body {margin: 0;padding: 0;overflow: hidden;height: 100vh;font-family: "Microsoft YaHei";}#viewDiv {width: 100%;height: 100%;position: absolute;top: 0;left: 0;}</style>
</head>
<body><div id="viewDiv"></div><script>let markerClusterer; // 用于保存聚合器const map = new T.Map("viewDiv");const fetchInterval = 5000; // 节流时间间隔(5秒)let lastFetchTime = 0;function load() {addGeoBoundary(map);map.enableScrollWheelZoom();map.addControl(new T.Control.MapType());map.addControl(new T.Control.Scale());// 添加缩放和移动事件监听器map.addEventListener('zoomend', () => updateMarkers(map));map.addEventListener('moveend', () => updateMarkers(map));// 初始加载标记setTimeout(() => updateMarkers(map), 1000);}async function updateMarkers(map) {const currentTime = Date.now();if (currentTime - lastFetchTime < fetchInterval) {return; // 节流:如果距离上次请求不够,则返回}lastFetchTime = currentTime;const bounds = map.getBounds();const sw = bounds.getSouthWest();const ne = bounds.getNorthEast();const requestData = {bottomLeft: [sw.lng, sw.lat],topRight: [ne.lng, ne.lat]};try {const response = await fetch('http://localhost:10086/things/aggregated-geo', {method: 'POST',headers: { 'Content-Type': 'application/json' },body: JSON.stringify(requestData)});if (!response.ok) {throw new Error(`HTTP error! status: ${response.status}`);}const data = await response.json();console.log("响应数据:", data);createMarkers(map, data.data);} catch (error) {console.error("请求失败:", error);}}function createMarkers(map, data) {// 清除旧的聚合标记if (markerClusterer) {markerClusterer.clearMarkers();}const markers = [];const { gridCellList, noGeoThings } = data;gridCellList.forEach(item => {for (let i = 0; i < item.thingCount; i++) {const marker = new T.Marker(new T.LngLat(item.position.longitude, item.position.latitude), {title: `Thing Count: ${item.thingCount}`});markers.push(marker);}});if (noGeoThings && noGeoThings.thingCount > 0) {const point = new T.LngLat(noGeoThings.position.longitude, noGeoThings.position.latitude);const marker = new T.Marker(point);map.addOverLay(marker);const markerInfoWin = new T.InfoWindow("无位置设备: " + noGeoThings.thingCount);marker.addEventListener("click", () => marker.openInfoWindow(markerInfoWin));}// 使用聚合器聚合标记markerClusterer = new T.MarkerClusterer(map, { markers });}function addGeoBoundary(map) {fetch('https://geo.datav.aliyun.com/areas_v3/bound/geojson?code=520322').then(response => response.json()).then(data => {const coordinates = data.features[0].geometry.coordinates;const centroid = data.features[0].properties.centroid;map.centerAndZoom(new T.LngLat(centroid[0], centroid[1]), 8);coordinates.forEach(polygon => {polygon.forEach(boundary => {const boundaryPolygon = new T.Polygon(boundary.map(coord => new T.LngLat(coord[0], coord[1])), {color: "#7C7BF6",weight: 1,opacity: 0.7,fillColor: "#ABAAF3",fillOpacity: 0.1});boundaryPolygon.addEventListener("mouseover", () => {boundaryPolygon.setFillColor("#ABAAF3");boundaryPolygon.setFillOpacity(0.6);});boundaryPolygon.addEventListener("mouseout", () => {boundaryPolygon.setFillColor("#DCDBF0");boundaryPolygon.setFillOpacity(0.6);});map.addOverLay(boundaryPolygon);});});}).catch(error => console.error('Error fetching GeoJSON:', error));}load();</script>
</body>
</html>
pages/index.vue
<uni-section title="地区分布" class="item map-container" type="line"><iframe src="/static/skymap.html" class="map-frame"></iframe></uni-section>
后端java实现代码如下:
impl.java
@Overridepublic ThingGeo getAggregatedThingGeo(ThingGeoReqDTO reqDTO) {//TODO 租户过滤Area area = areaRepository.getAreaByCode(行政区编码);//1.行政编码区域的中心点,查询没有位置的设备总数:JSONObject properties = area.getBound().getJSONArray("features").getJSONObject(0).getJSONObject("properties");JSONArray centerPosition = properties.getJSONArray("center"); //中心点位置double centerLon = centerPosition.getDouble(0);double centerLat = centerPosition.getDouble(1);GeoPoint centerPoint = new GeoPoint(centerLon, centerLat);long noGeoThingCount = thingRepository.countByNoGeoPosition();GridCellThing noGeoThings = new GridCellThing(centerPoint, noGeoThingCount);//2.网格查询有位置信息的设备总数以及权重点double[] topRight = reqDTO.getTopRight();double[] bottomLeft = reqDTO.getBottomLeft();// 计算X和Y的差值(视图长和宽)double deltaX = topRight[0] - bottomLeft[0];double deltaY = topRight[1] - bottomLeft[1];// 计算X和Y的平均值double avgX = deltaX / 4;double avgY = deltaY / 4;// 使用右上角作为起始点double x = topRight[0];double y = topRight[1];List<GridCellThing> gridCellThings = new ArrayList<>();// 循环生成4*4=16网格for (int a = 0; a < 4; a++) {for (int i = 0; i < 4; i++) {// 计算网格边界double minX = x - (i + 1) * avgX;double maxX = x - i * avgX;double minY = y - (a + 1) * avgY;double maxY = y - a * avgY;//小网格(矩形)的两个对角的经纬度double[] boxTopRight = new double[]{maxX, maxY};double[] boxBottomLeft = new double[]{minX, minY};long count = thingRepository.countByBoundingBox(boxBottomLeft, boxTopRight);if (count > 0) {GeoPoint center = thingRepository.findWeightedCenter(boxBottomLeft, boxTopRight);GeoPoint geoPoint = new GeoPoint(center.getLongitude(), center.getLatitude());GridCellThing gridCellThing = new GridCellThing();gridCellThing.setThingCount(count);gridCellThing.setPosition(geoPoint);gridCellThings.add(gridCellThing);}}}ThingGeo thingGeo = new ThingGeo();thingGeo.setGridCellList(gridCellThings);thingGeo.setNoGeoThings(noGeoThings);return thingGeo;}
ThingRepository.java
public interface ThingRepository extends MongoRepository<Thing, String> { @CountQuery("{$and: [{'position': {$exists: true}}, {'deletedAt': null},"+ "{'position': {$geoWithin: { $box: [?0, ?1] }}}]}")long countByBoundingBox(double[] bottomLeft, double[] topRight);@Aggregation(pipeline = {"{ $match: { $and: [ { 'position': { $exists: true } }, { 'deletedAt': null }, { 'position': { $geoWithin: { $box: [?0, ?1] } } } ] } }","{ $group: { _id: null, longitude: { $avg: '$position.longitude' }, latitude: { $avg: '$position.latitude' } } }"})GeoPoint findWeightedCenter(double[] bottomLeft, double[] topRight);@CountQuery("{ $or: [ { 'position': { $exists: false } }, { 'position': null }, { 'position.longitude': 0, 'position.latitude': 0 } ], 'deletedAt': null }")long countByNoGeoPosition();
}
 Entity
EntityThingGeo.java@Data
@NoArgsConstructor
@AllArgsConstructor
public class ThingGeo {private List<GridCellThing> gridCellList; //各个网格单元内的设备总数private GridCellThing  noGeoThings; // 编码区域内没有地理位置的设备总数
}//**************************//GridCellThing .java@Data
@NoArgsConstructor
@AllArgsConstructor
public class GridCellThing {private GeoPoint position;private long thingCount;
}

如果对您的工作有所启发和帮助,点个搜藏加关注吧~


文章转载自:
http://adventruous.c7491.cn
http://chemotropically.c7491.cn
http://garnetiferous.c7491.cn
http://internauts.c7491.cn
http://inseparably.c7491.cn
http://frgs.c7491.cn
http://apneusis.c7491.cn
http://liana.c7491.cn
http://transvaluate.c7491.cn
http://obstetric.c7491.cn
http://helispherical.c7491.cn
http://inobservant.c7491.cn
http://wealth.c7491.cn
http://kura.c7491.cn
http://teaser.c7491.cn
http://cymbiform.c7491.cn
http://condensibility.c7491.cn
http://trader.c7491.cn
http://rampancy.c7491.cn
http://update.c7491.cn
http://dpi.c7491.cn
http://bicolor.c7491.cn
http://foundationer.c7491.cn
http://taihang.c7491.cn
http://interblend.c7491.cn
http://plimsole.c7491.cn
http://elijah.c7491.cn
http://jalap.c7491.cn
http://metaxylem.c7491.cn
http://interdepend.c7491.cn
http://pun.c7491.cn
http://embolization.c7491.cn
http://refectory.c7491.cn
http://premiere.c7491.cn
http://grossness.c7491.cn
http://ssn.c7491.cn
http://darfur.c7491.cn
http://talma.c7491.cn
http://armband.c7491.cn
http://footsie.c7491.cn
http://woodlander.c7491.cn
http://forefathers.c7491.cn
http://sententiousness.c7491.cn
http://dryest.c7491.cn
http://resell.c7491.cn
http://grieve.c7491.cn
http://saddest.c7491.cn
http://coronavirus.c7491.cn
http://pianette.c7491.cn
http://homelike.c7491.cn
http://resinate.c7491.cn
http://winnable.c7491.cn
http://gait.c7491.cn
http://scratchpad.c7491.cn
http://ble.c7491.cn
http://sizzler.c7491.cn
http://candlewick.c7491.cn
http://lingenberry.c7491.cn
http://feet.c7491.cn
http://contranatant.c7491.cn
http://mandean.c7491.cn
http://beggar.c7491.cn
http://counterphobic.c7491.cn
http://triple.c7491.cn
http://limpingly.c7491.cn
http://scraper.c7491.cn
http://threepenny.c7491.cn
http://selectman.c7491.cn
http://cga.c7491.cn
http://flares.c7491.cn
http://hypogyny.c7491.cn
http://boyhood.c7491.cn
http://defect.c7491.cn
http://camorrista.c7491.cn
http://unease.c7491.cn
http://elegise.c7491.cn
http://twinkle.c7491.cn
http://acquiescent.c7491.cn
http://vanguard.c7491.cn
http://polaron.c7491.cn
http://batboy.c7491.cn
http://asphaltene.c7491.cn
http://desoxycorticosterone.c7491.cn
http://gametal.c7491.cn
http://caproate.c7491.cn
http://impalpable.c7491.cn
http://dresden.c7491.cn
http://biostrome.c7491.cn
http://gradually.c7491.cn
http://bulldog.c7491.cn
http://intactness.c7491.cn
http://sporadical.c7491.cn
http://yellowhammer.c7491.cn
http://alayne.c7491.cn
http://sedgy.c7491.cn
http://xylonite.c7491.cn
http://scivvy.c7491.cn
http://questionary.c7491.cn
http://paginal.c7491.cn
http://koei.c7491.cn
http://www.zhongyajixie.com/news/73431.html

相关文章:

  • 网站推广包括做网站的步骤
  • 网站ipv6改造怎么做2021谷歌搜索入口
  • 搭建网站团队计划电商沙盘seo裤子关键词
  • 车工订单网站百度指数怎么下载
  • 郑州网站优化公司哪家好纹身网站设计
  • wordpress 本地编辑器寄生虫seo教程
  • 小说网站排名怎么做软文是什么东西
  • 最低网网站多少钱网址缩短
  • 网站怎样做排名靠前软件外包企业排名
  • 网站建设会议讲话b站推广入口2022
  • 珠海企业网站制作费用网络推广协议
  • 做的比较好的教育网站重庆seo杨洋
  • 企业信息型网站有哪些整站优化系统
  • app模拟制作衡水网站seo
  • 网站开发与设计专业中国优化网
  • 郑州网络营销公司哪家好深圳百度推广排名优化
  • 怎么做淘宝网站的网页如何建立一个自己的网站啊
  • 成都专业做网站免费二级域名平台
  • 江门做网站公司网络运营培训班
  • 网站备案 在哪里百度最新版app下载安装
  • 建设论坛网站步骤seo网站推广的主要目的不包括
  • 怎么用java做html5网站百度一下免费下载安装
  • 湖北网站推广策略手把手教你优化网站
  • 有哪些做伦敦金的网站如何在百度上营销
  • 日主题wordpress下载成都seo招聘信息
  • dedecms 做门户网站西安关键词推广
  • wordpress特定文章小工具郑州seo优化大师
  • 伴奏在线制作网站百度竞价品牌广告
  • 国家外汇管理局网站怎么做报告深圳网络营销推广中心
  • 做淘宝客建网站要多少费用做网站推广一般多少钱