useEffect(() => { if (view && topType) { let heatMapLayer = view.map.findLayerById('heatmaplayer'); if (heatMapLayer) view.map.remove(heatMapLayer); graphicLayer.removeAll(); const find = typeArr.find(f => f.name === topType); if (find) { //查出对应的多边形 let queryTask = new QueryTask({ url: waterConomy.queryPolygon + find?.layerId }); let query = new Query(); query.returnGeometry = true; query.outFields = ["*"]; query.where = "1=1"; // Return all cities with a population greater than 1 million queryTask.execute(query).then(function (results) { var peakResults = results.features.map(function (feature) { feature.symbol = { type: "simple-fill", // autocasts as new SimpleFillSymbol() color: [0, 255, 255, 0.5], style: "solid", outline: { // autocasts as new SimpleLineSymbol() color: [0, 255, 255, 1], width: 3 } } as any; //中心点添加图标 let center = (feature as any).geometry.centroid; let graphic = new Graphic({ geometry: center, symbol: symbol }) graphicLayer.add(graphic); return feature; }); // graphicLayer.addMany(peakResults); return results.features[0].geometry }).then(res => { //缓冲区参数 let buffer = new BufferParameters({ bufferSpatialReference: view.spatialReference, distances: [10], geodesic: true, geometries: [res], outSpatialReference: view.spatialReference, unit: "kilometers",//公里 }); //利用服务生成缓冲区范围 let geometry = new GeometryService({ url: waterConomy.bufferUrl }); return geometry.buffer(buffer).then(resultBuffer => { return resultBuffer; }) }).then(res => { // Create a symbol for rendering the graphic const fillSymbol = { type: "simple-fill", // autocasts as new SimpleFillSymbol() color: [227, 139, 79, 0.8], outline: { // autocasts as new SimpleLineSymbol() color: "red", width: 1 } }; let polygon = new Graphic({ geometry: res[0], symbol: fillSymbol }); // graphicLayer.addMany([polygon]); return polygon; }).then(res => { let layerIds = Array.from({ length: 35 }, (v, k) => k) console.log(layerIds); //根据生成的缓冲区范围查询数据 let identify = new IdentifyTask({ url: waterConomy.queryHeatMap }); let identifyParams = new IdentifyParameters({ geometry: res.geometry, height: view.height, width: view.width, mapExtent: view.extent, layerIds: layerIds, returnGeometry: true, tolerance: 6, layerOption: "all", }) return identify.execute(identifyParams).then(res => { return res; }) }).then(res => { //生成热力图 let heatArr = res.results.map((m: any) => { return { geometry: m.feature.geometry, attributes: m.feature.attributes } }); let layer = new FeatureLayer({ source: heatArr, renderer: renderer as any, objectIdField: "ObjectID", id: "heatmaplayer" }); view.map.add(layer) }) } view.map.add(graphicLayer) } }, [view, topType])
正文
arcgis api生成缓冲区范围,根据缓冲区查询数据
文章版权声明:除非注明,否则均为
譬如朝露_策温技术开发工作室博客原创文章,转载或复制请以超链接形式并注明出处。
发表评论
侧栏公告
寄语
譬如朝露博客是一个分享前端知识的网站,联系方式11523518。
热评文章
标签列表
热门文章
友情链接