高德地图制作省级地图

let map = new AMap.Map("maps", {   //maps是容器的id名      zoom: 4, //地图显示的缩放级别      layers: [        new AMap.TileLayer.Satellite({  //卫星模式          zIndex: 0        })      ],      mapStyle: "amap://styles/darkblue"      //showIndoorMap: false    });
new AMap.DistrictSearch({ extensions: "all", subdistrict: 0 }).search("山西省", function(status, result) { //只需将山西省换成你要显示的省名就可以了 // 外多边形坐标数组和内多边形坐标数组 var outer = [ new AMap.LngLat(-360, 90, true), new AMap.LngLat(-360, -90, true), new AMap.LngLat(360, -90, true), new AMap.LngLat(360, 90, true) ]; var holes = result.districtList[0].boundaries;
var pathArray = [outer]; pathArray.push.apply(pathArray, holes); var polygon = new AMap.Polygon({ pathL: pathArray, // strokeColor: '#f00', strokeWeight: 1, fillColor: "#051a49", fillOpacity: 1 }); polygon.setPath(pathArray); that.map.add(polygon); });

通过以上就可以实现一个省级地图,可以通过 new AMap.TileLayer.Satellite({})来控制是否是卫星地图模式,

上一篇:算法血拼:Google+ 百度 +Alibaba+ 字节 +Tencent+ 网易 +360+ 拼夕夕


下一篇:一线互联网移动架构师360°全方面性能调优,深度解析,值得收藏