上一篇实现了demo的热力图,本篇新增叠加SHP图层,截图如下:
叠加SHP图层效果实现的思路如下:利用封装的js文件,直接读取shp图层,然后转换geojson,最后通过arcgis api来解析转换graphic绘制叠加在地图展示
1.map.html页面引用叠加SHP需要的js文件
<pre>
<script src="stream.js"></script>
<script src="shapefile.js"></script>
<script src="dbf.js"></script>
</pre>
2.以餐饮点图层来作为测试数据源,在叠加SHP菜单响应事件直接调用Shapefile构造函数:
<pre>
//叠加SHP图层
$("#overlayshp").click(function () {
map.graphics.clear();
var shapefile = new Shapefile({
shp: getRootPath() + "js/main/shpJS/test.shp",
dbf: getRootPath() + "js/main/shpJS/test.dbf"
}, function (data) {
var features = data.geojson.features;
if (features.length>0) {
for (var i = 0; i < features.length; i++) {
//features[i].geometry.coordinates
//features[i].properties.Id;
var symbol = new esri.symbol.PictureMarkerSymbol(getRootPath() +
"Content/images/poi/dw1.png", 20, 20);
var mappoint = new esri.geometry.Point(features[i].geometry.coordinates[0],
features[i].geometry.coordinates[1],
new esri.SpatialReference(map.spatialReference.wkid));
var baseGraphic = new esri.Graphic(mappoint, symbol);
map.graphics.add(baseGraphic);
}
}
})
});
</pre>
备注:团队承接webgis/gis毕业设计以及webgis项目等业务,欢迎有相关需求的客户来咨询
GIS之家论坛(推荐):GIS之家论坛
GIS作品:GIS之家
QQ兴趣部落:GIS之家部落
GIS之家交流群一:432512093(已满)
GIS之家交流群二:296438295
网友评论