arcgis api for js入门开发系列十叠加SHP图层

上一篇实现了demo的热力图,本篇新增叠加SHP图层,截图如下:

叠加SHP图层效果实现的思路如下:利用封装的js文件,直接读取shp图层,然后转换geojson,最后通过arcgis api来解析转换graphic绘制叠加在地图展示

1.map.html页面引用叠加SHP需要的js文件

<!--叠加shp图层需要的js文件-->
<script src="stream.js"></script>
<script src="shapefile.js"></script>
<script src="dbf.js"></script>

2.以餐饮点图层来作为测试数据源,在叠加SHP菜单响应事件直接调用Shapefile构造函数:

//叠加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);
                    }
                }
})

});
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值