Showing
1 changed file
with
45 additions
and
10 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2023-05-19 14:54:27 | 2 | * @Date: 2023-05-19 14:54:27 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-07-10 12:14:05 | 4 | + * @LastEditTime: 2024-07-11 15:12:46 |
| 5 | * @FilePath: /map-demo/src/views/index.vue | 5 | * @FilePath: /map-demo/src/views/index.vue |
| 6 | * @Description: 公众地图主体页面 | 6 | * @Description: 公众地图主体页面 |
| 7 | --> | 7 | --> |
| ... | @@ -322,7 +322,7 @@ export default { | ... | @@ -322,7 +322,7 @@ export default { |
| 322 | showLabel: true, // 是否展示地图文字和 POI 信息 | 322 | showLabel: true, // 是否展示地图文字和 POI 信息 |
| 323 | zoom: this.data_zoom, // 设置地图显示的缩放级别 | 323 | zoom: this.data_zoom, // 设置地图显示的缩放级别 |
| 324 | pitch: 0, // 俯仰角度,默认 0,最大值根据地图当前 zoom 级别不断增大,2D地图下无效 。 | 324 | pitch: 0, // 俯仰角度,默认 0,最大值根据地图当前 zoom 级别不断增大,2D地图下无效 。 |
| 325 | - rotation: 0, // 地图顺时针旋转角度,取值范围 [0-360] ,默认值:0 | 325 | + rotation: this.data_rotation, // 地图顺时针旋转角度,取值范围 [0-360] ,默认值:0 |
| 326 | center: this.data_center, // 设置地图中心点坐标 | 326 | center: this.data_center, // 设置地图中心点坐标 |
| 327 | forceVector: false, | 327 | forceVector: false, |
| 328 | // rotateEnable: true, | 328 | // rotateEnable: true, |
| ... | @@ -898,20 +898,55 @@ export default { | ... | @@ -898,20 +898,55 @@ export default { |
| 898 | 898 | ||
| 899 | // layer1.setMap(this.map); | 899 | // layer1.setMap(this.map); |
| 900 | 900 | ||
| 901 | + // TODO: 暂时屏蔽等待数据设置字段 | ||
| 901 | // 只显示相应区域,移动会回到选定范围 | 902 | // 只显示相应区域,移动会回到选定范围 |
| 902 | // this.lockMapBounds() | 903 | // this.lockMapBounds() |
| 903 | 904 | ||
| 904 | }, | 905 | }, |
| 905 | // 限制地图范围 | 906 | // 限制地图范围 |
| 906 | - // lockMapBounds() { | 907 | + lockMapBounds() { |
| 907 | - // // var bounds = this.map.getBounds(); | 908 | + // var bounds = this.map.getBounds(); |
| 908 | - // var myBounds = new AMap.Bounds( | 909 | + var myBounds = new AMap.Bounds( |
| 909 | - // [120.583246, 31.31645], | 910 | + // [120.58626,31.316141], |
| 910 | - // [120.589973, 31.311949] | 911 | + // [120.588357,31.313204] |
| 911 | - // ); | 912 | + [117.052221,26.834886], |
| 913 | + [117.046739,26.838553] | ||
| 914 | + ); | ||
| 912 | 915 | ||
| 913 | - // this.map.setLimitBounds(myBounds); | 916 | + this.map.setLimitBounds(myBounds); |
| 914 | - // }, | 917 | + |
| 918 | + let list =[ | ||
| 919 | + [120.585097,31.316144], | ||
| 920 | + [120.588264,31.316373], | ||
| 921 | + [120.588712,31.313162], | ||
| 922 | + [120.58609,31.313013] | ||
| 923 | + ] | ||
| 924 | + | ||
| 925 | + // 隐藏边界以外的区域 | ||
| 926 | + let outer = [ | ||
| 927 | + new AMap.LngLat(-360, 90, true), | ||
| 928 | + new AMap.LngLat(-360, -90, true), | ||
| 929 | + new AMap.LngLat(360, -90, true), | ||
| 930 | + new AMap.LngLat(360, 90, true), | ||
| 931 | + ] // 遮盖填充反向 | ||
| 932 | + | ||
| 933 | + let pathArray = [ | ||
| 934 | + outer, | ||
| 935 | + list | ||
| 936 | + ] | ||
| 937 | + | ||
| 938 | + var polygon = new AMap.Polygon({ | ||
| 939 | + pathL: pathArray, | ||
| 940 | + strokeColor: "#fff", | ||
| 941 | + strokeWeight: 2, | ||
| 942 | + fillColor: "#fff", | ||
| 943 | + fillOpacity: 1, | ||
| 944 | + }) | ||
| 945 | + | ||
| 946 | + polygon.setPath(pathArray) | ||
| 947 | + this.map.add(polygon) | ||
| 948 | + | ||
| 949 | + }, | ||
| 915 | showInfoClick(e) { | 950 | showInfoClick(e) { |
| 916 | // console.log(e); | 951 | // console.log(e); |
| 917 | var zoom = this.map.getZoom(); //获取当前地图级别 | 952 | var zoom = this.map.getZoom(); //获取当前地图级别 | ... | ... |
-
Please register or login to post a comment