Commit cd661f94 by 前端

Merge branch 'change-map' into 'master'

上线合并

See merge request !5
2 parents 4d302b70 47ed710b
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
} }
} }
.amap-info-content { .BMap_bubble_pop {
width: 314px; width: 314px;
height: auto; height: auto;
background: #FFFFFF !important; background: #FFFFFF !important;
...@@ -24,6 +24,12 @@ ...@@ -24,6 +24,12 @@
border-radius: 4px !important; border-radius: 4px !important;
padding: 0 !important; padding: 0 !important;
overflow: hidden!important; overflow: hidden!important;
.BMap_bubble_title{
height: 0!important;
}
.BMap_bubble_top{
height: 0!important;
}
.title { .title {
width: 100%; width: 100%;
font-weight: 600; font-weight: 600;
...@@ -45,7 +51,6 @@ ...@@ -45,7 +51,6 @@
align-items: flex-start; align-items: flex-start;
justify-content: space-between; justify-content: space-between;
padding-bottom: 12px; padding-bottom: 12px;
span { span {
font-size: 14px; font-size: 14px;
color: #999999; color: #999999;
...@@ -57,6 +62,8 @@ ...@@ -57,6 +62,8 @@
.item-text { .item-text {
color: #000000a6; color: #000000a6;
width:200px;
text-align:right;
} }
} }
} }
......
...@@ -33,4 +33,6 @@ html { ...@@ -33,4 +33,6 @@ html {
.message-class{ .message-class{
z-index: 5000 !important; z-index: 5000 !important;
} }
.tangram-suggestion-main {
z-index: 9999 !important; /* 使用 !important 可以确保覆盖其他样式 */
}
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
</div> </div>
</template> </template>
<script> <script>
let map, marker, placeSearch let map, marker, placeSearch
export default { export default {
name: 'map', name: 'map',
......
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(t="undefined"!=typeof globalThis?globalThis:t||self).GlMap=r()}(this,(function(){"use strict";function t(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function r(t,r,e,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void e(t)}c.done?r(u):Promise.resolve(u).then(n,o)}function e(t,r,e){return r&&function(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,i(n.key),n)}}(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function n(){n=function(){return r};var t,r={},e=Object.prototype,o=e.hasOwnProperty,i=Object.defineProperty||function(t,r,e){t[r]=e.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",f=a.toStringTag||"@@toStringTag";function l(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{l({},"")}catch(t){l=function(t,r,e){return t[r]=e}}function s(t,r,e,n){var o=r&&r.prototype instanceof g?r:g,a=Object.create(o.prototype),c=new P(n||[]);return i(a,"_invoke",{value:O(t,e,c)}),a}function h(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}r.wrap=s;var p="suspendedStart",y="suspendedYield",v="executing",d="completed",m={};function g(){}function w(){}function b(){}var L={};l(L,c,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(T([])));E&&E!==e&&o.call(E,c)&&(L=E);var j=b.prototype=g.prototype=Object.create(L);function G(t){["next","throw","return"].forEach((function(r){l(t,r,(function(t){return this._invoke(r,t)}))}))}function S(t,r){function e(n,i,a,c){var u=h(t[n],t,i);if("throw"!==u.type){var f=u.arg,l=f.value;return l&&"object"==typeof l&&o.call(l,"__await")?r.resolve(l.__await).then((function(t){e("next",t,a,c)}),(function(t){e("throw",t,a,c)})):r.resolve(l).then((function(t){f.value=t,a(f)}),(function(t){return e("throw",t,a,c)}))}c(u.arg)}var n;i(this,"_invoke",{value:function(t,o){function i(){return new r((function(r,n){e(t,o,r,n)}))}return n=n?n.then(i,i):i()}})}function O(r,e,n){var o=p;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===d){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=_(c,n);if(u){if(u===m)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var f=h(r,e,n);if("normal"===f.type){if(o=n.done?d:y,f.arg===m)continue;return{value:f.arg,done:n.done}}"throw"===f.type&&(o=d,n.method="throw",n.arg=f.arg)}}}function _(r,e){var n=e.method,o=r.iterator[n];if(o===t)return e.delegate=null,"throw"===n&&r.iterator.return&&(e.method="return",e.arg=t,_(r,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=h(o,r.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,m;var a=i.arg;return a?a.done?(e[r.resultName]=a.value,e.next=r.nextLoc,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,m):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,m)}function k(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function A(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function T(r){if(r||""===r){var e=r[c];if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var n=-1,i=function e(){for(;++n<r.length;)if(o.call(r,n))return e.value=r[n],e.done=!1,e;return e.value=t,e.done=!0,e};return i.next=i}}throw new TypeError(typeof r+" is not iterable")}return w.prototype=b,i(j,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:w,configurable:!0}),w.displayName=l(b,f,"GeneratorFunction"),r.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===w||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,l(t,f,"GeneratorFunction")),t.prototype=Object.create(j),t},r.awrap=function(t){return{__await:t}},G(S.prototype),l(S.prototype,u,(function(){return this})),r.AsyncIterator=S,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new S(s(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},G(j),l(j,f,"Generator"),l(j,c,(function(){return this})),l(j,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=T,P.prototype={constructor:P,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(A),!r)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var e=this;function n(n,o){return c.type="throw",c.arg=r,e.next=n,o&&(e.method="next",e.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),f=o.call(a,"finallyLoc");if(u&&f){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!f)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),m},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),A(e),m}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;A(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(r,e,n){return this.delegate={iterator:T(r),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=t),m}},r}function o(r){return function(r){if(Array.isArray(r))return t(r)}(r)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(r)||function(r,e){if(r){if("string"==typeof r)return t(r,e);var n={}.toString.call(r).slice(8,-1);return"Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n?Array.from(r):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(r,e):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t){var r=function(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,r);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof r?r:r+""}function a(t){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(t)}var c={1:"develop",2:"test",3:"production",4:"beta"},u=function(){return e((function t(){var e=this;!function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,t);var o,i,u={env:3,version:3},f=arguments[0];if(arguments.length>1&&(u="object"==a(arguments[0])?arguments[0]:u,f=arguments[1],null!==(o=u)&&void 0!==o&&o.env||(u.env=3),null!==(i=u)&&void 0!==i&&i.version||(u.version=3)),"undefined"!=typeof window){var l=function(){var t,o=(t=n().mark((function t(){var r,o,i,a;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,fetch("https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=map-api-js&env=".concat(c[u.env]));case 3:return r=t.sent,t.next=6,r.json();case 6:o=t.sent,i=Array.from(document.head.getElementsByTagName("script")).some((function(t){return t.src===o.apiUrl})),i?f&&"function"==typeof f&&(e.GLMap=new window.$GlMapApi(u,(function(){f&&"function"==typeof f&&f(e)}))):((a=document.createElement("script")).src=o.apiUrl,document.head.appendChild(a),a.onload=function(){e.GLMap=new window.$GlMapApi(u,(function(){f&&"function"==typeof f&&f(e)}))}),t.next=14;break;case 11:t.prev=11,t.t0=t.catch(0),console.error("Failed to fetch configuration:",t.t0);case 14:case"end":return t.stop()}}),t,null,[[0,11]])})),function(){var e=this,n=arguments;return new Promise((function(o,i){var a=t.apply(e,n);function c(t){r(a,o,i,c,u,"next",t)}function u(t){r(a,o,i,c,u,"throw",t)}c(void 0)}))});return function(){return o.apply(this,arguments)}}();l()}}),[{key:"invoke",value:function(t){var r,e=Array.prototype.slice.call(arguments,1);return(r=this.GLMap)[t].apply(r,o(e))}},{key:"map",get:function(){return this.GLMap._BMAP}},{key:"mapGL",get:function(){return this.GLMap._BMapGL}}])}();return u}));
<template> <template>
<div class="map-container"> <div class="map-container">
<div class="map-box"> <div class="map-box">
<el-select v-model="input" class="map-input" filterable remote reserve-keyword placeholder="请输入" :remote-method="remoteMethod" @change="handleChangeAdr" :loading="loading"> <!-- <el-select v-model="input" class="map-input" filterable remote reserve-keyword placeholder="请输入" :remote-method="remoteMethod" @change="handleChangeAdr" :loading="loading">
<el-option v-for="item in adrList" :key="item.id" :label="item.address" :value="item.id"></el-option> <el-option v-for="item in adrList" :key="item.id" :label="item.address" :value="item.id"></el-option>
</el-select> </el-select> -->
<el-input placeholder="请输入搜索地址" id="tipInput" size="small" maxlength="200" v-model="input" class="map-input">
<template slot="prepend">搜索</template>
<!-- <el-button slot="append" icon="el-icon-search" @click="search"></el-button> -->
</el-input>
<div class="icon-card"> <div class="icon-card">
<div :class="['icon-item', ctr.checked ? 'active' : '']" v-for="(ctr, index) in controlList" @click="controlHandle(index, ctr.icon)" :key="index"> <div :class="['icon-item', ctr.checked ? 'active' : '']" v-for="(ctr, index) in controlList" @click="controlHandle(index, ctr.icon)" :key="index">
<img class="control-icon" :src="require(`@/assets/${ctr.icon}.png`)" /> <img class="control-icon" :src="require(`@/assets/${ctr.icon}.png`)" />
...@@ -19,23 +23,24 @@ ...@@ -19,23 +23,24 @@
<script> <script>
let contextMenu let contextMenu
import AMapLoader from '@amap/amap-jsapi-loader' //按需引入依赖 // import AMapLoader from '@amap/amap-jsapi-loader' //按需引入依赖
import GLMapSdk from '@/utils/glsk-map-sdk'
export default { export default {
data() { data() {
return { return {
input: [], input: '',
adrList: [], autoCenterMarker: null,
placeSearch: '', placeSearch: '',
map: '', BMap: '',
address: '', address: '',
markerData: '', markerData: '',
contextMenuPositon: '', //右键菜单位置 contextMenuPositon: '', //右键菜单位置
controlList: [ controlList: [
{ // {
icon: 'moon', // icon: 'moon',
name: '卫星', // name: '卫星',
checked: false // checked: false
}, // },
{ {
icon: 'ranging', icon: 'ranging',
name: '测距', name: '测距',
...@@ -63,55 +68,109 @@ export default { ...@@ -63,55 +68,109 @@ export default {
mounted() { mounted() {
this.queryData = this.$route.query this.queryData = this.$route.query
this.initMap() this.initBMap()
// this.initMap()
}, },
methods: { methods: {
initMap() { initBMap() {
AMapLoader.load({ new GLMapSdk(
key: '44cc16e43ad7ed3358df507bd0618181', // 申请好的Web端开发者Key,首次调用 load 时必填 {
version: '2.0', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15 env: 3,
plugins: [ version: 1
//需要使用的插件 },
'AMap.ToolBar', async mapapi => {
'AMap.Scale', this.BMap = mapapi
'AMap.Geolocation', let map = await mapapi.invoke('Map', 'container')
'AMap.PlaceSearch', map.enableScrollWheelZoom() //启用滚轮放大缩小
'AMap.AutoComplete', map.enableAutoResize() //启用自动适应容器尺寸变化
'AMap.Geocoder', mapapi.invoke('centerAndZoom', mapapi.invoke('Point', 116.404, 39.915), 13)
'AMap.CitySearch', mapapi.invoke('LocalCity', res => {
'AMap.RangingTool' mapapi.invoke('panTo', res.center)
],
resizeEnable: true
}) })
.then(AMap => { // 添加比例尺
const that = this mapapi.invoke('ScaleControl')
that.AMap = AMap // 距离测量
that.map = new AMap.Map('container', { mapapi.invoke('DistanceTool', map)
//设置地图容器id this.bindSearch()
viewMode: '3D', //是否为3D地图模式 this.getParkingSpaceList()
zoom: 12, this.getContextMenu(mapapi)
autoFitView: true, }
resizeEnable: true, )
cursor: 'move' //初始化地图级别 },
bindSearch() {
let self = this,
url = require('@/assets/images/auto-center-marker.gif'),
size = this.BMap.invoke('Size', 24, 24)
self.auto = this.BMap.invoke('Autocomplete', {
input: 'tipInput'
}) })
// contextMenu && contextMenu.close() this.BMap.invoke('autocompleteShow')
//构造地点查询类 this.BMap.invoke('autocompleteAddEventListener', 'onconfirm', e => {
that.placeSearch = new AMap.PlaceSearch({ let location = e.item.value.location
pageSize: 8, // 单页显示结果条数 this.BMap.invoke('panTo', location, true)
pageIndex: 1, // 页码 self.autoCenterMarker = this.BMap.invoke('Marker', location, {
citylimit: false, //是否强制限制在设置的城市内搜索 icon: this.BMap.invoke('Icon', url, size)
// panel: "panel", // 结果列表将在此容器中进行展示。 })
autoFitView: true, // 是否自动调整地图视野使绘制的 Marker点都处于视口的可见范围 this.BMap.invoke('addOverlay', self.autoCenterMarker)
renderStyle: 'default' this.BMap.invoke('markerAddEventListener', 'rightclick', e => {
var contextMenu = this.BMap.invoke('ContextMenu')
contextMenu.addItem(
this.BMap.invoke('MenuItem', '新增车位标记', function () {
// that.addPoiMarker(_position);
self.addMarkerMenu()
}) })
//获取所有的点标记 )
that.getParkingSpaceList() this.BMap.invoke('addContextMenu', contextMenu)
that.getContextMenu(that.map) self.contextMenuPositon = e.latLng //右键菜单位置
}) })
.catch(e => {
console.log(e)
}) })
}, },
// initMap() {
// AMapLoader.load({
// key: '44cc16e43ad7ed3358df507bd0618181', // 申请好的Web端开发者Key,首次调用 load 时必填
// version: '2.0', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
// plugins: [
// //需要使用的插件
// 'AMap.ToolBar',
// 'AMap.Scale',
// 'AMap.Geolocation',
// 'AMap.PlaceSearch',
// 'AMap.AutoComplete',
// 'AMap.Geocoder',
// 'AMap.CitySearch',
// 'AMap.RangingTool'
// ],
// resizeEnable: true
// })
// .then(AMap => {
// const that = this;
// that.AMap = AMap
// that.map = new AMap.Map('container', {
// //设置地图容器id
// viewMode: '3D', //是否为3D地图模式
// zoom: 12,
// autoFitView: true,
// resizeEnable: true,
// cursor: 'move' //初始化地图级别
// })
// // contextMenu && contextMenu.close()
// //构造地点查询类
// that.placeSearch = new AMap.PlaceSearch({
// pageSize: 8, // 单页显示结果条数
// pageIndex: 1, // 页码
// citylimit: false, //是否强制限制在设置的城市内搜索
// // panel: "panel", // 结果列表将在此容器中进行展示。
// autoFitView: true, // 是否自动调整地图视野使绘制的 Marker点都处于视口的可见范围
// renderStyle: 'default'
// })
// //获取所有的点标记
// that.getParkingSpaceList()
// that.getContextMenu(that.map)
// })
// .catch(e => {
// console.log(e)
// })
// },
getParkingSpaceList() { getParkingSpaceList() {
let params = { let params = {
pageSize: 1000, pageSize: 1000,
...@@ -133,19 +192,29 @@ export default { ...@@ -133,19 +192,29 @@ export default {
delFlag = 0 delFlag = 0
icon = 'default' icon = 'default'
} }
marker = new AMap.Marker({ // marker = new AMap.Marker({
icon: require(`@/assets/${icon}.png`), // icon: require(`@/assets/${icon}.png`),
position: [item.parkingAddressLng, item.parkingAddressLat], // position: [item.parkingAddressLng, item.parkingAddressLat],
anchor: 'bottom', // anchor: 'bottom',
clickable: true, // clickable: true,
extData: { // extData: {
// id: item.id,
// parkingNumber: item.parkingNumber
// },
// style: { width: '48px', height: '48px' }
// })
// marker.setMap(map)
let url = require(`@/assets/${icon}.png`),
size = this.BMap.invoke('Size', 24, 24)
let lnglatXY = this.BMap.invoke('Point', item.parkingAddressLng, item.parkingAddressLat)
marker = this.BMap.invoke('Marker', lnglatXY, {
icon: this.BMap.invoke('Icon', url, size)
})
marker.extData = {
id: item.id, id: item.id,
parkingNumber: item.parkingNumber parkingNumber: item.parkingNumber
}, }
style: { width: '48px', height: '48px' } this.BMap.invoke('addOverlay', marker)
})
marker.setMap(map)
this.initMarket(marker, delFlag) this.initMarket(marker, delFlag)
} }
} }
...@@ -153,15 +222,14 @@ export default { ...@@ -153,15 +222,14 @@ export default {
}, },
//是否有删除功能 1=》可以 //是否有删除功能 1=》可以
initMarket(marker, delFlag) { initMarket(marker, delFlag) {
let { map, AMap } = this, let that = this,
that = this,
infoWindowContent, infoWindowContent,
infoWindow infoWindow
if (marker) { if (marker) {
marker.on('click', function (e) { this.BMap.invoke('markerAddEventListener', 'click', e => {
that.markerData = marker.getExtData() that.markerData = e.srcElement.extData
that.contextMenuPositon = e.lnglat that.contextMenuPositon = e.latLng
that.getAddress() that.getAddress()
infoWindowContent = ` infoWindowContent = `
<div class="title">车位标记</div> <div class="title">车位标记</div>
...@@ -192,10 +260,9 @@ export default { ...@@ -192,10 +260,9 @@ export default {
</div>` </div>`
} }
infoWindow = new AMap.InfoWindow({ infoWindow = this.BMap.invoke('InfoWindow', infoWindowContent)
content: infoWindowContent marker.openinfoWindow = infoWindow
}) this.BMap.invoke('mapOpenInfoWindow', infoWindow, e.target.getPosition())
infoWindow.open(map, that.contextMenuPositon)
that.bindEvent(infoWindow, marker) that.bindEvent(infoWindow, marker)
}) })
} }
...@@ -214,18 +281,35 @@ export default { ...@@ -214,18 +281,35 @@ export default {
getContextMenu(manipulator, isOpen) { getContextMenu(manipulator, isOpen) {
let that = this, let that = this,
isOk = isOpen ? (isOpen == 1 ? true : false) : !this.queryData.parkingAddressFlag isOk = isOpen ? (isOpen == 1 ? true : false) : !this.queryData.parkingAddressFlag
this.initContent() var contextMenu = this.BMap.invoke('ContextMenu')
//地图绑定鼠标右击事件——弹出右键菜单 contextMenu.addItem(
manipulator.on('rightclick', function (e) { this.BMap.invoke('MenuItem', '新增车位标记', function () {
contextMenu.close() that.addMarkerMenu()
this.BMap.invoke('removeContextMenu', contextMenu)
})
)
this.BMap.invoke('mapAddEventListener', 'rightclick', e => {
if (isOk) { if (isOk) {
contextMenu.open(that.map, e.lnglat) this.BMap.invoke('addContextMenu', contextMenu)
} else {
this.BMap.invoke('removeContextMenu', contextMenu)
} }
that.contextMenuPositon = e.lnglat //右键菜单位置 that.contextMenuPositon = e.latlng //右键菜单位置
that.getAddress() that.getAddress()
that.marketEvent() // that.marketEvent()
}) })
// // //地图绑定鼠标右击事件——弹出右键菜单
// manipulator.on('rightclick', function (e) {
// contextMenu.close()
// if (isOk) {
// contextMenu.open(that.map, e.lnglat)
// }
// that.contextMenuPositon = e.lnglat //右键菜单位置
// that.getAddress()
// that.marketEvent()
// })
}, },
marketEvent() { marketEvent() {
let marker = document.getElementById('marker') let marker = document.getElementById('marker')
...@@ -236,11 +320,11 @@ export default { ...@@ -236,11 +320,11 @@ export default {
marker = null marker = null
}, },
addMarkerMenu() { addMarkerMenu() {
let { map, AMap, queryData, contextMenuPositon, address } = this, let { queryData, contextMenuPositon, address } = this,
infoWindow, infoWindow,
infoWindowContent infoWindowContent;
infoWindowContent = `<div class="custom-infowindow input-card"> infoWindowContent = `<div class="custom-infoWindow input-card">
<div class="title">新增标记</div> <div class="title">新增标记</div>
<div class="custom-item"> <div class="custom-item">
<div class="item"> <div class="item">
...@@ -268,11 +352,8 @@ export default { ...@@ -268,11 +352,8 @@ export default {
</div>` </div>`
infoWindow = new AMap.InfoWindow({ infoWindow = this.BMap.invoke('InfoWindow', infoWindowContent)
content: infoWindowContent this.BMap.invoke('mapOpenInfoWindow', infoWindow, contextMenuPositon)
})
contextMenu.close()
infoWindow.open(map, contextMenuPositon)
this.bindEvent(infoWindow) this.bindEvent(infoWindow)
}, },
bindEvent(infoWindow, marker) { bindEvent(infoWindow, marker) {
...@@ -297,8 +378,6 @@ export default { ...@@ -297,8 +378,6 @@ export default {
}, },
confirm(infoWindow) { confirm(infoWindow) {
let { let {
AMap,
map,
queryData, queryData,
contextMenuPositon: { lng, lat } contextMenuPositon: { lng, lat }
} = this, } = this,
...@@ -311,28 +390,25 @@ export default { ...@@ -311,28 +390,25 @@ export default {
} }
this.$apis.parkingSpace.addFlagparkingSpace(params).then(res => { this.$apis.parkingSpace.addFlagparkingSpace(params).then(res => {
if (res.code == 0) { if (res.code == 0) {
marker = new AMap.Marker({ let lnglatXY = this.BMap.invoke('Point', lng, lat),
icon: require('@/assets/select.png'), url = require('@/assets/select.png'),
position: [lng, lat], size = this.BMap.invoke('Size', 48, 48)
anchor: 'bottom', marker = this.BMap.invoke('Marker', lnglatXY, {
extData: { icon: this.BMap.invoke('Icon', url, size)
id: queryData.id,
parkingNumber: queryData.parkingNumber
},
style: { width: '48px', height: '48px' }
}) })
marker.setMap(map) // marker.setMap(map)
this.BMap.invoke('addOverlay', marker)
this.initMarket(marker, 1) this.initMarket(marker, 1)
infoWindow.close() this.BMap.invoke('mapCloseInfoWindow', infoWindow)
this.$message.success('车位标记成功') this.$message.success('车位标记成功')
} else { } else {
this.$message.error(res.message) this.$message.error(res.message)
} }
this.getContextMenu(map, 2) this.getContextMenu(this.BMap, 2)
}) })
}, },
cancel(infoWindow) { cancel(infoWindow) {
infoWindow.close() this.BMap.invoke('mapCloseInfoWindow', infoWindow)
}, },
del(infoWindow, marker) { del(infoWindow, marker) {
let { markerData } = this, let { markerData } = this,
...@@ -345,24 +421,24 @@ export default { ...@@ -345,24 +421,24 @@ export default {
this.$apis.parkingSpace.deleteFlagparkingSpaceparams(params).then(res => { this.$apis.parkingSpace.deleteFlagparkingSpaceparams(params).then(res => {
if (res) { if (res) {
marker.hide() marker.hide()
infoWindow.close() this.BMap.invoke('mapCloseInfoWindow', infoWindow)
this.$message.success('删除成功') this.$message.success('删除成功')
this.getContextMenu(this.map, 1) this.getContextMenu(this.BMap, 1)
}
})
},
remoteMethod(query) {
if (query == '') {
return true
}
let _this = this
_this.placeSearch.search(query, function (status, result) {
if (status === 'complete' && result.poiList.pois.length) {
_this.adrList = result.poiList.pois
// console.log(_this.adrList)
} }
}) })
}, },
// remoteMethod(query) {
// if (query == '') {
// return true
// }
// let _this = this
// _this.placeSearch.search(query, function (status, result) {
// if (status === 'complete' && result.poiList.pois.length) {
// _this.adrList = result.poiList.pois
// // console.log(_this.adrList)
// }
// })
// },
getAddress(e) { getAddress(e) {
let { map, AMap, contextMenuPositon } = this, let { map, AMap, contextMenuPositon } = this,
that = this, that = this,
...@@ -386,25 +462,32 @@ export default { ...@@ -386,25 +462,32 @@ export default {
// this.shroudContextMenu(e.location) // this.shroudContextMenu(e.location)
} else { } else {
//获取地址 //获取地址
geocoder = new AMap.Geocoder({ // geocoder = new AMap.Geocoder({
radius: 500 //范围,默认:500 // radius: 500 //范围,默认:500
}) // })
geocoder.getAddress([contextMenuPositon.lng, contextMenuPositon.lat], function (status, result) { // geocoder.getAddress([contextMenuPositon.lng, contextMenuPositon.lat], function (status, result) {
if (status === 'complete' && result.regeocode) { // if (status === 'complete' && result.regeocode) {
that.address = result.regeocode.formattedAddress // that.address = result.regeocode.formattedAddress
// console.log(result.regeocode,that.address) // // console.log(result.regeocode,that.address)
// }
// })
// const lnglatXY = this.BMap.invoke('panTo',contextMenuPositon.lng, contextMenuPositon.lat)
geocoder = this.BMap.invoke('Geocoder')
geocoder.getLocation(contextMenuPositon, result => {
if (result) {
that.address = result.address
} }
}) })
} }
}, },
handleChangeAdr(val) { // handleChangeAdr(val) {
if (val) { // if (val) {
var location = this.adrList.find(item => item.id == val) // var location = this.adrList.find(item => item.id == val)
this.getAddress(location) // this.getAddress(location)
this.input = '' // this.input = ''
this.adrList = [] // this.adrList = []
} // }
}, // },
controlHandle(index, event) { controlHandle(index, event) {
this[event + 'Handle'](index) this[event + 'Handle'](index)
...@@ -412,57 +495,46 @@ export default { ...@@ -412,57 +495,46 @@ export default {
// this.controlList[index].checked=! this.controlList[index].checked // this.controlList[index].checked=! this.controlList[index].checked
}, },
//卫星 //卫星
moonHandle(index) { // moonHandle(index) {
let { AMap, map, activeIndex } = this // let { activeIndex } = this
if (activeIndex === index) { // console.log(activeIndex, index)
new AMap.TileLayer({ // if (activeIndex === index) {
map // this.BMap.invoke('setMapStyleNormal')
}) // // 构造官方卫星、路网图层
return // } else {
} // this.BMap.invoke('setMapStyleSatellite')
new AMap.TileLayer.Satellite({ // // 地图上设置图层
map // }
}) // },
},
//测距 //测距
rangingHandle(index) { rangingHandle(index) {
let { AMap, map, activeIndex } = this, let { activeIndex } = this
ruler
ruler = new AMap.RangingTool(map)
if (activeIndex === index) { if (activeIndex === index) {
ruler.turnOff() this.BMap.invoke('distanceToolclose') // 关闭测距
return return
} }
ruler.turnOn() this.BMap.invoke('distanceToolOpen') // 开启测距
}, },
//定位 //定位
locationHandle() { locationHandle() {
let { AMap, map } = this, this.BMap.invoke('LocalCity', res => {
geolocation console.log('IP', res)
geolocation = new AMap.Geolocation({ this.BMap.invoke('panTo', res.center)
enableHighAccuracy: true, //是否使用高精度定位,默认:true
timeout: 10000, //超过10秒后停止定位,默认:5s
position: 'RB', //定位按钮的停靠位置
offset: [10, 20], //定位按钮与设置的停靠位置的偏移量,默认:[10, 20]
zoomToAccuracy: true,
showButton: true //定位成功后是否自动调整地图视野到定位点
}) })
map.addControl(geolocation)
}, },
//放大 //放大
magnifyHandle() { magnifyHandle() {
let { map } = this this.BMap.invoke('zoomIn')
map.zoomIn()
}, },
//缩小 //缩小
reduceHandle() { reduceHandle() {
let { map } = this this.BMap.invoke('zoomOut')
map.zoomOut()
} }
}, },
beforeDestroy() { beforeDestroy() {
contextMenu && contextMenu.close() // contextMenu && contextMenu.close()
this.map.destroy() // this.map.destroy()
} }
} }
</script> </script>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!