Commit 1fdadbf4 by 张杰

修复地图报错

1 parent 5d71032c
import 'font-awesome/css/font-awesome.min.css' import 'font-awesome/css/font-awesome.min.css'
import './assets/scss/element-variables.scss' import '@/assets/scss/element-variables.scss'
//import Vue from 'vue' //import Vue from 'vue'
import ElementUI from 'element-ui'; import ElementUI from 'element-ui';
import 'animate.css/animate.min.css' import 'animate.css/animate.min.css'
import './assets/scss/style.scss' import '@/assets/scss/style.scss'
import 'element-ui/lib/theme-chalk/index.css'; import 'element-ui/lib/theme-chalk/index.css';
import './assets/spritesmith-generated/sprite.css' import '@/assets/spritesmith-generated/sprite.css'
import Router from 'vue-router' import Router from 'vue-router'
import routes from './router' import routes from '@/router'
import './core/public-path'; import '@/core/public-path';
import actions from './core/actions'; import actions from '@/core/actions';
import vLayout from 'pages/Layout.vue' import vLayout from '@/pages/Layout.vue'
import vFullLayout from 'pages/FullWidthLayout.vue' import vFullLayout from '@/pages/FullWidthLayout.vue'
import store from './vuex/store.js' import store from '@/vuex/store.js'
import App from './App.vue' import App from '@/App.vue'
import Vue from 'vue' import Vue from 'vue'
......
...@@ -52,7 +52,7 @@ import remoteLoad from "utils/remoteLoad.js"; ...@@ -52,7 +52,7 @@ import remoteLoad from "utils/remoteLoad.js";
import mapService from "utils/mapService.js"; import mapService from "utils/mapService.js";
import FenceMapControll from "./FenceMapControll.vue"; import FenceMapControll from "./FenceMapControll.vue";
const BUSINESS_SERVICE = services.business; const BUSINESS_SERVICE = services.business;
const mapMenu = '' const mapMenu = "";
import { CONSTANT } from "../../constant"; import { CONSTANT } from "../../constant";
export default { export default {
props: ["fenceMapModalVisible", "init", "readonlyStatus"], props: ["fenceMapModalVisible", "init", "readonlyStatus"],
...@@ -151,42 +151,38 @@ export default { ...@@ -151,42 +151,38 @@ export default {
}, },
bindSearch() { bindSearch() {
const self = this; const self = this;
this.auto = new AMap.Autocomplete({ AMap.plugin("AMap.Autocomplete", function () {
input: "fenceMapSearch", self.auto = new AMap.Autocomplete({
}); input: "fenceMapSearch",
});
this.autoCenterMarker = new AMap.Marker({ self.autoCenterMarker = new AMap.Marker({
icon: require("images/auto-center-marker.gif"), icon: require("images/auto-center-marker.gif"),
map: this.mapObj, map: self.mapObj,
offset: new AMap.Pixel(-12, -12), offset: new AMap.Pixel(-12, -12),
visible: false, visible: false,
}); });
this.autoCenterMarker.on("rightclick", (e) => { self.autoCenterMarker.on("rightclick", (e) => {
if (self.mapObj.getAllOverlays("circle").length) { if (self.mapObj.getAllOverlays("circle").length) {
window.mapMenu.contextMenu.open(self.mapObj, e.lnglat); window.mapMenu.contextMenu.open(self.mapObj, e.lnglat);
self.contextMenuPositon = e.lnglat; //右键菜单位置 self.contextMenuPositon = e.lnglat; //右键菜单位置
} }
}); });
AMap.event.addListener(this.auto, "select", (e) => { AMap.event.addListener(self.auto, "select", (e) => {
if (e.poi && e.poi.location) { if (e.poi && e.poi.location) {
this.mapObj.setCenter(e.poi.location); self.mapObj.setCenter(e.poi.location);
this.autoCenterMarker.setPosition(e.poi.location); self.autoCenterMarker.setPosition(e.poi.location);
/*for(var i = 0, l = this.polygons.length; i < l; i++) { /*for(var i = 0, l = this.polygons.length; i < l; i++) {
this.polygons[i].setMap(null); this.polygons[i].setMap(null);
}*/ }*/
this.autoCenterMarker.show(); self.autoCenterMarker.show();
this.mapObj.add(this.autoCenterMarker); self.mapObj.add(self.autoCenterMarker);
}
//this.form.lng = e.poi.location.lng;
//this.form.lat = e.poi.location.lat;
//this.contextMenuPositon = e.poi.location
//window.mapMenu.contextMenu.open(this.mapObj, mapService.getLngLat(e.poi.location.lng, e.poi.location.lat))
}
this.mapObj.setZoom(14); self.mapObj.setZoom(14);
});
}); });
}, },
bindContextMenu() { bindContextMenu() {
...@@ -195,16 +191,18 @@ export default { ...@@ -195,16 +191,18 @@ export default {
console.log(mapMenu); console.log(mapMenu);
function ContextMenu(map) { function ContextMenu(map) {
var me = this; var me = this;
var content = []; var content = [];
this.contextMenuPositon = null; this.contextMenuPositon = null;
content.push('<div class="context_menu" >') content.push('<div class="context_menu" >');
content.push('<p onclick="mapMenu.moveCenter()"><span>设置围栏中心</span></p>') content.push(
content.push('</div>') '<p onclick="mapMenu.moveCenter()"><span>设置围栏中心</span></p>'
);
content.push("</div>");
this.contextMenu = new AMap.ContextMenu({ this.contextMenu = new AMap.ContextMenu({
isCustom: true, isCustom: true,
content: content.join(''), content: content.join(""),
}); });
map.on("rightclick", (e) => { map.on("rightclick", (e) => {
if (self.mapObj.getAllOverlays("circle").length) { if (self.mapObj.getAllOverlays("circle").length) {
...@@ -215,7 +213,7 @@ export default { ...@@ -215,7 +213,7 @@ export default {
} }
ContextMenu.prototype.moveCenter = function () { ContextMenu.prototype.moveCenter = function () {
console.log('6666666666') console.log("6666666666");
self.moveCenter(); self.moveCenter();
this.contextMenu.close(); this.contextMenu.close();
}; };
......
...@@ -194,7 +194,7 @@ const monitor = { ...@@ -194,7 +194,7 @@ const monitor = {
}); });
//mapService.setFitView(MAP); mapService.setFitView(MAP);
this.allData = this.allData.concat(data); this.allData = this.allData.concat(data);
EventBus.$emit('uiMap.monitor.drawDone'); EventBus.$emit('uiMap.monitor.drawDone');
if(this.isCompare){ if(this.isCompare){
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!