|
@@ -6,28 +6,32 @@
|
|
|
<button class="el-button" @click="closeEdit" style="margin-bottom: 5px">编辑完成</button>
|
|
<button class="el-button" @click="closeEdit" style="margin-bottom: 5px">编辑完成</button>
|
|
|
<button class="el-button" @click="getPath" style="margin-bottom: 5px">保存</button>
|
|
<button class="el-button" @click="getPath" style="margin-bottom: 5px">保存</button>
|
|
|
</div>
|
|
</div>
|
|
|
- <div id="container" style="height: 600px;display: block;position: relative;margin-top: 10px;">
|
|
|
|
|
|
|
+ <div id="container" style="height: 600px;display: block;position: relative;margin-top: 10px;">
|
|
|
<div id="panel" style="position: absolute;top: 0;bottom:0;right: 0;width: 300px;overflow: auto;z-index: 9;"></div>
|
|
<div id="panel" style="position: absolute;top: 0;bottom:0;right: 0;width: 300px;overflow: auto;z-index: 9;"></div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
<script>
|
|
<script>
|
|
|
|
|
+ import {
|
|
|
|
|
+ getDetail as getAgencyDetail
|
|
|
|
|
+ } from "@/api/community/agency.js"
|
|
|
export default {
|
|
export default {
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
- location:{
|
|
|
|
|
|
|
+ location: {
|
|
|
latitude: "39.994257",
|
|
latitude: "39.994257",
|
|
|
longitude: "116.471354",
|
|
longitude: "116.471354",
|
|
|
},
|
|
},
|
|
|
- map:null,
|
|
|
|
|
- polyEditor:null,
|
|
|
|
|
- marker:null,
|
|
|
|
|
- polygonPath:[],
|
|
|
|
|
- address:'',
|
|
|
|
|
|
|
+ map: null,
|
|
|
|
|
+ polyEditor: null,
|
|
|
|
|
+ marker: null,
|
|
|
|
|
+ polygonPath: [],
|
|
|
|
|
+ address: '',
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- props:['editForm', 'longitude', 'latitude', 'region'],
|
|
|
|
|
- mounted() {
|
|
|
|
|
|
|
+ props: ['editForm', 'longitude', 'latitude', 'region'],
|
|
|
|
|
+ async mounted() {
|
|
|
|
|
+ await this.getLatLng()
|
|
|
let data = this.editForm
|
|
let data = this.editForm
|
|
|
let longitude = this.longitude;
|
|
let longitude = this.longitude;
|
|
|
let latitude = this.latitude;
|
|
let latitude = this.latitude;
|
|
@@ -36,7 +40,7 @@
|
|
|
this.location.longitude = longitude;
|
|
this.location.longitude = longitude;
|
|
|
this.location.latitude = latitude;
|
|
this.location.latitude = latitude;
|
|
|
}
|
|
}
|
|
|
- if(data.boundaryPath!==""&&data.boundaryPath!==null&&data.boundaryPath!==undefined){
|
|
|
|
|
|
|
+ if (data.boundaryPath !== "" && data.boundaryPath !== null && data.boundaryPath !== undefined) {
|
|
|
this.polygonPath = JSON.parse(data.boundaryPath)
|
|
this.polygonPath = JSON.parse(data.boundaryPath)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -45,8 +49,13 @@
|
|
|
this.initPolygon()
|
|
this.initPolygon()
|
|
|
this.initSearch()
|
|
this.initSearch()
|
|
|
},
|
|
},
|
|
|
- methods:{
|
|
|
|
|
- initMap(){
|
|
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ async getLatLng() {
|
|
|
|
|
+ let data = (await getAgencyDetail()).data.data
|
|
|
|
|
+ this.location.longitude = data.longitude;
|
|
|
|
|
+ this.location.latitude = data.latitude;
|
|
|
|
|
+ },
|
|
|
|
|
+ initMap() {
|
|
|
var _this = this
|
|
var _this = this
|
|
|
this.map = new AMap.Map('container', {
|
|
this.map = new AMap.Map('container', {
|
|
|
resizeEnable: true, //是否监控地图容器尺寸变化
|
|
resizeEnable: true, //是否监控地图容器尺寸变化
|
|
@@ -59,9 +68,9 @@
|
|
|
_this.setMark(_this.location)
|
|
_this.setMark(_this.location)
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
- setMark(data){
|
|
|
|
|
|
|
+ setMark(data) {
|
|
|
var _this = this
|
|
var _this = this
|
|
|
- if(this.marker){
|
|
|
|
|
|
|
+ if (this.marker) {
|
|
|
this.map.remove(this.marker);
|
|
this.map.remove(this.marker);
|
|
|
}
|
|
}
|
|
|
AMap.plugin('AMap.Geocoder', function() {
|
|
AMap.plugin('AMap.Geocoder', function() {
|
|
@@ -69,50 +78,51 @@
|
|
|
var lnglat = [data.longitude, data.latitude]
|
|
var lnglat = [data.longitude, data.latitude]
|
|
|
geocoder.getAddress(lnglat, function(status, result) {
|
|
geocoder.getAddress(lnglat, function(status, result) {
|
|
|
if (status === 'complete' && result.info === 'OK') {
|
|
if (status === 'complete' && result.info === 'OK') {
|
|
|
- // result为对应的地理位置详细信息
|
|
|
|
|
- let address = result.regeocode.formattedAddress
|
|
|
|
|
- _this.marker = new AMap.Marker({
|
|
|
|
|
- position: new AMap.LngLat(data.longitude, data.latitude), // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
|
|
|
|
|
- });
|
|
|
|
|
- _this.marker.setLabel({
|
|
|
|
|
- direction:'center top',
|
|
|
|
|
- offset: new AMap.Pixel(10, 0), //设置文本标注偏移量
|
|
|
|
|
- content: address, //设置文本标注内容
|
|
|
|
|
- });
|
|
|
|
|
- _this.address = address
|
|
|
|
|
- _this.map.add(_this.marker);
|
|
|
|
|
|
|
+ // result为对应的地理位置详细信息
|
|
|
|
|
+ let address = result.regeocode.formattedAddress
|
|
|
|
|
+ _this.marker = new AMap.Marker({
|
|
|
|
|
+ position: new AMap.LngLat(data.longitude, data
|
|
|
|
|
+ .latitude), // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
|
|
|
|
|
+ });
|
|
|
|
|
+ _this.marker.setLabel({
|
|
|
|
|
+ direction: 'center top',
|
|
|
|
|
+ offset: new AMap.Pixel(10, 0), //设置文本标注偏移量
|
|
|
|
|
+ content: address, //设置文本标注内容
|
|
|
|
|
+ });
|
|
|
|
|
+ _this.address = address
|
|
|
|
|
+ _this.map.add(_this.marker);
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
- initSearch(){
|
|
|
|
|
- var _this = this
|
|
|
|
|
- //输入提示
|
|
|
|
|
- var autoOptions = {
|
|
|
|
|
- input: "tipinput"
|
|
|
|
|
- };
|
|
|
|
|
- AMap.plugin(['AMap.PlaceSearch','AMap.AutoComplete'], function(){
|
|
|
|
|
- var auto = new AMap.AutoComplete(autoOptions);
|
|
|
|
|
- var placeSearch = new AMap.PlaceSearch({
|
|
|
|
|
- pageSize: 5, // 单页显示结果条数
|
|
|
|
|
- pageIndex: 1, // 页码
|
|
|
|
|
- map: _this.map, // 展现结果的地图实例
|
|
|
|
|
- panel: "panel", // 结果列表将在此容器中进行展示。
|
|
|
|
|
- autoFitView: true // 是否自动调整地图视野使绘制的 Marker点都处于视口的可见范围
|
|
|
|
|
- }); //构造地点查询类
|
|
|
|
|
- auto.on("select", select);//注册监听,当选中某条记录时会触发
|
|
|
|
|
- function select(e) {
|
|
|
|
|
- placeSearch.setCity(e.poi.adcode);
|
|
|
|
|
- placeSearch.search(e.poi.name); //关键字查询查询
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ initSearch() {
|
|
|
|
|
+ var _this = this
|
|
|
|
|
+ //输入提示
|
|
|
|
|
+ var autoOptions = {
|
|
|
|
|
+ input: "tipinput"
|
|
|
|
|
+ };
|
|
|
|
|
+ AMap.plugin(['AMap.PlaceSearch', 'AMap.AutoComplete'], function() {
|
|
|
|
|
+ var auto = new AMap.AutoComplete(autoOptions);
|
|
|
|
|
+ var placeSearch = new AMap.PlaceSearch({
|
|
|
|
|
+ pageSize: 5, // 单页显示结果条数
|
|
|
|
|
+ pageIndex: 1, // 页码
|
|
|
|
|
+ map: _this.map, // 展现结果的地图实例
|
|
|
|
|
+ panel: "panel", // 结果列表将在此容器中进行展示。
|
|
|
|
|
+ autoFitView: true // 是否自动调整地图视野使绘制的 Marker点都处于视口的可见范围
|
|
|
|
|
+ }); //构造地点查询类
|
|
|
|
|
+ auto.on("select", select); //注册监听,当选中某条记录时会触发
|
|
|
|
|
+ function select(e) {
|
|
|
|
|
+ placeSearch.setCity(e.poi.adcode);
|
|
|
|
|
+ placeSearch.search(e.poi.name); //关键字查询查询
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
- initPolygon(){
|
|
|
|
|
|
|
+ initPolygon() {
|
|
|
var _this = this;
|
|
var _this = this;
|
|
|
this.polyEditor = new AMap.PolygonEditor(this.map);
|
|
this.polyEditor = new AMap.PolygonEditor(this.map);
|
|
|
this.setPolygon(this.polygonPath)
|
|
this.setPolygon(this.polygonPath)
|
|
|
- this.polyEditor.on('add', function (data) {
|
|
|
|
|
|
|
+ this.polyEditor.on('add', function(data) {
|
|
|
var polygon = data.target;
|
|
var polygon = data.target;
|
|
|
_this.polyEditor.addAdsorbPolygons(polygon);
|
|
_this.polyEditor.addAdsorbPolygons(polygon);
|
|
|
// polygon.on('click', (res) => {
|
|
// polygon.on('click', (res) => {
|
|
@@ -122,64 +132,64 @@
|
|
|
// })
|
|
// })
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
- setPolygon(data){
|
|
|
|
|
- if(data.length<1)return
|
|
|
|
|
|
|
+ setPolygon(data) {
|
|
|
|
|
+ if (data.length < 1) return
|
|
|
var _this = this
|
|
var _this = this
|
|
|
- let polygon = new AMap.Polygon({
|
|
|
|
|
- path: data,
|
|
|
|
|
- fillColor: '#ccebc5',
|
|
|
|
|
- strokeOpacity: 1,
|
|
|
|
|
- fillOpacity: 0.5,
|
|
|
|
|
- strokeColor: '#2b8cbe',
|
|
|
|
|
- strokeWeight: 1,
|
|
|
|
|
- strokeStyle: 'dashed',
|
|
|
|
|
- strokeDasharray: [5, 5],
|
|
|
|
|
- });
|
|
|
|
|
- polygon.on('mouseover', () => {
|
|
|
|
|
- polygon.setOptions({
|
|
|
|
|
- fillOpacity: 0.7,
|
|
|
|
|
- fillColor: '#7bccc4'
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
- polygon.on('mouseout', () => {
|
|
|
|
|
- polygon.setOptions({
|
|
|
|
|
- fillOpacity: 0.5,
|
|
|
|
|
- fillColor: '#ccebc5'
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
- polygon.on('click', () => {
|
|
|
|
|
- this.polyEditor.open();
|
|
|
|
|
- })
|
|
|
|
|
- this.map.add(polygon);
|
|
|
|
|
- this.map.setFitView();
|
|
|
|
|
- _this.polyEditor.setTarget(polygon)
|
|
|
|
|
|
|
+ let polygon = new AMap.Polygon({
|
|
|
|
|
+ path: data,
|
|
|
|
|
+ fillColor: '#ccebc5',
|
|
|
|
|
+ strokeOpacity: 1,
|
|
|
|
|
+ fillOpacity: 0.5,
|
|
|
|
|
+ strokeColor: '#2b8cbe',
|
|
|
|
|
+ strokeWeight: 1,
|
|
|
|
|
+ strokeStyle: 'dashed',
|
|
|
|
|
+ strokeDasharray: [5, 5],
|
|
|
|
|
+ });
|
|
|
|
|
+ polygon.on('mouseover', () => {
|
|
|
|
|
+ polygon.setOptions({
|
|
|
|
|
+ fillOpacity: 0.7,
|
|
|
|
|
+ fillColor: '#7bccc4'
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ polygon.on('mouseout', () => {
|
|
|
|
|
+ polygon.setOptions({
|
|
|
|
|
+ fillOpacity: 0.5,
|
|
|
|
|
+ fillColor: '#ccebc5'
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ polygon.on('click', () => {
|
|
|
|
|
+ this.polyEditor.open();
|
|
|
|
|
+ })
|
|
|
|
|
+ this.map.add(polygon);
|
|
|
|
|
+ this.map.setFitView();
|
|
|
|
|
+ _this.polyEditor.setTarget(polygon)
|
|
|
},
|
|
},
|
|
|
createPolygon() {
|
|
createPolygon() {
|
|
|
this.polyEditor.close();
|
|
this.polyEditor.close();
|
|
|
this.polyEditor.setTarget();
|
|
this.polyEditor.setTarget();
|
|
|
this.polyEditor.open();
|
|
this.polyEditor.open();
|
|
|
},
|
|
},
|
|
|
- startEdit(){
|
|
|
|
|
|
|
+ startEdit() {
|
|
|
this.polyEditor.open();
|
|
this.polyEditor.open();
|
|
|
},
|
|
},
|
|
|
- closeEdit(){
|
|
|
|
|
|
|
+ closeEdit() {
|
|
|
this.polyEditor.close();
|
|
this.polyEditor.close();
|
|
|
},
|
|
},
|
|
|
- getPath(){
|
|
|
|
|
|
|
+ getPath() {
|
|
|
let target = this.polyEditor.getTarget()
|
|
let target = this.polyEditor.getTarget()
|
|
|
let path = ""
|
|
let path = ""
|
|
|
- if(target){
|
|
|
|
|
|
|
+ if (target) {
|
|
|
path = target._opts.path
|
|
path = target._opts.path
|
|
|
}
|
|
}
|
|
|
- if(path!==""&&path!==null&&path!==undefined){
|
|
|
|
|
|
|
+ if (path !== "" && path !== null && path !== undefined) {
|
|
|
path = JSON.stringify(path)
|
|
path = JSON.stringify(path)
|
|
|
}
|
|
}
|
|
|
this.region = this.address;
|
|
this.region = this.address;
|
|
|
this.latitude = this.location['latitude']
|
|
this.latitude = this.location['latitude']
|
|
|
this.longitude = this.location['longitude']
|
|
this.longitude = this.location['longitude']
|
|
|
- if(this.editForm != "{}"){
|
|
|
|
|
- this.editForm.boundaryPath = path
|
|
|
|
|
- this.$emit('update:editForm', this.editForm)
|
|
|
|
|
|
|
+ if (this.editForm != "{}") {
|
|
|
|
|
+ this.editForm.boundaryPath = path
|
|
|
|
|
+ this.$emit('update:editForm', this.editForm)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
this.$emit('update:region', this.region);
|
|
this.$emit('update:region', this.region);
|
|
@@ -194,7 +204,7 @@
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
<style>
|
|
|
- .amap-sug-result{
|
|
|
|
|
|
|
+ .amap-sug-result {
|
|
|
z-index: 999999999;
|
|
z-index: 999999999;
|
|
|
background-color: #fff;
|
|
background-color: #fff;
|
|
|
color: #000;
|
|
color: #000;
|