初始化地圖
在list数组中存放地图的边界,
let that = this
// 隐藏边界以外的区域
// let 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),
// ] // 遮盖填充反向
// let pathArray = [
// outer,
// that.list
// ]
// var polygon = new AMap.Polygon({
// pathL: pathArray,
// strokeColor: "#27aaf7",
// strokeWeight: 2,
// fillColor: "#fff",
// fillOpacity: 1,
// })
// polygon.setPath(pathArray)
// map.add(polygon)
至此,地图外部的区域就隐藏完成了!
一般来说是可以了的,如果还是不行的话,可以看下面官网的事例 (* ̄︶ ̄)
2.或者可以查看官网 --> 区域掩模
官网 - 区域掩模
https://lbs.amap.com/demo/jsapi-v2/example/3d/mask