您的位置:首页 > 科技 > IT业 > 【ArcGIS For JS】前端geojson渲染行政区划图层并加标签

【ArcGIS For JS】前端geojson渲染行政区划图层并加标签

2024/10/5 20:24:27 来源:https://blog.csdn.net/horizon08/article/details/139281170  浏览:    关键词:【ArcGIS For JS】前端geojson渲染行政区划图层并加标签

原理

通过DataV工具 生成行政区的geojson(得到各区的面元素数据), 随后使用手动绘制featureLayer与Label,并加载到地图。

    //vue3加载geojson数据public/geojson/pt.json,在MapView渲染上加载geojson数据 type是"MultiPolygon"fetch(baseUrl+'/geojson/pt.json').then(response => response.json()).then(data => {console.log(data)// debuggerlet graphics = data.features.map((feature) => {//Polygon 单个多边形绘制let geometry = {type: 'polygon',rings: feature.geometry.coordinates[0]}return new Graphic({geometry: geometry,attributes: feature.properties})})let featureLayer = new FeatureLayer({fields: [{name: 'ObjectID',alias: 'ObjectID',type: 'oid'},{name: 'name',alias: 'name',type: 'string'},{name: 'adcode',alias: 'adcode',type: 'integer'}],objectIdField: 'ObjectID',geometryType: 'polygon',spatialReference: {wkid: 4326},source: graphics,renderer: {type: 'simple',symbol: {type: 'simple-fill',color: [227, 139, 79, 0.8],outline: {color: [255, 255, 255],width: 1}}},labelingInfo: [{labelExpressionInfo: {expression: '$feature.name'},symbol: {type: 'text',color: [0, 0, 0, 1],haloColor: [255, 255, 255, 1],haloSize: 1,font: {size: 12}}}]})//地图加载featureLayerview.map.layers.add(featureLayer)})})

源码地址

https://github.com/Billyas/AQICalculator-nuxt3

演示站点

https://billyas.github.io/arcgis-vue3-demo/

效果

在这里插入图片描述

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com