Commit 283c59db by 胡悦

更换百度地图

1 parent cb1b5a1b
......@@ -610,8 +610,8 @@
</div>
<script src="https://img02.glsx.com.cn/layui/layui.js"></script>
<script src="/js/load.js"></script>
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=44cc16e43ad7ed3358df507bd0618181&plugin=AMap.Geocoder&plugin=AMap.PlaceSearch&plugin=AMap.Geolocation"></script>
<script src="/js/validator.js"></script>
<!-- <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=44cc16e43ad7ed3358df507bd0618181&plugin=AMap.Geocoder&plugin=AMap.PlaceSearch&plugin=AMap.Geolocation"></script> -->
<script src="/js/validator.js"></script>
<script>
layui.use(['gtree', 'request', 'helper', 'layer', 'laydate', 'element', 'xmSelect', 'laytpl', 'validator', 'util', 'common'], function () {
var com = layui.common
......@@ -1143,20 +1143,21 @@
body.find('#mapBtn').click()
var res = helper.store.get('merchantMapObj')
if (res.lat && res.merchantAddress) {
merchantForm.lat = res.lat
merchantForm.lng = res.lng
merchantForm.lat = res.lat.toFixed(6)
merchantForm.lng = res.lng.toFixed(6)
merchantForm.merchantAddress = res.merchantAddress
var fullAddress = ''
var provincecode = ''
if (res.geocoderAddress) {
fullAddress = res.geocoderAddress.addressComponent
provincecode = res.geocoderAddress.adcode
addressData.fullAddress = res.geocoderAddress.addressComponent
addressData.provincecode = res.geocoderAddress.adcode
} else {
fullAddress = addressData.fullAddress
provincecode = addressData.provincecode
}
console.log(res.geocoderAddress, 'res.geocoderAddress')
// if (res.geocoderAddress) {
// fullAddress = res.address
// provincecode = res.content.address_detail.adcode
// addressData.fullAddress = res.geocoderAddress.addressComponent
// addressData.provincecode = res.geocoderAddress.adcode
// } else {
fullAddress = res.geocoderAddress.addressComponents
provincecode = res.geocoderAddress.content.address_detail.adcode
// }
// 获取省市
var provinceIdx = ''
var cityIdx = ''
......@@ -1190,9 +1191,9 @@
$('#addrEl').val(merchantForm.merchantAddress)
var province = provinceInfoList.find(item => item.name == provinceIdx)
$('#startp').val(province.name)
cityInfo = province.districtList
cityInfo = province.districts
merchantForm.provinceName = province.name
merchantForm.provinceCode = province.adcode
merchantForm.provinceCode = province.code
com.getSelect({
id: 'startc',
value: 'name',
......@@ -1205,13 +1206,13 @@
if (value) {
merchantForm.cityName = value
var cityChange = cityInfo.find(item => item.name == value)
merchantForm.cityCode = cityChange.adcode
merchantForm.cityCode = cityChange.code
$('#addrEl').val('')
}
}
})
var city = cityInfo.find(item => item.name == cityIdx)
merchantForm.cityCode = city.adcode
merchantForm.cityCode = city.code
merchantForm.cityName = city.name
$('#startc').val(merchantForm.cityName)
form.render('select')
......@@ -1803,29 +1804,25 @@ function uniqueNodes(nodes) {
// 省市区
function getProvinceList() {
// var ajax = layui.$.ajax
// ajax({
// // url: 'https://oss-config.test.glsx.com.cn/mock/5be17454f31545347559d499/config/glsx-oss-account-config',
// url: 'http://oss-config.dev.glsx.com.cn/mock/617ba1df1072f92988f05a14/account/provinceList',
// async: false,
// success: function (res) {
// console.log(res)
// provinceInfoList = res.provinceInfoList
// }
// })
var map = new AMap.Map('district', {
resizeEnable: true
var params = {
keyword: '中国',
extensions_code: 1,
sub_admin: 2
}
let data = ''
for (let key in params) {
data += '&' + key + '=' + params[key]
}
let path = 'http://eshield.dev.glsx.com.cn/nesi/apiRegion/search?'
path = path + data
const pro = fetch(path).then(res => {
console.log(res, 'res')
return res.json()
})
AMap.plugin(['AMap.DistrictSearch'], () => {
var opts = {
subdistrict: 2, //返回下一级行政区
level: 'city', //查询的范围
showbiz: true //查询行政级别为 市
}
var districtSearch = new AMap.DistrictSearch(opts)
districtSearch.search('中国', (status, result) => {
provinceInfoList = result.districtList[0].districtList
com.getSelect({
pro.then(r => {
console.log(JSON.parse(r.data), 'r')
provinceInfoList = JSON.parse(r.data).districts[0].districts
com.getSelect({
id: 'startp',
name: 'provinceName',
url: '/area/list',
......@@ -1839,8 +1836,8 @@ function uniqueNodes(nodes) {
if (value) {
// var province = provinceInfoList.find(item => item.provinceId == value)
var province = provinceInfoList.find(item => item.name == value)
cityInfo = province.districtList
merchantForm.provinceCode = province.adcode
cityInfo = province.districts
merchantForm.provinceCode = province.code
merchantForm.provinceName = province.name
$('#addrEl').val('')
} else {
......@@ -1863,7 +1860,7 @@ function uniqueNodes(nodes) {
if (value) {
// var city = cityInfo.find(item => item.cityId == value)
var city = cityInfo.find(item => item.name == value)
merchantForm.cityCode = city.adcode
merchantForm.cityCode = city.code
merchantForm.cityName = city.name
} else {
merchantForm.cityCode = ''
......@@ -1873,8 +1870,79 @@ function uniqueNodes(nodes) {
})
}
})
})
})
// var ajax = layui.$.ajax
// ajax({
// // url: 'https://oss-config.test.glsx.com.cn/mock/5be17454f31545347559d499/config/glsx-oss-account-config',
// url: 'http://oss-config.dev.glsx.com.cn/mock/617ba1df1072f92988f05a14/account/provinceList',
// async: false,
// success: function (res) {
// console.log(res)
// provinceInfoList = res.provinceInfoList
// }
// })
// var map = new AMap.Map('district', {
// resizeEnable: true
// })
// AMap.plugin(['AMap.DistrictSearch'], () => {
// var opts = {
// subdistrict: 2, //返回下一级行政区
// level: 'city', //查询的范围
// showbiz: true //查询行政级别为 市
// }
// var districtSearch = new AMap.DistrictSearch(opts)
// districtSearch.search('中国', (status, result) => {
// provinceInfoList = result.districtList[0].districtList
// com.getSelect({
// id: 'startp',
// name: 'provinceName',
// url: '/area/list',
// // value: 'provinceId',
// data: provinceInfoList,
// value: 'name',
// text: 'name',
// param: {},
// select: function (data) {
// const { value } = data
// if (value) {
// // var province = provinceInfoList.find(item => item.provinceId == value)
// var province = provinceInfoList.find(item => item.name == value)
// cityInfo = province.districtList
// merchantForm.provinceCode = province.adcode
// merchantForm.provinceName = province.name
// $('#addrEl').val('')
// } else {
// cityInfo = []
// merchantForm.provinceCode = ''
// merchantForm.provinceName = ''
// }
// merchantForm.cityCode = ''
// merchantForm.cityName = ''
// com.getSelect({
// id: 'startc',
// name: 'cityName',
// url: '/area/list',
// value: 'name',
// text: 'name',
// data: cityInfo,
// link: 'startp',
// select: function (data) {
// const { value } = data
// if (value) {
// // var city = cityInfo.find(item => item.cityId == value)
// var city = cityInfo.find(item => item.name == value)
// merchantForm.cityCode = city.adcode
// merchantForm.cityName = city.name
// } else {
// merchantForm.cityCode = ''
// merchantForm.cityName = ''
// }
// }
// })
// }
// })
// })
// })
}
// 数 - start
......
......@@ -87,6 +87,7 @@
<script type="text/javascript"
src="https://webapi.amap.com/maps?v=1.4.15&key=44cc16e43ad7ed3358df507bd0618181&plugin=AMap.Geocoder&plugin=AMap.PlaceSearch&plugin=AMap.Geolocation">
</script>
<script src="/js/glsk-mapapi-sdk.js"></script>
<script>
layui.use(['helper'], function () {
var form = layui.form
......@@ -97,13 +98,19 @@
var pois = []
var geocoder //根据当前marker 获取地址
var poiActiveIdx = -1
var map = new AMap.Map("container", {
resizeEnable: true
})
var map = null, mapapi = null, marker = null
// new GLMapSdk(async res => {
// mapapi = res
// map = await mapapi.invoke('Map', 'container')
// mapapi.invoke('centerAndZoom', mapapi.invoke('Point', 113.736716, 23.069466), 15)
// map.enableScrollWheelZoom(true)
// })
// var map = new AMap.Map("container", {
// resizeEnable: true
// })
// mapapi = new GlMap()
init()
console.log(GlMap, '===')
var btnHandle = {
handleSearchAddr: function () {
var addr = $('#addrEl').val()
......@@ -127,35 +134,45 @@
return false
})
map.on('click', setLocation)
// map.on('click', setLocation)
function init() {
var __pos = null
mapData = helper.store.get('merchantMapObj')
if (mapData.lat && mapData.lng) {
__pos = [mapData.lng, mapData.lat]
modelVal('merchantAddress', mapData.merchantAddress)
} else {
var geolocation = new AMap.Geolocation({})
geolocation.getCurrentPosition()
AMap.event.addListener(geolocation, 'complete', (e) => {
// console.log(e) // 定位成功之后做的事
__pos = [e.position.lng, e.position.lat]
mapData.lat = e.position.lat
mapData.lng = e.position.lng
mapData.merchantAddress = e.formattedAddress
// 初始化地图
new GlMap(async api => {
mapapi = api
map = await mapapi.invoke('Map', 'container')
mapapi.invoke('centerAndZoom', mapapi.invoke('Point', 113.736716, 23.069466), 15)
mapapi.invoke("mapAddEventListener",'click', setLocation)
map.enableScrollWheelZoom(true) // 启用滚轮放大缩小,默认禁用
if (mapData.lat && mapData.lng) {
const {lng, lat} = mapData
console.log(mapData, 'mapData')
const lngLatXY = getLngLat(mapData.lng, mapData.lat)
// __pos = [mapData.lng, mapData.lat]
modelVal('merchantAddress', mapData.merchantAddress)
marker = createMarker(lngLatXY)
mapapi.invoke('addOverlay',marker)
mapapi.invoke('panTo', lngLatXY)
} else {
mapapi.invoke('Geolocation', res => {
console.log(res, 'Geolocation')
const lngLatXY = getLngLat(res.longitude, res.latitude)
if (marker) mapapi.invoke('removeOverlay', marker)
marker = createMarker(lngLatXY)
mapapi.invoke('addOverlay', marker)
mapapi.invoke('panTo', lngLatXY)
})
}
marker = new AMap.Marker({
position: __pos,
// 设置是否可以拖拽
draggable: true,
cursor: "move" // 设置拖拽效果
}
})
map.add(marker)
setFitView()
}
function getLngLat(lng, lat) {
return mapapi.invoke('Point', lng, lat)
}
function createMarker(lngLatXY) {
const marker = mapapi.invoke('Marker', lngLatXY)
mapapi.invoke('markerEnableDragging')
return marker
}
function modelVal(id, val) {
......@@ -167,11 +184,11 @@
}
function setLocation(e) {
// console.log(e)
var lnglat = e.lnglat
mapData.lat = e.lnglat.lat
mapData.lng = e.lnglat.lng
var lnglat = e.point
mapData.lat = lnglat.lat
mapData.lng = lnglat.lng
marker.setPosition(lnglat)
mapapi.invoke('panTo', lnglat)
getAddress()
}
......@@ -249,57 +266,75 @@
// 根据给定坐标进行解析 - 地图选点
function getAddress() {
if (!geocoder) {
geocoder = new AMap.Geocoder({
// city: "010", //城市设为北京,默认:“全国”
radius: 1000 //范围,默认:500
})
geocoder = mapapi.invoke('Geocoder')
// geocoder = new AMap.Geocoder({
// // city: "010", //城市设为北京,默认:“全国”
// radius: 1000 //范围,默认:500
// })
}
geocoder.getAddress(marker.getPosition(), function (status, result) {
if (status === "complete" && result.regeocode) {
mapData.merchantAddress = result.regeocode.formattedAddress
mapapi.invoke('getLocation', marker.getPosition(), res => {
console.log(res)
if (res) {
mapData.merchantAddress = res.surroundingPois.length ? res.surroundingPois[0].address : res.address
modelVal('merchantAddress', mapData.merchantAddress)
placeSearch(mapData.merchantAddress)
geocoder.getLocation(mapData.merchantAddress, (status, result) => {
if (status === 'complete' && result.info === 'OK') {
mapData.geocoderAddress = result.geocodes[0]
}
})
mapData.geocoderAddress = res
}
})
// geocoder.getAddress(marker.getPosition(), function (status, result) {
// if (status === "complete" && result.regeocode) {
// mapData.merchantAddress = result.regeocode.formattedAddress
// modelVal('merchantAddress', mapData.merchantAddress)
// placeSearch(mapData.merchantAddress)
// geocoder.getLocation(mapData.merchantAddress, (status, result) => {
// if (status === 'complete' && result.info === 'OK') {
// mapData.geocoderAddress = result.geocodes[0]
// }
// })
// }
// })
}
// 根据给定的地址进行解析 - 搜索地址
function getLocation(searchText) {
console.log(searchText)
if (!geocoder) {
geocoder = new AMap.Geocoder({
// city: "010", //城市设为北京,默认:“全国”
radius: 1000 //范围,默认:500
})
geocoder = mapapi.invoke('Geocoder')
// geocoder = new AMap.Geocoder({
// // city: "010", //城市设为北京,默认:“全国”
// radius: 1000 //范围,默认:500
// })
}
geocoder.getLocation(searchText, function (status, result) {
// console.log(result)
if (status === "complete" && result.geocodes.length) {
var lnglat = result.geocodes[0].location
// var _result$geocodes$ = result.geocodes[0]
// formattedAddress = _result$geocodes$.formattedAddress
// addressComponent = _result$geocodes$.addressComponent
mapData.lat = lnglat.lat
mapData.lng = lnglat.lng
mapData.merchantAddress = result.geocodes[0].formattedAddress
// mapData.province = addressComponent.province || ""
// mapData.city = addressComponent.city || ""
// mapData.district = addressComponent.district || ""
modelVal('merchantAddress', mapData.merchantAddress)
marker.setPosition(lnglat)
// address = _result$geocodes$
setFitView()
placeSearch(searchText)
} else {
layer.msg('未查询到当前地址,请尝试更换搜索关键字', {
icon: 0
})
}
})
mapapi.invoke('getPoint', searchText, res => {
console.log(res)
const lngLatXY = getLngLat(res.lng, res.lat)
marker.setPosition(lngLatXY)
mapapi.invoke('panTo', lngLatXY)
getAddress()
}, '全国')
// geocoder.getLocation(searchText, function (status, result) {
// // console.log(result)
// if (status === "complete" && result.geocodes.length) {
// var lnglat = result.geocodes[0].location
// // var _result$geocodes$ = result.geocodes[0]
// // formattedAddress = _result$geocodes$.formattedAddress
// // addressComponent = _result$geocodes$.addressComponent
// mapData.lat = lnglat.lat
// mapData.lng = lnglat.lng
// mapData.merchantAddress = result.geocodes[0].formattedAddress
// // mapData.province = addressComponent.province || ""
// // mapData.city = addressComponent.city || ""
// // mapData.district = addressComponent.district || ""
// modelVal('merchantAddress', mapData.merchantAddress)
// marker.setPosition(lnglat)
// // address = _result$geocodes$
// setFitView()
// placeSearch(searchText)
// } else {
// layer.msg('未查询到当前地址,请尝试更换搜索关键字', {
// icon: 0
// })
// }
// })
}
})
......
!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}));
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!