|
@@ -1,11 +1,13 @@
|
|
|
<template>
|
|
<template>
|
|
|
<el-dialog
|
|
<el-dialog
|
|
|
- title="位置选择"
|
|
|
|
|
|
|
+ title="校准位置"
|
|
|
:visible.sync="dialogVisible"
|
|
:visible.sync="dialogVisible"
|
|
|
- width="800px"
|
|
|
|
|
|
|
+ width="1200px"
|
|
|
:close-on-click-modal="false"
|
|
:close-on-click-modal="false"
|
|
|
:close-on-press-escape="false"
|
|
:close-on-press-escape="false"
|
|
|
|
|
+ :destroy-on-close="true"
|
|
|
@close="handleClose"
|
|
@close="handleClose"
|
|
|
|
|
+ append-to-body
|
|
|
>
|
|
>
|
|
|
<div class="map-container block-amap-box">
|
|
<div class="map-container block-amap-box">
|
|
|
<!-- <div class="searchBox">
|
|
<!-- <div class="searchBox">
|
|
@@ -34,43 +36,76 @@
|
|
|
class="demo-form-inline"
|
|
class="demo-form-inline"
|
|
|
size="mini"
|
|
size="mini"
|
|
|
>
|
|
>
|
|
|
- <el-form-item label="经度">
|
|
|
|
|
- <el-input v-model="locationForm.lng" disabled></el-input>
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
- <el-form-item label="纬度">
|
|
|
|
|
- <el-input v-model="locationForm.lat" disabled></el-input>
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
- <!-- <el-form-item>
|
|
|
|
|
- <el-button type="primary" size="mini" @click="locationSearch"
|
|
|
|
|
- >定位</el-button
|
|
|
|
|
- >
|
|
|
|
|
- </el-form-item> -->
|
|
|
|
|
- <el-form-item>
|
|
|
|
|
- <el-input
|
|
|
|
|
- @change="searchFun"
|
|
|
|
|
- clearable
|
|
|
|
|
- placeholder="请输入地区检索"
|
|
|
|
|
- v-model.lazy="searchAddr"
|
|
|
|
|
- >
|
|
|
|
|
- <i slot="suffix" class="el-input__icon el-icon-search"></i>
|
|
|
|
|
- </el-input>
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
|
|
+ <el-row :gutter="40">
|
|
|
|
|
+ <el-col :span="10">
|
|
|
|
|
+ <el-form-item label="经度">
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ v-model="locationForm.lng"
|
|
|
|
|
+ placeholder="请输入经度"
|
|
|
|
|
+ ></el-input>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-col>
|
|
|
|
|
+ <el-col :span="10">
|
|
|
|
|
+ <el-form-item label="纬度">
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ v-model="locationForm.lat"
|
|
|
|
|
+ placeholder="请输入纬度"
|
|
|
|
|
+ ></el-input>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-col>
|
|
|
|
|
+ <el-col :span="4">
|
|
|
|
|
+ <el-form-item>
|
|
|
|
|
+ <el-button type="primary" size="mini" @click="handleLocation"
|
|
|
|
|
+ >定位</el-button
|
|
|
|
|
+ >
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-col>
|
|
|
|
|
+ </el-row>
|
|
|
|
|
+ <el-row :gutter="40">
|
|
|
|
|
+ <el-col :span="20">
|
|
|
|
|
+ <el-form-item>
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ clearable
|
|
|
|
|
+ placeholder="请输入地区检索"
|
|
|
|
|
+ v-model.lazy="searchAddr"
|
|
|
|
|
+ >
|
|
|
|
|
+ <!-- <i slot="suffix" class="el-input__icon el-icon-search"></i> -->
|
|
|
|
|
+ </el-input>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-col>
|
|
|
|
|
+ <el-col :span="4">
|
|
|
|
|
+ <el-form-item>
|
|
|
|
|
+ <el-button type="primary" size="mini" @click="handleSearch"
|
|
|
|
|
+ >查询</el-button
|
|
|
|
|
+ >
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-col>
|
|
|
|
|
+ </el-row>
|
|
|
</el-form>
|
|
</el-form>
|
|
|
- <div style="height: 70vh" id="searchAmapWrapper" tabindex="0"></div>
|
|
|
|
|
|
|
+ <div
|
|
|
|
|
+ style="height: 700px; margin-bottom: 24px"
|
|
|
|
|
+ id="searchAmapWrapper"
|
|
|
|
|
+ tabindex="0"
|
|
|
|
|
+ ></div>
|
|
|
</div>
|
|
</div>
|
|
|
<span slot="footer" class="dialog-footer">
|
|
<span slot="footer" class="dialog-footer">
|
|
|
<el-button
|
|
<el-button
|
|
|
@click="handleClose"
|
|
@click="handleClose"
|
|
|
:disabled="dialogSubmitLoading"
|
|
:disabled="dialogSubmitLoading"
|
|
|
:loading="dialogSubmitLoading"
|
|
:loading="dialogSubmitLoading"
|
|
|
|
|
+ class="plainbutton"
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ plain
|
|
|
|
|
+ size="mini"
|
|
|
>取 消</el-button
|
|
>取 消</el-button
|
|
|
>
|
|
>
|
|
|
<el-button
|
|
<el-button
|
|
|
:disabled="dialogSubmitLoading"
|
|
:disabled="dialogSubmitLoading"
|
|
|
type="primary"
|
|
type="primary"
|
|
|
@click="submitForm"
|
|
@click="submitForm"
|
|
|
|
|
+ size="mini"
|
|
|
:loading="dialogSubmitLoading"
|
|
:loading="dialogSubmitLoading"
|
|
|
- >确定</el-button
|
|
|
|
|
|
|
+ >保存</el-button
|
|
|
>
|
|
>
|
|
|
</span>
|
|
</span>
|
|
|
</el-dialog>
|
|
</el-dialog>
|
|
@@ -102,17 +137,29 @@ export default {
|
|
|
lng: '',
|
|
lng: '',
|
|
|
lat: ''
|
|
lat: ''
|
|
|
},
|
|
},
|
|
|
- formatAddress: ''
|
|
|
|
|
|
|
+ formatAddress: '',
|
|
|
|
|
+ zoom: 14,
|
|
|
|
|
+ isAMap: true
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
watch: {
|
|
watch: {
|
|
|
visible(val) {
|
|
visible(val) {
|
|
|
if (val !== this.dialogVisible) {
|
|
if (val !== this.dialogVisible) {
|
|
|
this.dialogVisible = val;
|
|
this.dialogVisible = val;
|
|
|
|
|
+ this.locationForm = {
|
|
|
|
|
+ lng: this.data?.tmnLongitude,
|
|
|
|
|
+ lat: this.data?.tmnLatitude
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
if (val) {
|
|
if (val) {
|
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
|
- this.initMap();
|
|
|
|
|
|
|
+ if (this.isAMap) {
|
|
|
|
|
+ this.initMap();
|
|
|
|
|
+ this.locationSearch();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.initTiandiMap();
|
|
|
|
|
+ this.locationTiandiSearch();
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
} else {
|
|
} else {
|
|
|
this.resetForm();
|
|
this.resetForm();
|
|
@@ -126,12 +173,93 @@ export default {
|
|
|
},
|
|
},
|
|
|
mounted() {},
|
|
mounted() {},
|
|
|
methods: {
|
|
methods: {
|
|
|
|
|
+ initTiandiMap() {
|
|
|
|
|
+ var imageURL =
|
|
|
|
|
+ 'http://t0.tianditu.gov.cn/img_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=bfe366f1af60602bd0e51853af6d23d2';
|
|
|
|
|
+
|
|
|
|
|
+ //创建自定义图层对象
|
|
|
|
|
+ var lay = new T.TileLayer(imageURL, { minZoom: 1, maxZoom: 15 });
|
|
|
|
|
+ var lay2 = new T.TileLayer(
|
|
|
|
|
+ process.env.VUE_APP_WMS_RESOURCE_ADDRESS_TEST,
|
|
|
|
|
+ {
|
|
|
|
|
+ minZoom: 15,
|
|
|
|
|
+ maxZoom: 30
|
|
|
|
|
+ }
|
|
|
|
|
+ );
|
|
|
|
|
+ // 自定义小板桥图层
|
|
|
|
|
+ /**
|
|
|
|
|
+ * {
|
|
|
|
|
+ transparent: true,
|
|
|
|
|
+ VERSION: '1.1.0',
|
|
|
|
|
+ service: 'WMS',
|
|
|
|
|
+ transparent: true,
|
|
|
|
|
+ request: 'GetMap',
|
|
|
|
|
+ width: 768,
|
|
|
|
|
+ height: 663,
|
|
|
|
|
+ layers: 'yunfei:xbq0718qp',
|
|
|
|
|
+ srs: 'EPSG:4326',
|
|
|
|
|
+ format: 'application/openlayers'
|
|
|
|
|
+ }
|
|
|
|
|
+ */
|
|
|
|
|
+ var lay1 = new T.TileLayer.WMS(
|
|
|
|
|
+ process.env.VUE_APP_WMS_RESOURCE_ADDRESS_PREFIX,
|
|
|
|
|
+ {
|
|
|
|
|
+ width: 768,
|
|
|
|
|
+ height: 663,
|
|
|
|
|
+ layers: 'yunfei:xbq0718qp',
|
|
|
|
|
+ transparent: true,
|
|
|
|
|
+ styles: ''
|
|
|
|
|
+ // crs: 'EPSG:4326'
|
|
|
|
|
+ // bbox: '106.448774,30.951907909501745,106.49528109636745,30.992093',
|
|
|
|
|
+ // format: 'application/openlayers'
|
|
|
|
|
+ }
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ this.map = new T.Map('searchAmapWrapper', {
|
|
|
|
|
+ layers: [lay1, lay]
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ this.map.on('click', (e) => {
|
|
|
|
|
+ const { lng, lat } = e.lnglat;
|
|
|
|
|
+ console.log(lng, lat, e.lnglat);
|
|
|
|
|
+ this.locationForm = {
|
|
|
|
|
+ lng,
|
|
|
|
|
+ lat
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ this.addMarker(lng, lat);
|
|
|
|
|
+
|
|
|
|
|
+ this.formatAddress = '';
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ this.geocoder = new T.Geocoder();
|
|
|
|
|
+
|
|
|
|
|
+ this.map.centerAndZoom(new T.LngLat(106.476278, 30.960783), this.zoom);
|
|
|
|
|
+ },
|
|
|
initMap() {
|
|
initMap() {
|
|
|
|
|
+ const imageLayer = new AMap.ImageLayer({
|
|
|
|
|
+ url: process.env.VUE_APP_SYS_BASE_URL + '/layer/changli.png',
|
|
|
|
|
+ bounds: new AMap.Bounds(
|
|
|
|
|
+ [118.98942, 39.589391],
|
|
|
|
|
+ [119.018889, 39.567637]
|
|
|
|
|
+ ),
|
|
|
|
|
+ zooms: [16.5, 30]
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
var map = new AMap.Map('searchAmapWrapper', {
|
|
var map = new AMap.Map('searchAmapWrapper', {
|
|
|
center: this.center,
|
|
center: this.center,
|
|
|
resizeEnable: true,
|
|
resizeEnable: true,
|
|
|
zoom: 15,
|
|
zoom: 15,
|
|
|
- lang: 'en'
|
|
|
|
|
|
|
+ lang: 'en',
|
|
|
|
|
+ layers: [
|
|
|
|
|
+ // 卫星
|
|
|
|
|
+ new AMap.TileLayer.Satellite(),
|
|
|
|
|
+ // 标准图层
|
|
|
|
|
+ new AMap.createDefaultLayer(),
|
|
|
|
|
+ imageLayer
|
|
|
|
|
+ // 路网
|
|
|
|
|
+ // new AMap.TileLayer.RoadNet()
|
|
|
|
|
+ ]
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
AMap.plugin(
|
|
AMap.plugin(
|
|
@@ -153,6 +281,18 @@ export default {
|
|
|
}
|
|
}
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
|
|
+ var wms = new AMap.TileLayer.WMS({
|
|
|
|
|
+ url: process.env.VUE_APP_WMS_RESOURCE_ADDRESS,
|
|
|
|
|
+ blend: true,
|
|
|
|
|
+ tileSize: 256,
|
|
|
|
|
+ params: {
|
|
|
|
|
+ // LAYERS: 'map:shanghai',
|
|
|
|
|
+ // VERSION: '1.1.0'
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ wms.setMap(map);
|
|
|
|
|
+
|
|
|
this.map = map;
|
|
this.map = map;
|
|
|
|
|
|
|
|
this.map.on('click', (e) => {
|
|
this.map.on('click', (e) => {
|
|
@@ -178,72 +318,179 @@ export default {
|
|
|
this.map.plugin(['AMap.DistrictSearch'], () => {});
|
|
this.map.plugin(['AMap.DistrictSearch'], () => {});
|
|
|
},
|
|
},
|
|
|
submitForm() {
|
|
submitForm() {
|
|
|
- this.dialogSubmitLoading = true;
|
|
|
|
|
-
|
|
|
|
|
- return new Promise((resolve) => {
|
|
|
|
|
- if (!this.formatAddress) {
|
|
|
|
|
- this.geocoder.getAddress(
|
|
|
|
|
- this.marker.getPosition(),
|
|
|
|
|
- (status, result) => {
|
|
|
|
|
- if (status === 'complete' && result.regeocode) {
|
|
|
|
|
- const { formattedAddress } = result.regeocode;
|
|
|
|
|
-
|
|
|
|
|
- this.formatAddress = formattedAddress;
|
|
|
|
|
- } else {
|
|
|
|
|
- this.$message.error('根据经纬度查询位置失败');
|
|
|
|
|
- }
|
|
|
|
|
- this.handleSuccess();
|
|
|
|
|
- resolve();
|
|
|
|
|
|
|
+ if (this.locationForm.lat) {
|
|
|
|
|
+ this.dialogSubmitLoading = true;
|
|
|
|
|
+
|
|
|
|
|
+ return new Promise((resolve) => {
|
|
|
|
|
+ if (!this.formatAddress) {
|
|
|
|
|
+ if (this.isAMap) {
|
|
|
|
|
+ this.geocoder.getAddress(
|
|
|
|
|
+ this.marker.getPosition(),
|
|
|
|
|
+ (status, result) => {
|
|
|
|
|
+ if (status === 'complete' && result.regeocode) {
|
|
|
|
|
+ const { addressComponent } = result.regeocode;
|
|
|
|
|
+ this.formatAddress = {
|
|
|
|
|
+ province: addressComponent.province,
|
|
|
|
|
+ city: addressComponent.city,
|
|
|
|
|
+ district: addressComponent.district
|
|
|
|
|
+ };
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$message.error('根据经纬度查询位置失败');
|
|
|
|
|
+ }
|
|
|
|
|
+ this.handleSuccess();
|
|
|
|
|
+ resolve();
|
|
|
|
|
+ }
|
|
|
|
|
+ );
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.geocoder.getLocation(this.marker.getLngLat(), (result) => {
|
|
|
|
|
+ if (result.getStatus() === 0) {
|
|
|
|
|
+ const addressComponent =
|
|
|
|
|
+ result.getAddressComponent().addressComponent;
|
|
|
|
|
+
|
|
|
|
|
+ this.formatAddress = {
|
|
|
|
|
+ province: addressComponent.province,
|
|
|
|
|
+ city: addressComponent.city,
|
|
|
|
|
+ district: addressComponent.county
|
|
|
|
|
+ };
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$message.error('根据经纬度查询位置失败');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.handleSuccess();
|
|
|
|
|
+ resolve();
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
- );
|
|
|
|
|
- } else {
|
|
|
|
|
- this.dialogSubmitLoading = false;
|
|
|
|
|
- resolve();
|
|
|
|
|
- this.handleSuccess();
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.dialogSubmitLoading = false;
|
|
|
|
|
+ resolve();
|
|
|
|
|
+ this.handleSuccess();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
handleSuccess() {
|
|
handleSuccess() {
|
|
|
this.dialogSubmitLoading = false;
|
|
this.dialogSubmitLoading = false;
|
|
|
this.handleClose();
|
|
this.handleClose();
|
|
|
- this.$emit(
|
|
|
|
|
- 'success',
|
|
|
|
|
- assign({ address: this.formatAddress }, this.locationForm)
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ this.$emit('success', assign(this.formatAddress, this.locationForm));
|
|
|
},
|
|
},
|
|
|
onSearchResult({ lng, lat }) {},
|
|
onSearchResult({ lng, lat }) {},
|
|
|
handleClose() {
|
|
handleClose() {
|
|
|
this.$emit('update:visible', false);
|
|
this.$emit('update:visible', false);
|
|
|
},
|
|
},
|
|
|
handleInit() {},
|
|
handleInit() {},
|
|
|
- searchFun() {
|
|
|
|
|
- // console.log(this.marker)
|
|
|
|
|
- if (this.marker) {
|
|
|
|
|
- this.map.remove(this.marker);
|
|
|
|
|
|
|
+ handleSearch() {
|
|
|
|
|
+ if (this.isAMap) {
|
|
|
|
|
+ this.searchFun();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.handleTiandiSearch();
|
|
|
}
|
|
}
|
|
|
- if (!this.searchAddr) {
|
|
|
|
|
- return false;
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ handleTiandiSearch() {
|
|
|
|
|
+ if (this.searchAddr) {
|
|
|
|
|
+ if (this.marker) {
|
|
|
|
|
+ this.map.removeOverLay(this.marker);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!this.searchAddr) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.marker = new T.Marker();
|
|
|
|
|
+ this.geocoder.getPoint(this.searchAddr, (result) => {
|
|
|
|
|
+ if (result.getStatus() === 0) {
|
|
|
|
|
+ const lnglat = result.getLocationPoint();
|
|
|
|
|
+
|
|
|
|
|
+ this.locationForm.lng = lnglat.lng;
|
|
|
|
|
+ this.locationForm.lat = lnglat.lat;
|
|
|
|
|
+
|
|
|
|
|
+ this.marker.setLngLat(lnglat);
|
|
|
|
|
+ this.map.addOverLay(this.marker);
|
|
|
|
|
+ this.map.panTo(lnglat);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$message.error('根据地址查询位置失败');
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
- this.marker = new AMap.Marker();
|
|
|
|
|
- this.geocoder.getLocation(this.searchAddr, (status, result) => {
|
|
|
|
|
- if (status === 'complete' && result.geocodes.length) {
|
|
|
|
|
- const lnglat = result.geocodes[0].location;
|
|
|
|
|
-
|
|
|
|
|
- this.locationForm.lng = lnglat.lng;
|
|
|
|
|
- this.locationForm.lat =
|
|
|
|
|
- result.geocodes[0] && result.geocodes[0].formattedAddress;
|
|
|
|
|
- this.marker.setPosition(lnglat);
|
|
|
|
|
- this.map.add(this.marker);
|
|
|
|
|
- this.map.setFitView(this.marker);
|
|
|
|
|
- } else {
|
|
|
|
|
- this.$message.error('根据地址查询位置失败');
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ searchFun() {
|
|
|
|
|
+ if (this.searchAddr) {
|
|
|
|
|
+ if (this.marker) {
|
|
|
|
|
+ this.map.remove(this.marker);
|
|
|
}
|
|
}
|
|
|
- });
|
|
|
|
|
|
|
+ if (!this.searchAddr) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.marker = new AMap.Marker();
|
|
|
|
|
+ this.geocoder.getLocation(this.searchAddr, (status, result) => {
|
|
|
|
|
+ if (status === 'complete' && result.geocodes.length) {
|
|
|
|
|
+ const lnglat = result.geocodes[0].location;
|
|
|
|
|
+
|
|
|
|
|
+ this.locationForm.lng = lnglat.lng;
|
|
|
|
|
+ this.locationForm.lat = lnglat.lat;
|
|
|
|
|
+
|
|
|
|
|
+ // result.geocodes[0] && result.geocodes[0].formattedAddress;
|
|
|
|
|
+ this.marker.setPosition(lnglat);
|
|
|
|
|
+ this.map.add(this.marker);
|
|
|
|
|
+ this.map.setFitView(this.marker);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$message.error('根据地址查询位置失败');
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
resetForm() {
|
|
resetForm() {
|
|
|
this.locationForm = { lng: '', lat: '' };
|
|
this.locationForm = { lng: '', lat: '' };
|
|
|
this.searchAddr = '';
|
|
this.searchAddr = '';
|
|
|
this.formatAddress = '';
|
|
this.formatAddress = '';
|
|
|
|
|
+ },
|
|
|
|
|
+ locationSearch() {
|
|
|
|
|
+ if (!this.locationForm.lng || !this.locationForm.lat) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (this.marker) {
|
|
|
|
|
+ this.map.remove(this.marker);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.marker = new AMap.Marker();
|
|
|
|
|
+
|
|
|
|
|
+ this.marker.setPosition([this.locationForm.lng, this.locationForm.lat]);
|
|
|
|
|
+ this.map.add(this.marker);
|
|
|
|
|
+ this.map.setFitView(this.marker, true, [300, 300, 300, 300]);
|
|
|
|
|
+ },
|
|
|
|
|
+ locationTiandiSearch() {
|
|
|
|
|
+ if (!this.locationForm.lng || !this.locationForm.lat) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.addMarker(this.locationForm.lng, this.locationForm.lat);
|
|
|
|
|
+ },
|
|
|
|
|
+ handleLocation() {
|
|
|
|
|
+ if (this.isAMap) {
|
|
|
|
|
+ this.locationSearch();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.locationTiandiSearch();
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ addMarker(lng, lat) {
|
|
|
|
|
+ if (this.marker) {
|
|
|
|
|
+ this.map.removeOverLay(this.marker);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const lnglat = new T.LngLat(lng, lat);
|
|
|
|
|
+ this.marker = new T.Marker(lnglat);
|
|
|
|
|
+
|
|
|
|
|
+ //向地图上添加标注
|
|
|
|
|
+ this.map.addOverLay(this.marker);
|
|
|
|
|
+ this.map.panTo(lnglat);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ beforeDestroy() {
|
|
|
|
|
+ if (this.isAMap) {
|
|
|
|
|
+ this.map && this.map.destroy();
|
|
|
|
|
+ this.map = null;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
@@ -386,4 +633,7 @@ export default {
|
|
|
left: 10px;
|
|
left: 10px;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+.plainbutton {
|
|
|
|
|
+ background-color: rgba(255, 255, 255, 0);
|
|
|
|
|
+}
|
|
|
</style>
|
|
</style>
|