有些时候我们只需要某个省份的行政区域,那么运用百度地图如何实现呢?
我们先上效果图:
步骤:
创建map实例
var map;
createMap() {
map = new BMap.Map('main');
map.centerAndZoom(new BMap.Point(106.714476, 26.60403), 8);
// 将地图在水平位置上移动x像素,垂直位置上移动y像素(x,y)
map.panBy(-210, 330);
getBoundary();
}
绘制行政区域外覆盖物
getBoundary() {
map.clearOverlays(); // 清除地图的其余覆盖物
const bdary = new BMap.Boundary();
bdary.get('贵州省', (rs) => {
const count = rs.boundaries.length;
if (count === 0) {
return ;
}
const EN_JW = '180, 90;';
const NW_JW = '-180,