|
@@ -19,12 +19,14 @@ export default {
|
|
|
depId: 239,
|
|
|
markeList: null,
|
|
|
timer: null,
|
|
|
- ids:'',
|
|
|
- ruler1:null
|
|
|
+ ids: '',
|
|
|
+ ruler1: null,
|
|
|
+ mouseTool: null,
|
|
|
}
|
|
|
},
|
|
|
props: {
|
|
|
idInfo: Object,
|
|
|
+ showRang: String,
|
|
|
},
|
|
|
watch: {
|
|
|
idInfo: {
|
|
@@ -35,7 +37,7 @@ export default {
|
|
|
if (this.timer) {
|
|
|
clearTimeout(this.timer)
|
|
|
}
|
|
|
- if (val.key.indexOf('car')>=0) {
|
|
|
+ if (val.key.indexOf('car') >= 0) {
|
|
|
this.ids = val.meta.id
|
|
|
this.addCarMaker(this.AMap)
|
|
|
} else {
|
|
@@ -48,11 +50,16 @@ export default {
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
+ callback(fn) {
|
|
|
+ if (fn) {
|
|
|
+ fn(this)
|
|
|
+ }
|
|
|
+ },
|
|
|
async initMap() {
|
|
|
return AMapLoader.load({
|
|
|
key: 'a09220a9ab56352435dd123abf0c37f6', // 申请好的Web端开发者Key,首次调用 load 时必填
|
|
|
version: '2.0', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
|
|
|
- plugins: ['AMap.RangingTool'], // 需要使用的的插件列表,如比例尺'AMap.Scale'等 AMap.RangingTool(测距)
|
|
|
+ plugins: ['AMap.RangingTool', 'AMap.MouseTool'], // 需要使用的的插件列表,如比例尺'AMap.Scale'等 AMap.RangingTool(测距)
|
|
|
})
|
|
|
.then((AMap) => {
|
|
|
this.AMap = AMap
|
|
@@ -65,8 +72,17 @@ export default {
|
|
|
center: ['106.4754116', '29.6307097'],
|
|
|
})
|
|
|
// 测距
|
|
|
- this. ruler1 = new AMap.RangingTool(this.map)
|
|
|
-// this.ruler1.turnOn()
|
|
|
+ this.ruler1 = new AMap.RangingTool(this.map)
|
|
|
+ // 面积
|
|
|
+ this.mouseTool = new AMap.MouseTool(this.map)
|
|
|
+ this.mouseTool.measureArea({
|
|
|
+ strokeColor: '#80d8ff',
|
|
|
+ fillColor: '#80d8ff',
|
|
|
+ fillOpacity: 0.3,
|
|
|
+ //同 Polygon 的 Option 设置
|
|
|
+ })
|
|
|
+ this.mouseTool.close(true)
|
|
|
+ // this.ruler1.turnOn()
|
|
|
this.map.setDefaultCursor(`url(https://webapi.amap.com/theme/v1.3/openhand.cur),default`)
|
|
|
this.map.on('mousedown', () => {
|
|
|
this.map.setDefaultCursor(`url(https://webapi.amap.com/theme/v1.3/closedhand.cur),default`)
|