|
@@ -1,7 +1,11 @@ |
|
|
<template> |
|
|
<template> |
|
|
<div id="map"> |
|
|
|
|
|
|
|
|
<div id="map" ref="mapContainer"> |
|
|
<div class="tips" v-if="isShowTips"> |
|
|
<div class="tips" v-if="isShowTips"> |
|
|
<p>{{this.tips}}</p> |
|
|
<p>{{this.tips}}</p> |
|
|
|
|
|
<p>当前点坐标:</p> |
|
|
|
|
|
<van-field v-model="map.center"></van-field> |
|
|
|
|
|
<p>绘制的围栏坐标数组:</p> |
|
|
|
|
|
<van-field v-model="polyList" type="textarea"></van-field> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
@@ -16,7 +20,7 @@ export default { |
|
|
map: { |
|
|
map: { |
|
|
instance: null, |
|
|
instance: null, |
|
|
zoom: 13, |
|
|
zoom: 13, |
|
|
center: '' /* || [113.121586,23.021351] */, // |
|
|
|
|
|
|
|
|
center: null /* || [113.121586,23.021351] */, // |
|
|
marker: null, |
|
|
marker: null, |
|
|
polygon: null, |
|
|
polygon: null, |
|
|
radius: '', |
|
|
radius: '', |
|
@@ -25,11 +29,15 @@ export default { |
|
|
|
|
|
|
|
|
isPointInRing: null, //是否在围栏内 |
|
|
isPointInRing: null, //是否在围栏内 |
|
|
isShowTips: false, //是否显示tips, 默认false,等到围栏加载完才显示 |
|
|
isShowTips: false, //是否显示tips, 默认false,等到围栏加载完才显示 |
|
|
|
|
|
/* polyList: '', */ |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
computed: { |
|
|
computed: { |
|
|
tips() { |
|
|
tips() { |
|
|
return this.isPointInRing ? '该点在围栏内' : '该点在围栏外'; |
|
|
return this.isPointInRing ? '该点在围栏内' : '该点在围栏外'; |
|
|
|
|
|
}, |
|
|
|
|
|
polyList() { |
|
|
|
|
|
return this.polyLnglAtList.toString(); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
created() { |
|
|
created() { |
|
@@ -141,10 +149,17 @@ export default { |
|
|
/* let point = this.map.marker.getPosition(); |
|
|
/* let point = this.map.marker.getPosition(); |
|
|
this.isPointInRing = AMap.GeometryUtil.isPointInRing(point, this.map.center); */ |
|
|
this.isPointInRing = AMap.GeometryUtil.isPointInRing(point, this.map.center); */ |
|
|
let point = this.map.marker.getPosition(); |
|
|
let point = this.map.marker.getPosition(); |
|
|
|
|
|
console.log("point", point, typeof point); |
|
|
|
|
|
this.map.center = point.toString(); |
|
|
/* console.log("是否在多边形围栏内部::", this.isPointInRing ); */ |
|
|
/* console.log("是否在多边形围栏内部::", this.isPointInRing ); */ |
|
|
// 判断一个坐标点是否在一个圆形内 |
|
|
// 判断一个坐标点是否在一个圆形内 |
|
|
this.isPointInRing = this.map.polygon.contains(point); |
|
|
|
|
|
|
|
|
this.isPointInRing = this.map.polygon.contains(point); |
|
|
console.log("是否在圆形围栏内部", this.map.polygon.contains(point)); |
|
|
console.log("是否在圆形围栏内部", this.map.polygon.contains(point)); |
|
|
|
|
|
let divBox = document.createElement('span'); |
|
|
|
|
|
divBox.innerHTML = this.isPointInRing; |
|
|
|
|
|
divBox.className = 'fence'; |
|
|
|
|
|
document.body.appendChild(divBox); |
|
|
|
|
|
console.log("map-container", this.$refs.mapContainer); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@@ -156,17 +171,22 @@ export default { |
|
|
width: 100%; |
|
|
width: 100%; |
|
|
z-index: 99; |
|
|
z-index: 99; |
|
|
.tips { |
|
|
.tips { |
|
|
height: 80px; |
|
|
|
|
|
width: 40%; |
|
|
|
|
|
line-height: 80px; |
|
|
|
|
|
|
|
|
height: 200px; |
|
|
|
|
|
width: 90%; |
|
|
|
|
|
padding: 5px; |
|
|
|
|
|
overflow: scroll; |
|
|
|
|
|
/* line-height: 80px; */ |
|
|
color: red; |
|
|
color: red; |
|
|
background: wheat; |
|
|
background: wheat; |
|
|
position: absolute; |
|
|
position: absolute; |
|
|
top: 20px; |
|
|
top: 20px; |
|
|
left: 10%; |
|
|
|
|
|
|
|
|
left: 5%; |
|
|
text-align: center; |
|
|
text-align: center; |
|
|
font-size: 16px; |
|
|
font-size: 16px; |
|
|
z-index: 9999; |
|
|
z-index: 9999; |
|
|
|
|
|
p { |
|
|
|
|
|
padding: 10px; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
</style> |
|
|
</style> |