|
123456789101112131415161718192021222324252627282930313233343536373839 |
- export default function MapLoader(isSyncLoad = false, pluginsArr = []) {
-
- return new Promise((resolve, reject) => {
- try {
- if (window.AMap && (pluginsArr === null || pluginsArr === undefined || pluginsArr.length === 0)) {
- resolve(window.AMap);
- } else {
- var script = document.createElement('script');
- script.type = 'text/javascript';
- script.async = !isSyncLoad;
- script.src =
- 'https://webapi.amap.com/maps?v=1.4.15&callback=initAMap&key=' +
- '6e4a6c39ea6d18b8dd3151baa3a7c0d5' +
- '&plugin=AMap.BezierCurveEditor' +
- (pluginsArr ? ',' + pluginsArr.join(',') : '');
- script.onerror = reject;
- document.head.appendChild(script);
-
- var script1 = document.createElement('script');
- script1.type = 'text/javascript';
- script1.async = false;
- script1.src = 'https://webapi.amap.com/ui/1.0/main.js?v=1.0.11';
- script1.onerror = reject;
- if (isSyncLoad) {
- document.head.appendChild(script1);
- }
- }
- window.initAMap = () => {
- resolve(window.AMap);
- };
-
- window._AMapSecurityConfig = {
- securityJsCode: '6a421e1233cd12dd4899e373e11bb641'
- };
- } catch (e) {
- console.log(e);
- }
- });
- }
|