gdmap-utils 1.2.2 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,2 +1,215 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("MapUtils",[],t):"object"==typeof exports?exports.MapUtils=t():e.MapUtils=t()}(this,()=>(()=>{"use strict";var e={923:function(e){e.exports=function(){function e(e){var n=[];return e.AMapUI&&n.push(t(e.AMapUI)),e.Loca&&n.push(r(e.Loca)),Promise.all(n)}function t(e){return new Promise(function(t,r){var a=[];if(e.plugins)for(var l=0;l<e.plugins.length;l+=1)-1==o.AMapUI.plugins.indexOf(e.plugins[l])&&a.push(e.plugins[l]);if(i.AMapUI===n.failed)r("前次请求 AMapUI 失败");else if(i.AMapUI===n.notload){i.AMapUI=n.loading,o.AMapUI.version=e.version||o.AMapUI.version,l=o.AMapUI.version;var c=document.body||document.head,p=document.createElement("script");p.type="text/javascript",p.src="https://webapi.amap.com/ui/"+l+"/main.js",p.onerror=function(e){i.AMapUI=n.failed,r("请求 AMapUI 失败")},p.onload=function(){if(i.AMapUI=n.loaded,a.length)window.AMapUI.loadUI(a,function(){for(var e=0,r=a.length;e<r;e++){var n=a[e].split("/").slice(-1)[0];window.AMapUI[n]=arguments[e]}for(t();s.AMapUI.length;)s.AMapUI.splice(0,1)[0]()});else for(t();s.AMapUI.length;)s.AMapUI.splice(0,1)[0]()},c.appendChild(p)}else i.AMapUI===n.loaded?e.version&&e.version!==o.AMapUI.version?r("不允许多个版本 AMapUI 混用"):a.length?window.AMapUI.loadUI(a,function(){for(var e=0,r=a.length;e<r;e++){var n=a[e].split("/").slice(-1)[0];window.AMapUI[n]=arguments[e]}t()}):t():e.version&&e.version!==o.AMapUI.version?r("不允许多个版本 AMapUI 混用"):s.AMapUI.push(function(e){e?r(e):a.length?window.AMapUI.loadUI(a,function(){for(var e=0,r=a.length;e<r;e++){var n=a[e].split("/").slice(-1)[0];window.AMapUI[n]=arguments[e]}t()}):t()})})}function r(e){return new Promise(function(t,r){if(i.Loca===n.failed)r("前次请求 Loca 失败");else if(i.Loca===n.notload){i.Loca=n.loading,o.Loca.version=e.version||o.Loca.version;var a=o.Loca.version,l=o.AMap.version.startsWith("2"),c=a.startsWith("2");if(l&&!c||!l&&c)r("JSAPI 与 Loca 版本不对应!!");else{l=o.key,c=document.body||document.head;var p=document.createElement("script");p.type="text/javascript",p.src="https://webapi.amap.com/loca?v="+a+"&key="+l,p.onerror=function(e){i.Loca=n.failed,r("请求 AMapUI 失败")},p.onload=function(){for(i.Loca=n.loaded,t();s.Loca.length;)s.Loca.splice(0,1)[0]()},c.appendChild(p)}}else i.Loca===n.loaded?e.version&&e.version!==o.Loca.version?r("不允许多个版本 Loca 混用"):t():e.version&&e.version!==o.Loca.version?r("不允许多个版本 Loca 混用"):s.Loca.push(function(e){e?r(e):r()})})}if(!window)throw Error("AMap JSAPI can only be used in Browser.");var n,a;(a=n||(n={})).notload="notload",a.loading="loading",a.loaded="loaded",a.failed="failed";var o={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},i={AMap:n.notload,AMapUI:n.notload,Loca:n.notload},s={AMap:[],AMapUI:[],Loca:[]},l=[];return{load:function(t){return new Promise(function(r,a){if(i.AMap==n.failed)a("");else if(i.AMap==n.notload){var s=t.key,c=t.version,p=t.plugins;s?(window.AMap&&"lbs.amap.com"!==location.host&&a("禁止多种API加载方式混用"),o.key=s,o.AMap.version=c||o.AMap.version,o.AMap.plugins=p||o.AMap.plugins,i.AMap=n.loading,c=document.body||document.head,window.___onAPILoaded=function(o){if(delete window.___onAPILoaded,o)i.AMap=n.failed,a(o);else for(i.AMap=n.loaded,e(t).then(function(){r(window.AMap)}).catch(a);l.length;)l.splice(0,1)[0]()},(p=document.createElement("script")).type="text/javascript",p.src="https://webapi.amap.com/maps?callback=___onAPILoaded&v="+o.AMap.version+"&key="+s+"&plugin="+o.AMap.plugins.join(","),p.onerror=function(e){i.AMap=n.failed,a(e)},c.appendChild(p)):a("请填写key")}else if(i.AMap==n.loaded)if(t.key&&t.key!==o.key)a("多个不一致的 key");else if(t.version&&t.version!==o.AMap.version)a("不允许多个版本 JSAPI 混用");else{if(s=[],t.plugins)for(c=0;c<t.plugins.length;c+=1)-1==o.AMap.plugins.indexOf(t.plugins[c])&&s.push(t.plugins[c]);s.length?window.AMap.plugin(s,function(){e(t).then(function(){r(window.AMap)}).catch(a)}):e(t).then(function(){r(window.AMap)}).catch(a)}else if(t.key&&t.key!==o.key)a("多个不一致的 key");else if(t.version&&t.version!==o.AMap.version)a("不允许多个版本 JSAPI 混用");else{var y=[];if(t.plugins)for(c=0;c<t.plugins.length;c+=1)-1==o.AMap.plugins.indexOf(t.plugins[c])&&y.push(t.plugins[c]);!function(e){"function"==typeof e&&(i.AMap===n.loaded?e(window.AMap):l.push(e))}(function(){y.length?window.AMap.plugin(y,function(){e(t).then(function(){r(window.AMap)}).catch(a)}):e(t).then(function(){r(window.AMap)}).catch(a)})}})},reset:function(){delete window.AMap,delete window.AMapUI,delete window.Loca,o={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},i={AMap:n.notload,AMapUI:n.notload,Loca:n.notload},s={AMap:[],AMapUI:[],Loca:[]}}}}()}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,r),o.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};r.r(n),r.d(n,{MapUtils:()=>A,createMapUtils:()=>b,initMapSource:()=>x});var a=r(923),o=r.n(a);const i=function(){function e(){}return e.loadScript=function(e){return t=this,r=void 0,a=function(){return function(e,t){var r,n,a,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&s[0]?n.return:s[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,s[1])).done)return a;switch(n=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){o.label=s[1];break}if(6===s[0]&&o.label<a[1]){o.label=a[1],a=s;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(s);break}a[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}(this,function(t){return[2,o().load(e).then(function(e){return e}).catch(function(e){throw console.error(e),new Error(e)})]})},new((n=void 0)||(n=Promise))(function(e,o){function i(e){try{l(a.next(e))}catch(e){o(e)}}function s(e){try{l(a.throw(e))}catch(e){o(e)}}function l(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n(function(e){e(r)})).then(i,s)}l((a=a.apply(t,r||[])).next())});var t,r,n,a},e}();var s=function(){return s=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},s.apply(this,arguments)};const l=function(e){return new AMap.Marker(s({},e))},c=function(e){return new AMap.Icon({size:this.Size.apply(this,e.size),image:e.image,imageSize:this.Size.apply(this,e.imageSize),imageOffset:this.Pixel.apply(this,e.imageOffset)})},p=function(e,t){return new AMap.Size(e,t)},y=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return new((e=AMap.Pixel).bind.apply(e,function(e,t,r){if(r||2===arguments.length)for(var n,a=0,o=t.length;a<o;a++)!n&&a in t||(n||(n=Array.prototype.slice.call(t,0,a)),n[a]=t[a]);return e.concat(n||Array.prototype.slice.call(t))}([void 0],t,!1)))},u=function(e,t,r){return new AMap.LngLat(e,t,r)};var f=function(){return f=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},f.apply(this,arguments)};const h=function(){function e(e,t){this.events=new Map,this.map=e,this.rawLayer=new AMap.LabelsLayer(f({collision:!0,opacity:1,zIndex:120,allowCollision:!0},t)),this.map.add(this.rawLayer)}return e.convertOverlayDataToOvlOpts=function(e,t,r,n,a){var o,i,s,l,c=e.overlayData,p=c.lon,y=c.lat,u=c.extData,h=c.title,v=n(e,t,a),d=f({position:[p,y],extData:u},v);if(e.labelShowed)d.text=null!==(i=d.text)&&void 0!==i?i:{content:h,direction:"top",style:{fontSize:16,strokeWidth:5},zooms:[5,20]};else{var w=null!==(o=d.text)&&void 0!==o?o:{content:h,direction:"top",style:{fontSize:16,strokeWidth:5},zooms:[5,20]};w.content="",d.text=w}var L=r(e);return d.icon=null!==(s=d.icon)&&void 0!==s?s:{image:"",size:[25,34],anchor:"bottom-center"},null===(l=d.icon)||void 0===l||(l.image=L),d},e.prototype.bindEventOverlay=function(e,t){"function"==typeof t?(this.on(e,t),this.events.set(e,t)):A.error("Please provide an event callback function")},e.prototype.addOverlayBindEvent=function(e){this.events.forEach(function(t,r){e.on(r,t)})},e.prototype.createOverlays=function(e){var t=this,r=e.map(function(e){var r=new AMap.LabelMarker(e);return t.addOverlayBindEvent(r),r});return this.rawLayer.add(r),r},e.prototype.add=function(e){this.createOverlays(e)},e.prototype.remove=function(e){this.rawLayer.remove(e)},e.prototype.hide=function(){this.rawLayer.hide()},e.prototype.show=function(){this.rawLayer.show()},e.prototype.getAllOverlay=function(){return this.rawLayer.getAllOverlays()},e.prototype.destroy=function(){this.rawLayer.clear(),this.map.remove(this.rawLayer)},e.prototype.reload=function(){this.rawLayer.clear()},e.prototype.clearAllOvl=function(){this.rawLayer.clear()},e.prototype.overlayFitMap=function(){var e=this.getAllOverlay();this.map.setFitView(e)},e.prototype.findLayerOverlay=function(e){return e?this.getAllOverlay().find(function(t){return t.getExtData().id===e})||null:(A.error("Please provide a markerId"),null)},e.prototype.refreshOverlayIcon=function(e,t){e?e.setIcon(t):A.error("labelMarker is not found")},e.prototype.refreshOverlayLabel=function(e,t){if(e)if(t)e.setText(t);else{var r=e.getText();e.setText(f(f({},r),{content:""}))}else A.error("labelMarker is not found")},e.prototype.on=function(e,t){this.getAllOverlay().forEach(function(r){r.on(e,t)})},e}();var v=function(){return v=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},v.apply(this,arguments)},d=function(){function e(e){this.rawLayer=new AMap.OverlayGroup,this.events=new Map,this.map=e,this.map.add(this.rawLayer)}return e.convertOverlayDataToOvlOpts=function(e,t,r,n,a){var o,i,s=e.overlayData,l=s.lon,c=s.lat,p=s.extData,y=n(e,t,a),u=v({position:[l,c],extData:p},y);e.labelShowed?u.label=null!==(o=u.label)&&void 0!==o?o:{content:'<div class="markerLayer">'.concat(e.overlayData.title,"</div>"),offset:a.Pixel(0,-5),direction:"top"}:u.label=void 0,u.icon=null!==(i=u.icon)&&void 0!==i?i:a.createIcon({size:[25,34],image:"",imageSize:[25,34],imageOffset:[0,0]});var f=r(e);return"string"==typeof u.icon?u.icon=f:u.icon.setImage(f),u},e.prototype.bindEventOverlay=function(e,t){"function"==typeof t?(this.rawLayer.on(e,t),this.events.set(e,t)):A.error("Please provide an event callback function")},e.prototype.addOverlayBindEvent=function(e){this.events.forEach(function(t,r){e.on(r,t)})},e.prototype.createOverlays=function(e){var t=e.map(function(e){return A.createAMapMarker(e)});return this.rawLayer.addOverlays(t),t},e.prototype.add=function(e){this.createOverlays(e)},e.prototype.remove=function(e){this.rawLayer.removeOverlays(e)},e.prototype.hide=function(){this.rawLayer.hide()},e.prototype.show=function(){this.rawLayer.show()},e.prototype.getAllOverlay=function(){return this.rawLayer.getOverlays()},e.prototype.destroy=function(){this.rawLayer.clearOverlays(),this.rawLayer.setMap(null)},e.prototype.reload=function(){this.rawLayer.clearOverlays()},e.prototype.clearAllOvl=function(){this.rawLayer.clearOverlays()},e.prototype.overlayFitMap=function(){var e=this.getAllOverlay();this.map.setFitView(e)},e.prototype.findLayerOverlay=function(e){if(e)return this.getAllOverlay().find(function(t){return t.getExtData().id===e})||null;A.error("Please provide a markerId")},e.prototype.refreshOverlayIcon=function(e,t){if(!e)return A.error("marker is not found");e.setIcon(t)},e.prototype.refreshOverlayLabel=function(e,t){if(!e)return A.error("marker is not found");if(t)e.setLabel(t);else{var r=e.getLabel();e.setLabel(v(v({},r),{content:""}))}},e}();const w=d;var L=function(){function e(t,r){this.layerVisible=!0;var n=t.layerType,a=t.layerName,o=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]])}return r}(t,["layerType","layerName"]),i=e.layerClassMap.get(n);if(!i)throw new Error("[BaseMarkerLayer Error]: Invalid layer type ".concat(n));this.rawLayerIns=new i(r.map,t.overlayLayer),this.layerName=a,this.mapUtils=r,this.overlayList=t.overlayList,this.getIconUrl=t.getIconUrl,this.getOverlayOpts=t.getOverlayOpts,this.layerType=t.layerType,Object.assign(this,o),this.initLayer()}return e.registerLayer=function(t,r){"string"==typeof t&&"function"==typeof r?e.layerClassMap.set(t,r):A.error("[LayerManager Error]: Invalid layer type or layer class")},e.prototype.initLayer=function(){this.createOverlays(this.overlayList)},e.prototype.convertOverlayDataToOpts=function(t){var r=this,n=e.layerClassMap.get(this.layerType);return t.map(function(e,t){return n.convertOverlayDataToOvlOpts(e,t,r.getIconUrl,r.getOverlayOpts,A)})},e.prototype.createOverlays=function(e){var t=this.convertOverlayDataToOpts(e);return this.rawLayerIns.createOverlays(t)},e.prototype.overlayFitMap=function(){this.rawLayerIns.overlayFitMap()},e.prototype.bindEventOverlays=function(e,t){this.rawLayerIns.bindEventOverlay(e,t)},e.prototype.hide=function(){this.layerVisible=!1,this.rawLayerIns.hide()},e.prototype.show=function(){this.layerVisible=!0,this.rawLayerIns.show()},e.prototype.getAllOverlay=function(){return function(e,t,r){if(r||2===arguments.length)for(var n,a=0,o=t.length;a<o;a++)!n&&a in t||(n||(n=Array.prototype.slice.call(t,0,a)),n[a]=t[a]);return e.concat(n||Array.prototype.slice.call(t))}([],this.rawLayerIns.getAllOverlay(),!0)},e.prototype.destroy=function(){this.mapUtils.removeLayer(this),this.rawLayerIns.destroy(),this.overlayList=[]},e.prototype.clearAllOverlay=function(){this.overlayList=[],this.rawLayerIns.clearAllOvl()},e.prototype.reload=function(){this.rawLayerIns.reload(),this.createOverlays(this.overlayList)},e.prototype.findLayerOverlay=function(e){return this.rawLayerIns.findLayerOverlay(e)},e.prototype.add=function(e){var t,r=this.convertOverlayDataToOpts(e);(t=this.overlayList).push.apply(t,e),(this.rawLayerIns instanceof w||this.rawLayerIns instanceof h)&&this.rawLayerIns.add(r)},e.prototype.remove=function(e){var t=this;if(this.rawLayerIns instanceof w)if(e[0]instanceof AMap.Marker){var r=e.map(function(e){return e.getExtData().id});this.overlayList=this.overlayList.filter(function(e){return!r.includes(e.id)}),this.rawLayerIns.remove(e)}else{var n=e.map(function(e){return t.findLayerOverlay(e)}).filter(function(e){return!!e});this.rawLayerIns.remove(n),this.overlayList=this.overlayList.filter(function(t){return!e.includes(t.id)})}else if(this.rawLayerIns instanceof h)if(e[0]instanceof AMap.LabelMarker){var a=e.map(function(e){return e.getExtData().id});this.overlayList=this.overlayList.filter(function(e){return!a.includes(e.id)}),this.rawLayerIns.remove(e)}else n=e.map(function(e){return t.findLayerOverlay(e)}).filter(function(e){return!!e}),this.rawLayerIns.remove(n),this.overlayList=this.overlayList.filter(function(t){return!e.includes(t.id)})},e.prototype.refreshOverlayIcon=function(t){var r=this.overlayList.findIndex(function(e){return e.id===t});if(-1===r)return A.error("[BaseMarkerLayer Error]: Invalid overlayId ".concat(t));var n=e.layerClassMap.get(this.layerType);if(this.rawLayerIns instanceof w||this.rawLayerIns instanceof h){var a,o=this.rawLayerIns.findLayerOverlay(t),i=n.convertOverlayDataToOvlOpts(this.overlayList[r],r,this.getIconUrl,this.getOverlayOpts,A),s=this.getIconUrl(this.overlayList[r]);this.rawLayerIns instanceof w?("string"==typeof(a=i.icon)?a=s:a.setImage(s),this.rawLayerIns.refreshOverlayIcon(o,a)):((a=i.icon).image=s,this.rawLayerIns.refreshOverlayIcon(o,a))}},e.prototype.refreshOverlayLabel=function(t,r){var n=this.overlayList.findIndex(function(e){return e.id===t});if(-1===n)return A.error("[Layer Error]: Invalid overlayId ".concat(t));var a=e.layerClassMap.get(this.layerType);if(this.rawLayerIns instanceof w||this.rawLayerIns instanceof h){var o=this.rawLayerIns.findLayerOverlay(t);this.overlayList.find(function(e){return e.id===t}).labelShowed=r;var i=a.convertOverlayDataToOvlOpts(this.overlayList[n],n,this.getIconUrl,this.getOverlayOpts,A);this.rawLayerIns instanceof w?r?this.rawLayerIns.refreshOverlayLabel(o,i.label):this.rawLayerIns.refreshOverlayLabel(o):r?this.rawLayerIns.refreshOverlayLabel(o,i.text):this.rawLayerIns.refreshOverlayLabel(o)}},e.prototype.getRawLayer=function(){return this.rawLayerIns.rawLayer},e.layerClassMap=new Map,e}();L.registerLayer("markerLayer",w),L.registerLayer("labelMarkerLayer",h);const g=L,M=function(){function e(){this.layers=new Map}return e.prototype.addLayer=function(e){if(this.hasLayer(e))throw new Error('Layer with name "'.concat(e.layerName,'" already exists'));this.layers.set(e.layerName,e)},e.prototype.removeLayer=function(e){this.layers.delete(e.layerName)},e.prototype.show=function(e){var t=this.layers.get(e);t&&t.show()},e.prototype.hide=function(e){var t=this.layers.get(e);t&&t.hide()},e.prototype.showAll=function(){this.layers.forEach(function(e){return e.show()})},e.prototype.hideAll=function(){this.layers.forEach(function(e){return e.hide()})},e.prototype.reload=function(){this.layers.forEach(function(e){return e.reload()})},e.prototype.hasLayer=function(e){return this.layers.has(e.layerName)},e}();var O=function(e,t,r,n){return new(r||(r=Promise))(function(a,o){function i(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(i,s)}l((n=n.apply(e,t||[])).next())})},I=function(e,t){var r,n,a,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&s[0]?n.return:s[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,s[1])).done)return a;switch(n=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){o.label=s[1];break}if(6===s[0]&&o.label<a[1]){o.label=a[1],a=s;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(s);break}a[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}},m=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]])}return r},A=function(){function e(t,r){if(this.LayerManager=new M,"object"!=typeof r||!("Map"in r))throw e.error("AMap is not exist");if("mapIns"in t&&t.mapIns instanceof r.Map){t.mapIns;var n=m(t,["mapIns"]);this.map=t.mapIns,this.options=n}else{if(!("mountSelector"in t))throw e.error("mountSelector is not exist");this.options=t;var a=t.mountSelector;n=m(t,["mountSelector"]),this.map=this.initMap(a,n)}this.bindMapClickEvent()}return e.prototype.bindMapClickEvent=function(){this.map.on("click",function(){})},e.prototype.initMap=function(e,t){return new window.AMap.Map(e,t)},e.prototype.createLayer=function(e){var t=new g(e,this);return this.LayerManager.addLayer(t),t},e.prototype.removeLayer=function(t){this.LayerManager.hasLayer(t)?this.LayerManager.removeLayer(t):e.error("".concat(t.layerName," is not exist"))},e.prototype.setFitView=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];(e=this.map).setFitView.apply(e,t)},e.error=function(e){console.error("[MapUtils Error]:".concat(e))},e.createAMapMarker=l,e.createIcon=c,e.Size=p,e.Pixel=y,e.LngLat=u,e}();function b(e,t){return O(this,void 0,void 0,function(){var r;return I(this,function(n){switch(n.label){case 0:return r=window.AMap,t?[4,x(t)]:[3,2];case 1:r=n.sent(),n.label=2;case 2:return[2,new A(e,r)]}})})}function x(e){return O(this,void 0,void 0,function(){return I(this,function(t){switch(t.label){case 0:return[4,i.loadScript(e)];case 1:return[2,t.sent()]}})})}return n})());
1
+ !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("@amap/amap-jsapi-loader")):"function"==typeof define&&define.amd?define("GdMapUtils",["@amap/amap-jsapi-loader"],r):"object"==typeof exports?exports.GdMapUtils=r(require("@amap/amap-jsapi-loader")):e.GdMapUtils=r(e.AMapLoader)}(this,e=>(()=>{"use strict";var r={591(r){r.exports=e}},t={};function __webpack_require__(e){var a=t[e];if(void 0!==a)return a.exports;var n=t[e]={exports:{}};return r[e](n,n.exports,__webpack_require__),n.exports}__webpack_require__.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(r,{a:r}),r},__webpack_require__.d=(e,r)=>{for(var t in r)__webpack_require__.o(r,t)&&!__webpack_require__.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},__webpack_require__.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};__webpack_require__.r(a),__webpack_require__.d(a,{BaseMarkerLayer:()=>u,ClusterMarkerLayer:()=>v,MapUtils:()=>d,createMapUtils:()=>createMapUtils,initMapSource:()=>initMapSource});var n=__webpack_require__(591),o=__webpack_require__.n(n),__awaiter=function(e,r,t,a){return new(t||(t=Promise))(function(n,o){function fulfilled(e){try{step(a.next(e))}catch(e){o(e)}}function rejected(e){try{step(a.throw(e))}catch(e){o(e)}}function step(e){var r;e.done?n(e.value):(r=e.value,r instanceof t?r:new t(function(e){e(r)})).then(fulfilled,rejected)}step((a=a.apply(e,r||[])).next())})},__generator=function(e,r){var t,a,n,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=verb(0),i.throw=verb(1),i.return=verb(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function verb(s){return function(l){return function(s){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(o=0)),o;)try{if(t=1,a&&(n=2&s[0]?a.return:s[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,s[1])).done)return n;switch(a=0,n&&(s=[2&s[0],n.value]),s[0]){case 0:case 1:n=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,a=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(n=o.trys,(n=n.length>0&&n[n.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!n||s[1]>n[0]&&s[1]<n[3])){o.label=s[1];break}if(6===s[0]&&o.label<n[1]){o.label=n[1],n=s;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(s);break}n[2]&&o.ops.pop(),o.trys.pop();continue}s=r.call(e,o)}catch(e){s=[6,e],a=0}finally{t=n=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};const i=function(){function MapSourceImport(){}return MapSourceImport.loadScript=function(e){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(r){return[2,o().load(e).then(function(e){return e}).catch(function(e){throw console.error(e),new Error(e)})]})})},MapSourceImport}();var __assign=function(){return __assign=Object.assign||function(e){for(var r,t=1,a=arguments.length;t<a;t++)for(var n in r=arguments[t])Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);return e},__assign.apply(this,arguments)},__rest=function(e,r){var t={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&r.indexOf(a)<0&&(t[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(a=Object.getOwnPropertySymbols(e);n<a.length;n++)r.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(e,a[n])&&(t[a[n]]=e[a[n]])}return t},__spreadArray=function(e,r,t){if(t||2===arguments.length)for(var a,n=0,o=r.length;n<o;n++)!a&&n in r||(a||(a=Array.prototype.slice.call(r,0,n)),a[n]=r[n]);return e.concat(a||Array.prototype.slice.call(r))};const s={
2
+ /**
3
+ * 创建高德地图标注
4
+ * @param {AMap.MarkerOptions} options 标注配置
5
+ * @returns {AMap.Marker} 标注对象
6
+ */
7
+ createAMapMarker:function(e){return new AMap.Marker(__assign({},e))},
8
+ /**
9
+ * 创建一个图标
10
+ * @param {[number, number]} size - 图标尺寸,格式为 [width, height]
11
+ * @param {string} image - 图片的 URL 地址
12
+ * @param {[number, number]} imageSize - 图标所用图片的大小,格式为 [width, height]
13
+ * @param {[number, number]} imageOffset - 图标取图的偏移量,格式为 [x, y]
14
+ * @returns {AMap.Icon} 图标对象
15
+ */
16
+ createIcon:function(e){return new AMap.Icon({size:this.Size.apply(this,e.size),image:e.image,imageSize:this.Size.apply(this,e.imageSize),imageOffset:this.Pixel.apply(this,e.imageOffset)})},
17
+ /**
18
+ * 地物对象的像素尺寸
19
+ * @param {number} width 宽度
20
+ * @param {number} height 高度
21
+ * @returns {AMap.Size} 尺寸对象
22
+ */
23
+ Size:function(e,r){return new AMap.Size(e,r)},
24
+ /**
25
+ * 像素坐标,确定地图上的一个像素点
26
+ * @param {number} x x坐标
27
+ * @param {number} y y坐标
28
+ * @returns {AMap.Pixel} 像素对象
29
+ */
30
+ Pixel:function(){for(var e,r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return new((e=AMap.Pixel).bind.apply(e,__spreadArray([void 0],r,!1)))},
31
+ /**
32
+ * 经纬度坐标,用来描述地图上的一个点位置
33
+ * @param {number} lng 经度值
34
+ * @param {number} lat 纬度值
35
+ * @param {boolean} noWrap 是否不进行标准化处理
36
+ * @returns {AMap.LngLat} 经纬度对象
37
+ */
38
+ LngLat:function(e,r,t){return new AMap.LngLat(e,r,t)},createAMapInfoWindow:function(e){var r=e,t=r.isCustom,a=void 0===t||t,n=r.closeWhenClickMap,o=void 0===n||n,i=__rest(r,["isCustom","closeWhenClickMap"]);return new AMap.InfoWindow(__assign({isCustom:a,closeWhenClickMap:o},i))},
39
+ /**
40
+ * 创建高德地图折线
41
+ * @param {Object} options 折线配置
42
+ * @returns {AMap.Polyline} 折线对象
43
+ */
44
+ createAMapPolyline:function(e){var r=Object.assign(e,{showDir:!0,lineJoin:"round",strokeColor:"#28F",strokeOpacity:1,strokeWeight:6});return new AMap.Polyline(r)},loadPlugins:function(e){return new Promise(function(r){AMap.plugin(e,function(){r()})})}};var LabelMarkerLayer_assign=function(){return LabelMarkerLayer_assign=Object.assign||function(e){for(var r,t=1,a=arguments.length;t<a;t++)for(var n in r=arguments[t])Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);return e},LabelMarkerLayer_assign.apply(this,arguments)};const l=function(){function LabelMarkerLayer(e,r){this.events=new Map,this.map=e,this.rawLayer=new AMap.LabelsLayer(LabelMarkerLayer_assign({collision:!0,opacity:1,zIndex:120,allowCollision:!0},r)),this.map.add(this.rawLayer)}
45
+ /**
46
+ * 将覆盖物数据转换为标记配置
47
+ * @param item 覆盖物数据
48
+ * @param index 索引
49
+ * @param getIconUrl 获取图标URL的方法
50
+ * @param getOverlayOpts 动态获取覆盖物配置的方法
51
+ * @param MapUtils MapUtils构造函数
52
+ * @returns 标记配置
53
+ */return LabelMarkerLayer.convertOverlayDataToOvlOpts=function(e,r,t,a,n){var o,i,s,l=e.overlayData,y=l.lon,p=l.lat,c=l.extData,u=l.title,f=a(e,r,n),h=LabelMarkerLayer_assign({position:[y,p],extData:c},f);if(e.labelShowed)h.text=null!==(i=h.text)&&void 0!==i?i:{content:u,direction:"top",style:{fontSize:16,strokeWidth:5},zooms:[5,20]};else{var v=null!==(o=h.text)&&void 0!==o?o:{content:u,direction:"top",style:{fontSize:16,strokeWidth:5},zooms:[5,20]};v.content="",h.text=v}var L=t(e);return h.icon=null!==(s=h.icon)&&void 0!==s?s:{image:"",size:[25,34],anchor:"bottom-center"},h.icon.image=L,h},LabelMarkerLayer.prototype.bindEventOverlay=function(e,r){"function"==typeof r?(this.on(e,r),this.events.set(e,r)):d.error("Please provide an event callback function")},LabelMarkerLayer.prototype.addOverlayBindEvent=function(e){this.events.forEach(function(r,t){e.on(t,r)})},LabelMarkerLayer.prototype.createOverlays=function(e){var r=this,t=e.map(function(e){var t=new AMap.LabelMarker(e);return r.addOverlayBindEvent(t),t});return this.rawLayer.add(t),t},LabelMarkerLayer.prototype.add=function(e){this.createOverlays(e)},LabelMarkerLayer.prototype.remove=function(e){this.rawLayer.remove(e)},LabelMarkerLayer.prototype.hide=function(){this.rawLayer.hide()},LabelMarkerLayer.prototype.show=function(){this.rawLayer.show()},LabelMarkerLayer.prototype.getAllOverlay=function(){return this.rawLayer.getAllOverlays()},LabelMarkerLayer.prototype.destroy=function(){this.rawLayer.clear(),this.map.remove(this.rawLayer),this.rawLayer=null},LabelMarkerLayer.prototype.reload=function(){this.rawLayer.clear()},LabelMarkerLayer.prototype.clearAllOvl=function(){this.rawLayer.clear()},LabelMarkerLayer.prototype.overlayFitMap=function(){var e=this.getAllOverlay();this.map.setFitView(e)},LabelMarkerLayer.prototype.findLayerOverlay=function(e){return e?this.getAllOverlay().find(function(r){return r.getExtData().id===e}):(d.error("Please provide a markerId"),null)},LabelMarkerLayer.prototype.refreshOverlayIcon=function(e,r){e?e.setIcon(r):d.error("labelMarker is not found")},LabelMarkerLayer.prototype.refreshOverlayLabel=function(e,r){if(e)if(r)e.setText(r);else{var t=e.getText();e.setText(LabelMarkerLayer_assign(LabelMarkerLayer_assign({},t),{content:""}))}else d.error("labelMarker is not found")},
54
+ /**
55
+ *
56
+ * labelLayer不存在on方法
57
+ * @param {AMap.EventType} clickType 事件类型
58
+ * @param {() => void} callback 事件函数
59
+ * @memberof LabelMarkerLayer
60
+ */
61
+ LabelMarkerLayer.prototype.on=function(e,r){this.getAllOverlay().forEach(function(t){t.on(e,r)})},LabelMarkerLayer}();var MarkerLayer_assign=function(){return MarkerLayer_assign=Object.assign||function(e){for(var r,t=1,a=arguments.length;t<a;t++)for(var n in r=arguments[t])Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);return e},MarkerLayer_assign.apply(this,arguments)},y=function(){function MarkerLayer(e){this.rawLayer=new AMap.OverlayGroup,this.events=new Map,this.map=e,this.map.add(this.rawLayer)}
62
+ /**
63
+ * 将覆盖物数据转换为标记配置
64
+ * @param item 覆盖物数据
65
+ * @param index 索引
66
+ * @param getIconUrl 获取图标URL的方法
67
+ * @param getOverlayOpts 动态获取覆盖物配置的方法
68
+ * @param MapUtils MapUtils构造函数
69
+ * @returns 标记配置
70
+ */return MarkerLayer.convertOverlayDataToOvlOpts=function(e,r,t,a,n){var o,i,s=e.overlayData,l=s.lon,y=s.lat,p=s.extData,c=a(e,r,n),u=MarkerLayer_assign({position:[l,y],extData:p},c);e.labelShowed?u.label=null!==(o=u.label)&&void 0!==o?o:{content:'<div class="markerLayer">'.concat(e.overlayData.title,"</div>"),offset:n.Pixel(0,-5),direction:"top"}:u.label=void 0,u.icon=null!==(i=u.icon)&&void 0!==i?i:n.createIcon({size:[25,34],image:"",imageSize:[25,34],imageOffset:[0,0]});var f=t(e);return"string"==typeof u.icon?u.icon=f:u.icon.setImage(f),u},MarkerLayer.prototype.bindEventOverlay=function(e,r){"function"==typeof r?(this.rawLayer.on(e,r),this.events.set(e,r)):d.error("Please provide an event callback function")},MarkerLayer.prototype.addOverlayBindEvent=function(e){this.events.forEach(function(r,t){e.on(t,r)})},MarkerLayer.prototype.createOverlays=function(e){var r=e.map(function(e){return d.createAMapMarker(e)});return this.rawLayer.addOverlays(r),r},MarkerLayer.prototype.add=function(e){this.createOverlays(e)},MarkerLayer.prototype.remove=function(e){this.rawLayer.removeOverlays(e)},MarkerLayer.prototype.hide=function(){this.rawLayer.hide()},MarkerLayer.prototype.show=function(){this.rawLayer.show()},MarkerLayer.prototype.getAllOverlay=function(){return this.rawLayer.getOverlays()},MarkerLayer.prototype.destroy=function(){this.rawLayer.clearOverlays(),this.rawLayer.setMap(null),this.rawLayer=null},MarkerLayer.prototype.reload=function(){this.rawLayer.clearOverlays()},MarkerLayer.prototype.clearAllOvl=function(){this.rawLayer.clearOverlays()},MarkerLayer.prototype.overlayFitMap=function(){var e=this.getAllOverlay();this.map.setFitView(e)},MarkerLayer.prototype.findLayerOverlay=function(e){if(e)return this.getAllOverlay().find(function(r){return r.getExtData().id===e});d.error("Please provide a markerId")},MarkerLayer.prototype.refreshOverlayIcon=function(e,r){if(!e)return d.error("marker is not found");e.setIcon(r)},MarkerLayer.prototype.refreshOverlayLabel=function(e,r){if(!e)return d.error("marker is not found");if(r)e.setLabel(r);else{var t=e.getLabel();e.setLabel(MarkerLayer_assign(MarkerLayer_assign({},t),{content:""}))}},MarkerLayer}();const p=y;var baseMarkerLayer_rest=function(e,r){var t={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&r.indexOf(a)<0&&(t[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(a=Object.getOwnPropertySymbols(e);n<a.length;n++)r.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(e,a[n])&&(t[a[n]]=e[a[n]])}return t},baseMarkerLayer_spreadArray=function(e,r,t){if(t||2===arguments.length)for(var a,n=0,o=r.length;n<o;n++)!a&&n in r||(a||(a=Array.prototype.slice.call(r,0,n)),a[n]=r[n]);return e.concat(a||Array.prototype.slice.call(r))},c=function(){function BaseMarkerLayer(e,r){this.layerVisible=!0;var t=e.layerType,a=e.layerName,n=baseMarkerLayer_rest(e,["layerType","layerName"]),o=BaseMarkerLayer.layerClassMap.get(t);if(!o)throw new Error("[BaseMarkerLayer Error]: Invalid layer type ".concat(t));this.rawLayerIns=new o(r.map,e.overlayLayer),this.layerName=a,this.mapUtils=r,this.overlayList=e.overlayList,this.getIconUrl=e.getIconUrl,this.getOverlayOpts=e.getOverlayOpts,this.layerType=e.layerType,Object.assign(this,n),this.initLayer()}
71
+ /**
72
+ * 注册图层类型与控制器类的关联
73
+ * @param {string} layerType - 图层类型
74
+ * @param {Function} layerClass - 图层控制器类
75
+ */return BaseMarkerLayer.registerLayer=function(e,r){"string"==typeof e&&"function"==typeof r?BaseMarkerLayer.layerClassMap.set(e,r):d.error("[LayerManager Error]: Invalid layer type or layer class")},BaseMarkerLayer.prototype.initLayer=function(){this.createOverlays(this.overlayList)},
76
+ /**
77
+ * 将覆盖物数据转换为覆盖物配置
78
+ * @param overlayList 覆盖物数据列表
79
+ * @returns 覆盖物配置列表
80
+ */
81
+ BaseMarkerLayer.prototype.convertOverlayDataToOpts=function(e){var r=this,t=BaseMarkerLayer.layerClassMap.get(this.layerType);return e.map(function(e,a){return t.convertOverlayDataToOvlOpts(e,a,r.getIconUrl,r.getOverlayOpts,d)})},BaseMarkerLayer.prototype.createOverlays=function(e){var r=this.convertOverlayDataToOpts(e);return this.rawLayerIns.createOverlays(r)},BaseMarkerLayer.prototype.overlayFitMap=function(){this.rawLayerIns.overlayFitMap()},BaseMarkerLayer.prototype.bindEventOverlays=function(e,r){this.rawLayerIns.bindEventOverlay(e,r)},BaseMarkerLayer.prototype.hide=function(){this.layerVisible=!1,this.rawLayerIns.hide()},BaseMarkerLayer.prototype.show=function(){this.layerVisible=!0,this.rawLayerIns.show()},BaseMarkerLayer.prototype.getAllOverlay=function(){return baseMarkerLayer_spreadArray([],this.rawLayerIns.getAllOverlay(),!0)},BaseMarkerLayer.prototype.destroy=function(){this.mapUtils.removeLayer(this),this.rawLayerIns.destroy(),this.overlayList=[]},BaseMarkerLayer.prototype.clearAllOverlay=function(){this.overlayList=[],this.rawLayerIns.clearAllOvl()},BaseMarkerLayer.prototype.reload=function(){this.rawLayerIns.reload(),this.createOverlays(this.overlayList)},BaseMarkerLayer.prototype.findLayerOverlay=function(e){return this.rawLayerIns.findLayerOverlay(e)},BaseMarkerLayer.prototype.add=function(e){var r,t=this.convertOverlayDataToOpts(e);(r=this.overlayList).push.apply(r,e),(this.rawLayerIns instanceof p||this.rawLayerIns instanceof l)&&this.rawLayerIns.add(t)},BaseMarkerLayer.prototype.remove=function(e){var r=this;if(this.rawLayerIns instanceof p){if(e[0]instanceof AMap.Marker){var t=e.map(function(e){return e.getExtData().id});this.overlayList=this.overlayList.filter(function(e){return!t.includes(e.id)}),this.rawLayerIns.remove(e)}else{var a=e.map(function(e){return r.findLayerOverlay(e)}).filter(function(e){return!!e});this.rawLayerIns.remove(a),this.overlayList=this.overlayList.filter(function(r){return!e.includes(r.id)})}}else if(this.rawLayerIns instanceof l){if(function(e){return e[0]instanceof AMap.LabelMarker}(e)){var n=e.map(function(e){return e.getExtData().id});this.overlayList=this.overlayList.filter(function(e){return!n.includes(e.id)}),this.rawLayerIns.remove(e)}else{a=e.map(function(e){return r.findLayerOverlay(e)}).filter(function(e){return!!e});this.rawLayerIns.remove(a),this.overlayList=this.overlayList.filter(function(r){return!e.includes(r.id)})}}},BaseMarkerLayer.prototype.refreshOverlayIcon=function(e){var r=this.overlayList.findIndex(function(r){return r.id===e});if(-1===r)return d.error("[BaseMarkerLayer Error]: Invalid overlayId ".concat(e));var t,a=BaseMarkerLayer.layerClassMap.get(this.layerType),n=this.rawLayerIns.findLayerOverlay(e),o=a.convertOverlayDataToOvlOpts(this.overlayList[r],r,this.getIconUrl,this.getOverlayOpts,d),i=this.getIconUrl(this.overlayList[r]);this.rawLayerIns instanceof p?("string"==typeof(t=o.icon)?t=i:t.setImage(i),this.rawLayerIns.refreshOverlayIcon(n,t)):((t=o.icon).image=i,this.rawLayerIns.refreshOverlayIcon(n,t))},BaseMarkerLayer.prototype.refreshOverlayLabel=function(e){var r=this.overlayList.findIndex(function(r){return r.id===e});if(-1===r)return d.error("[Layer Error]: Invalid overlayId ".concat(e));var t=BaseMarkerLayer.layerClassMap.get(this.layerType),a=this.rawLayerIns.findLayerOverlay(e),n=t.convertOverlayDataToOvlOpts(this.overlayList[r],r,this.getIconUrl,this.getOverlayOpts,d);this.rawLayerIns instanceof p?this.rawLayerIns.refreshOverlayLabel(a,n.label):this.rawLayerIns.refreshOverlayLabel(a,n.text)},BaseMarkerLayer.prototype.getRawLayer=function(){return this.rawLayerIns.rawLayer},BaseMarkerLayer.layerClassMap=new Map,BaseMarkerLayer}();c.registerLayer("markerLayer",p),c.registerLayer("labelMarkerLayer",l);const u=c;const f=function(){function MarkerClusterLayer(e,r,t){this.map=e,this.rawLayer=new AMap.MarkerCluster(e,r,t)}return MarkerClusterLayer.prototype.bindEventMarker=function(e,r){this.rawLayer.on(e,r)},MarkerClusterLayer.prototype.add=function(e){this.rawLayer.addData(e)},MarkerClusterLayer.prototype.remove=function(e){this.rawLayer.setData(e)},MarkerClusterLayer.prototype.hide=function(){this.rawLayer.setData([])},MarkerClusterLayer.prototype.show=function(e){this.rawLayer.setData(e)},MarkerClusterLayer.prototype.destroy=function(){this.rawLayer.setData([]),this.rawLayer.setMap(null),this.rawLayer=null},MarkerClusterLayer.prototype.clearAllOvl=function(){this.rawLayer.setData([])},MarkerClusterLayer}();var clusterMarkerLayer_assign=function(){return clusterMarkerLayer_assign=Object.assign||function(e){for(var r,t=1,a=arguments.length;t<a;t++)for(var n in r=arguments[t])Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);return e},clusterMarkerLayer_assign.apply(this,arguments)},clusterMarkerLayer_rest=function(e,r){var t={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&r.indexOf(a)<0&&(t[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(a=Object.getOwnPropertySymbols(e);n<a.length;n++)r.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(e,a[n])&&(t[a[n]]=e[a[n]])}return t},h=function(){function ClusterMarkerLayer(e,r){this.layerVisible=!0;var t=e.layerType,a=e.layerName,n=clusterMarkerLayer_rest(e,["layerType","layerName"]),o=ClusterMarkerLayer.layerClassMap.get(t);if(!o)throw new Error("[ClusterMarkerLayer Error]: Invalid layer type ".concat(t));var i=this.convertOverlayDataToClusterData(e.overlayList);this.rawLayerIns=new o(r.map,i,e.layerOpts),this.layerName=a,this.mapUtils=r,this.overlayList=e.overlayList,this.layerType=e.layerType,Object.assign(this,n)}
82
+ /**
83
+ * 注册图层类型与控制器类的关联
84
+ * @param {string} layerType - 图层类型
85
+ * @param {Function} layerClass - 图层控制器类
86
+ * @ignore
87
+ */return ClusterMarkerLayer.registerLayer=function(e,r){"string"==typeof e&&"function"==typeof r?ClusterMarkerLayer.layerClassMap.set(e,r):d.error("[ClusterMarkerLayer Error]: Invalid layer type or layer class")},
88
+ /**
89
+ * 将覆盖物数据转换为聚合标记所需的数据格式
90
+ * @param overlayList 覆盖物数据列表
91
+ * @returns 聚合标记数据列表
92
+ */
93
+ ClusterMarkerLayer.prototype.convertOverlayDataToClusterData=function(e){return e.map(function(e){return clusterMarkerLayer_assign(clusterMarkerLayer_assign({},e),{lnglat:[e.overlayData.lon,e.overlayData.lat],weight:e.overlayData.weight||1})})},ClusterMarkerLayer.prototype.bindEventOverlays=function(e,r){this.rawLayerIns.bindEventMarker(e,r)},ClusterMarkerLayer.prototype.hide=function(){this.layerVisible=!1,this.rawLayerIns.hide()},ClusterMarkerLayer.prototype.show=function(){this.layerVisible=!0;var e=this.convertOverlayDataToClusterData(this.overlayList);this.rawLayerIns.show(e)},ClusterMarkerLayer.prototype.destroy=function(){this.mapUtils.removeLayer(this),this.rawLayerIns.destroy(),this.overlayList=[]},ClusterMarkerLayer.prototype.clearAllOverlay=function(){this.overlayList=[],this.rawLayerIns.clearAllOvl()},ClusterMarkerLayer.prototype.add=function(e){var r,t=this.convertOverlayDataToClusterData(e);(r=this.overlayList).push.apply(r,e),this.rawLayerIns.add(t)},
94
+ /**
95
+ * `remove`
96
+ *
97
+ * @param {(Array<number | string>)} ovs
98
+ * @memberof ClusterMarkerLayer
99
+ */
100
+ ClusterMarkerLayer.prototype.remove=function(e){if(Array.isArray(e)){var r=e;this.overlayList=this.overlayList.filter(function(e){return!r.includes(e.id)});var t=this.convertOverlayDataToClusterData(this.overlayList);this.rawLayerIns.remove(t)}},ClusterMarkerLayer.prototype.getRawLayer=function(){return this.rawLayerIns.rawLayer},ClusterMarkerLayer.layerClassMap=new Map,ClusterMarkerLayer}();h.registerLayer("markerClusterLayer",f);const v=h;const L=function(){function LayerManager(){this.layers=new Map}return LayerManager.prototype.addLayer=function(e){if(this.hasLayer(e)){var r='Layer with name "'.concat(e.layerName,'" already exists');return d.error(r)}this.layers.set(e.layerName,e)},LayerManager.prototype.removeLayer=function(e){this.layers.delete(e.layerName)},LayerManager.prototype.show=function(e){var r=this.layers.get(e);if(!r){var t='Layer with name "'.concat(e,'" not found');return d.error(t)}r.show()},LayerManager.prototype.hide=function(e){var r=this.layers.get(e);if(!r){var t='Layer with name "'.concat(e,'" not found');return d.error(t)}r.hide()},LayerManager.prototype.showAll=function(){this.layers.forEach(function(e){return e.show()})},LayerManager.prototype.hideAll=function(){this.layers.forEach(function(e){return e.hide()})},LayerManager.prototype.reload=function(){this.layers.forEach(function(e){"function"==typeof e.reload&&e.reload()})},LayerManager.prototype.hasLayer=function(e){return this.layers.has(e.layerName)},LayerManager}();var MapUtils_awaiter=function(e,r,t,a){return new(t||(t=Promise))(function(n,o){function fulfilled(e){try{step(a.next(e))}catch(e){o(e)}}function rejected(e){try{step(a.throw(e))}catch(e){o(e)}}function step(e){var r;e.done?n(e.value):(r=e.value,r instanceof t?r:new t(function(e){e(r)})).then(fulfilled,rejected)}step((a=a.apply(e,r||[])).next())})},MapUtils_generator=function(e,r){var t,a,n,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=verb(0),i.throw=verb(1),i.return=verb(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function verb(s){return function(l){return function(s){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(o=0)),o;)try{if(t=1,a&&(n=2&s[0]?a.return:s[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,s[1])).done)return n;switch(a=0,n&&(s=[2&s[0],n.value]),s[0]){case 0:case 1:n=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,a=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(n=o.trys,(n=n.length>0&&n[n.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!n||s[1]>n[0]&&s[1]<n[3])){o.label=s[1];break}if(6===s[0]&&o.label<n[1]){o.label=n[1],n=s;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(s);break}n[2]&&o.ops.pop(),o.trys.pop();continue}s=r.call(e,o)}catch(e){s=[6,e],a=0}finally{t=n=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}},MapUtils_rest=function(e,r){var t={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&r.indexOf(a)<0&&(t[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(a=Object.getOwnPropertySymbols(e);n<a.length;n++)r.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(e,a[n])&&(t[a[n]]=e[a[n]])}return t},d=function(){function MapUtils(e,r){if(this.LayerManager=new L,"object"!=typeof r||!("Map"in r))throw MapUtils.error("AMap is not exist");if("mapIns"in e&&e.mapIns instanceof r.Map){e.mapIns;var t=MapUtils_rest(e,["mapIns"]);this.map=e.mapIns,this.options=t}else{if(!("mountSelector"in e))throw MapUtils.error("mountSelector is not exist");this.options=e;var a=e.mountSelector;t=MapUtils_rest(e,["mountSelector"]);this.map=this.initMap(a,t)}}
101
+ /**
102
+ * @param {AMap.EventType} type 地图事件类型
103
+ * @param {(e: any) => void} fn 回调函数
104
+ * @param {*} [context] 事件上下文,缺省为当前实例
105
+ * @param {boolean} [once] 事件是否执行一次
106
+ * @memberof MapUtils
107
+ */return MapUtils.prototype.bindMapClickEvent=function(e,r,t,a){this.map.on(e,r,t,a)},MapUtils.prototype.initMap=function(e,r){return new window.AMap.Map(e,r)},MapUtils.prototype.createBaseMarkerLayer=function(e){var r=new u(e,this);return this.LayerManager.addLayer(r),r},
108
+ /**
109
+ * 高德地图中 `MarkerCluster, MassMarks`用于渲染海量点,它们调用方式也比较接近,将其聚合为一个统一的图层管理
110
+ * 目前, 聚合图层只包装`MarkerCluster`
111
+ * @param {ClusterMarkerLayerOpts<U, T>} opts - 图层配置选项
112
+ */
113
+ MapUtils.prototype.createClusterMarkerLayer=function(e){var r=new v(e,this);return this.LayerManager.addLayer(r),r},
114
+ /**
115
+ * `removeLayer`接收图层实例将其从mapUtils的关联中移除
116
+ * @param {(BaseMarkerLayerIns | ClusterMarkerLayerIns)} layer
117
+ */
118
+ MapUtils.prototype.removeLayer=function(e){this.LayerManager.hasLayer(e)?this.LayerManager.removeLayer(e):MapUtils.error("".concat(e.layerName," is not exist"))},
119
+ /**
120
+ * 根据地图上添加的覆盖物分布情况,自动缩放地图到合适的视野级别
121
+ * @param {Array} overlays - 覆盖物数组,缺省为全部覆盖物
122
+ * @param {Boolean} immediately - 是否立即过渡
123
+ * @param {Array<Number>} avoid - 四周边距,上、下、左、右
124
+ * @param {number} maxZoom - 最大地图zoom级别
125
+ */
126
+ MapUtils.prototype.setFitView=function(){for(var e,r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];(e=this.map).setFitView.apply(e,r)},MapUtils.prototype.clearInfoWindow=function(){this.map.clearInfoWindow()},
127
+ /**
128
+ * 地图跳转参数
129
+ * @typedef {Object} GotoOpts
130
+ * @property {number} zoom - 目标缩放级别
131
+ * @property {AMap.LngLat|[number,number]} center - 目标中心点(高德坐标实例或 [lng,lat] 数组)
132
+ * @property {boolean} [immediately=false] - 是否立即跳转,默认平滑过渡
133
+ * @property {number} [duration] - 过渡动画时长(毫秒)
134
+ */
135
+ /**
136
+ * 将地图视图切换到指定状态
137
+ * @param {GotoOpts} opts 跳转配置
138
+ */
139
+ MapUtils.prototype.seZoomAndCenter=function(e){var r=this.map.getZoom(),t=this.map.getCenter(),a=[t.lng,t.lat],n=e.center,o=void 0===n?a:n,i=e.zoom,s=void 0===i?r:i,l=e.immediately,y=e.duration;this.map.setZoomAndCenter(s,o,l,y)},
140
+ /**
141
+ * 图层`layerName`显示, `layerName`为创建图层所传递的参数,用于标识图层名称。
142
+ * @param {string} layerName - 图层名称
143
+ */
144
+ MapUtils.prototype.showLayer=function(e){this.LayerManager.show(e)},
145
+ /**
146
+ * 图层`layerName`隐藏, `layerName`为创建图层所传递的参数,用于标识图层名称。
147
+ * @param {string} layerName - 图层名称
148
+ */
149
+ MapUtils.prototype.hideLayer=function(e){this.LayerManager.hide(e)},MapUtils.prototype.showAllLayers=function(){this.LayerManager.showAll()},MapUtils.prototype.hideAllLayers=function(){this.LayerManager.hideAll()},MapUtils.prototype.reloadLayers=function(){this.LayerManager.reload()},
150
+ /**
151
+ * @ignore
152
+ * @param msg
153
+ */
154
+ MapUtils.error=function(e){console.error("[MapUtils Error]:".concat(e))},MapUtils.createAMapMarker=s.createAMapMarker,MapUtils.createIcon=s.createIcon,MapUtils.Size=s.Size,MapUtils.Pixel=s.Pixel,MapUtils.LngLat=s.LngLat,MapUtils.createAMapInfoWindow=s.createAMapInfoWindow,MapUtils.createAMapPolyline=s.createAMapPolyline,MapUtils.loadPlugins=s.loadPlugins,MapUtils}();
155
+ /**
156
+ *
157
+ * `createMapUtils`功能如下:
158
+ * 1. 支持将高德地图实例包装成工具函数 (为其扩展功能),
159
+ * 2. 地图创建并为其扩展功能,
160
+ * 3. 高德地图依赖加载 ( 高德AMap函数加载 )
161
+ * @param {MapUtilsOpts[keyof MapUtilsOpts]} opts
162
+ * - 工具函数配置选项,支持两种模式:
163
+ * 1. 使用现有地图实例(MapUtilsUseExistingOpts)
164
+ * 2. 创建新地图实例(MapUtilsCreateOpts)
165
+ *
166
+ * [MapOptions文档地址](https://lbs.amap.com/api/javascript-api-v2/documentation#map)
167
+ * ```
168
+ * interface MapUtilsCreateOpts extends MapOptions {
169
+ mountSelector: string; //选择器
170
+ }
171
+
172
+ interface MapUtilsUseExistingOpts extends MapOptions {
173
+ mapIns: mapIns; //高德地图实例
174
+ }
175
+ * ```
176
+ * @param {loaderOpts} [loaderOPts]
177
+ * - 高德地图环境加载所传递的配置对象
178
+ * ```
179
+ * type loaderOpts = {
180
+ key: string;
181
+ version: string;
182
+ plugins?: string[] | undefined;
183
+ AMapUI?: {
184
+ version?: string | undefined;
185
+ plugins?: string[] | undefined;
186
+ } | undefined;
187
+ Loca?: {
188
+ version?: string | undefined;
189
+ } | undefined;
190
+ }
191
+ * ```
192
+ * @return {*}
193
+ */
194
+ function createMapUtils(e,r){return MapUtils_awaiter(this,void 0,void 0,function(){var t;return MapUtils_generator(this,function(a){switch(a.label){case 0:return t=window.AMap,r?[4,initMapSource(r)]:[3,2];case 1:t=a.sent(),a.label=2;case 2:return[2,new d(e,t)]}})})}
195
+ /**
196
+ *
197
+ * @param {loaderOpts} Opts
198
+ * - 高德地图环境加载所传递的配置对象
199
+ * ```
200
+ * type loaderOpts = {
201
+ key: string;
202
+ version: string;
203
+ plugins?: string[] | undefined;
204
+ AMapUI?: {
205
+ version?: string | undefined;
206
+ plugins?: string[] | undefined;
207
+ } | undefined;
208
+ Loca?: {
209
+ version?: string | undefined;
210
+ } | undefined;
211
+ }
212
+ * ```
213
+ * @return {*}
214
+ */function initMapSource(e){return MapUtils_awaiter(this,void 0,void 0,function(){return MapUtils_generator(this,function(r){switch(r.label){case 0:return[4,i.loadScript(e)];case 1:return[2,r.sent()]}})})}return a})());
2
215
  //# sourceMappingURL=index.js.map