|
|
@ -29,6 +29,7 @@
|
|
|
|
</el-form>
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
|
|
|
|
<div id="container4"></div>
|
|
|
|
<div id="container4"></div>
|
|
|
|
|
|
|
|
<el-button class="add" @click="createPolygon">新建</el-button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
<script setup>
|
|
|
|
<script setup>
|
|
|
@ -43,12 +44,10 @@ const locale = (Cookies.get('language') || 'zhCn') === 'zhCn'
|
|
|
|
const {proxy} = getCurrentInstance();
|
|
|
|
const {proxy} = getCurrentInstance();
|
|
|
|
const queryParams = ref({})
|
|
|
|
const queryParams = ref({})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let map = null
|
|
|
|
let map = null
|
|
|
|
let path = [[116.390969, 39.911592], [116.391496, 39.909008], [116.389264, 39.909765], [116.38802, 39.911016]]
|
|
|
|
let path = [[116.390969, 39.911592], [116.391496, 39.909008], [116.389264, 39.909765], [116.38802, 39.911016]]
|
|
|
|
let path2 = [[116.400969, 39.921592], [116.401496, 39.919008], [116.399264, 39.919765], [116.39802, 39.921016]]
|
|
|
|
const areaPath = ref([path])
|
|
|
|
const areaPath = ref([path,path2])
|
|
|
|
const marketPath = ref([[116.390669, 39.911147],[116.400669, 39.921147]])
|
|
|
|
let marketPath = [116.390669, 39.911147]
|
|
|
|
|
|
|
|
AMapLoader.load({
|
|
|
|
AMapLoader.load({
|
|
|
|
key: "ba8fb8d8bae1b280b93406d5959d492f", // 申请好的Web端开发者Key,首次调用 load 时必填
|
|
|
|
key: "ba8fb8d8bae1b280b93406d5959d492f", // 申请好的Web端开发者Key,首次调用 load 时必填
|
|
|
|
// version: "1.4.15", //
|
|
|
|
// version: "1.4.15", //
|
|
|
@ -66,19 +65,6 @@ AMapLoader.load({
|
|
|
|
center: [116.397428, 39.90923], //初始化地图中心点位置
|
|
|
|
center: [116.397428, 39.90923], //初始化地图中心点位置
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
let marker = new AMap.Marker({
|
|
|
|
|
|
|
|
position: marketPath,
|
|
|
|
|
|
|
|
anchor: 'bottom-center',
|
|
|
|
|
|
|
|
offset: new AMap.Pixel(0, 0)
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
marker.setTitle('我是marker的title');
|
|
|
|
|
|
|
|
marker.setLabel({
|
|
|
|
|
|
|
|
direction: 'top',
|
|
|
|
|
|
|
|
offset: new AMap.Pixel(0, -10), //设置文本标注偏移量
|
|
|
|
|
|
|
|
content: "" + AMap.GeometryUtil.isPointInRing(marketPath,path,path2),
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
marker.setMap(map);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 在图面添加工具条控件,工具条控件集成了缩放、平移、定位等功能按钮在内的组合控件
|
|
|
|
// 在图面添加工具条控件,工具条控件集成了缩放、平移、定位等功能按钮在内的组合控件
|
|
|
|
map.addControl(new AMap.ToolBar({position: 'LT'}));
|
|
|
|
map.addControl(new AMap.ToolBar({position: 'LT'}));
|
|
|
|
|
|
|
|
|
|
|
@ -91,42 +77,99 @@ AMapLoader.load({
|
|
|
|
// 在图面添加类别切换控件,实现默认图层与卫星图、实施交通图层之间切换的控制
|
|
|
|
// 在图面添加类别切换控件,实现默认图层与卫星图、实施交通图层之间切换的控制
|
|
|
|
map.addControl(new AMap.MapType());
|
|
|
|
map.addControl(new AMap.MapType());
|
|
|
|
|
|
|
|
|
|
|
|
areaPath.value.forEach( (e,index)=> {
|
|
|
|
|
|
|
|
|
|
|
|
setPolygon(areaPath.value)
|
|
|
|
|
|
|
|
setMarker(marketPath.value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).catch(e => {
|
|
|
|
|
|
|
|
console.log(e);
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
const setMarker = (e)=>{
|
|
|
|
|
|
|
|
let markers = map.getAllOverlays('marker');
|
|
|
|
|
|
|
|
map.remove(markers)
|
|
|
|
|
|
|
|
e.forEach(val=>{
|
|
|
|
|
|
|
|
let marker = new AMap.Marker({
|
|
|
|
|
|
|
|
position: val,
|
|
|
|
|
|
|
|
anchor: 'bottom-center',
|
|
|
|
|
|
|
|
offset: new AMap.Pixel(0, 0)
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
marker.setTitle('我是marker的title');
|
|
|
|
|
|
|
|
console.log((areaPath.value))
|
|
|
|
|
|
|
|
let isPointInRing = false
|
|
|
|
|
|
|
|
areaPath.value.forEach(res=>{
|
|
|
|
|
|
|
|
if(AMap.GeometryUtil.isPointInRing(val, res)){
|
|
|
|
|
|
|
|
isPointInRing=true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
marker.setLabel({
|
|
|
|
|
|
|
|
direction: 'top',
|
|
|
|
|
|
|
|
offset: new AMap.Pixel(0, -10), //设置文本标注偏移量
|
|
|
|
|
|
|
|
content: "" +isPointInRing,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
marker.setMap(map);
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const setPolygon = (res) => {
|
|
|
|
|
|
|
|
res.forEach((e, index) => {
|
|
|
|
let polygon = new AMap.Polygon({path: e});
|
|
|
|
let polygon = new AMap.Polygon({path: e});
|
|
|
|
map.add([polygon]);
|
|
|
|
map.add([polygon]);
|
|
|
|
let polyEditor = new AMap.PolygonEditor(map);
|
|
|
|
let polyEditor = new AMap.PolygonEditor(map);
|
|
|
|
polyEditor.addAdsorbPolygons([polygon]);
|
|
|
|
polyEditor.addAdsorbPolygons([polygon]);
|
|
|
|
polyEditor.on('add', function (data) {
|
|
|
|
polygon.on('dblclick', () => {
|
|
|
|
console.log(data);
|
|
|
|
polyEditor.setTarget(polygon);
|
|
|
|
let polygon = data.target;
|
|
|
|
polyEditor.open();
|
|
|
|
polyEditor.addAdsorbPolygons(polygon);
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
polyEditor.on('addnode', function (data) {
|
|
|
|
polyEditor.on('addnode', function (data) {
|
|
|
|
// 获取区域坐标
|
|
|
|
// 获取区域坐标
|
|
|
|
areaPath.value[index] = polyEditor.getTarget()._opts.path
|
|
|
|
areaPath.value[index] = polyEditor.getTarget()._opts.path
|
|
|
|
|
|
|
|
setMarker(marketPath.value)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
polyEditor.on('adjust', function (data) {
|
|
|
|
polyEditor.on('adjust', function (data) {
|
|
|
|
// 获取区域坐标
|
|
|
|
// 获取区域坐标
|
|
|
|
areaPath.value[index] = polyEditor.getTarget()._opts.path
|
|
|
|
areaPath.value[index] = polyEditor.getTarget()._opts.path
|
|
|
|
|
|
|
|
setMarker(marketPath.value)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
polyEditor.setTarget(polygon);
|
|
|
|
|
|
|
|
polyEditor.open();
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
setMarker(marketPath.value)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let createPolygon = () => {
|
|
|
|
|
|
|
|
let arr = []
|
|
|
|
|
|
|
|
map.add([new AMap.Polygon({path: arr})]);
|
|
|
|
|
|
|
|
let polyEditor = new AMap.PolygonEditor(map)
|
|
|
|
|
|
|
|
let index = areaPath.value.length
|
|
|
|
|
|
|
|
polyEditor.close();
|
|
|
|
|
|
|
|
polyEditor.setTarget();
|
|
|
|
|
|
|
|
polyEditor.open();
|
|
|
|
|
|
|
|
polyEditor.on('add', function (data) {
|
|
|
|
|
|
|
|
areaPath.value.push(data.target._opts.path)
|
|
|
|
|
|
|
|
// polyEditor.close();
|
|
|
|
|
|
|
|
// map.clearMap()
|
|
|
|
|
|
|
|
setPolygon(areaPath.value)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
polyEditor.on('addnode', function (data) {
|
|
|
|
|
|
|
|
// 获取区域坐标
|
|
|
|
|
|
|
|
areaPath.value[index] = polyEditor.getTarget()._opts.path
|
|
|
|
|
|
|
|
setMarker(marketPath.value)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
polyEditor.on('adjust', function (data) {
|
|
|
|
|
|
|
|
// 获取区域坐标
|
|
|
|
|
|
|
|
areaPath.value[index] = polyEditor.getTarget()._opts.path
|
|
|
|
|
|
|
|
setMarker(marketPath.value)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}).catch(e => {
|
|
|
|
|
|
|
|
console.log(e);
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
const getLine = () => {
|
|
|
|
const getLine = () => {
|
|
|
|
let list = areaPath.value
|
|
|
|
let list = areaPath.value
|
|
|
|
let params = []
|
|
|
|
let params = []
|
|
|
|
list.forEach((e,index)=>{
|
|
|
|
list.forEach((e, index) => {
|
|
|
|
e.forEach(val => {
|
|
|
|
e.forEach(val => {
|
|
|
|
params.push({
|
|
|
|
params.push({
|
|
|
|
longitude:val[0],
|
|
|
|
longitude: val[0],
|
|
|
|
latitude:val[1],
|
|
|
|
latitude: val[1],
|
|
|
|
index:index
|
|
|
|
index: index
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -140,4 +183,10 @@ const getLine = () => {
|
|
|
|
width: 100%;
|
|
|
|
width: 100%;
|
|
|
|
height: calc(100vh - 190px);
|
|
|
|
height: calc(100vh - 190px);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.add {
|
|
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
|
|
bottom: 15px;
|
|
|
|
|
|
|
|
right: 150px;
|
|
|
|
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</style>
|
|
|
|