|
| 1 | +(function() { |
| 2 | + var r = new RegExp("(^|(.*?\\/))(mbgl-include\.js)(\\?|$)"), |
| 3 | + s = document.getElementsByTagName('script'), targetScript; |
| 4 | + for(var i=0;i<s.length; i++) { |
| 5 | + var src = s[i].getAttribute('src'); |
| 6 | + if(src) { |
| 7 | + var m = src.match(r); |
| 8 | + if(m) { |
| 9 | + targetScript =s[i]; |
| 10 | + break; |
| 11 | + } |
| 12 | + } |
| 13 | + } |
| 14 | + function inputScript(url){ |
| 15 | + var script = '<script type="text/javascript" src="' + url + '"><' + '/script>'; |
| 16 | + document.writeln(script); |
| 17 | + } |
| 18 | + function inputCSS(url){ |
| 19 | + var css = '<link rel="stylesheet" href="' + url + '">'; |
| 20 | + document.writeln(css); |
| 21 | + } |
| 22 | + Array.prototype.contains = function ( needle ) { |
| 23 | + for (i in this) { |
| 24 | + if (this[i] == needle){ |
| 25 | + return true; |
| 26 | + } |
| 27 | + } |
| 28 | + return false; |
| 29 | + } |
| 30 | + //加载类库资源文件 |
| 31 | + function load() { |
| 32 | + var includes=(targetScript.getAttribute('include')||"").split(","); |
| 33 | + var excludes=(targetScript.getAttribute('exclude')||"").split(","); |
| 34 | + if(!excludes.contains('mapbox-gl')) { |
| 35 | + inputCSS("https://cdn.bootcss.com/mapbox-gl/0.39.1/mapbox-gl.css"); |
| 36 | + inputScript("https://cdn.bootcss.com/mapbox-gl/0.39.1/mapbox-gl.js"); |
| 37 | + } |
| 38 | + if(includes.contains('mapv')){ |
| 39 | + inputScript("http://mapv.baidu.com/build/mapv.min.js"); |
| 40 | + } |
| 41 | + if(!excludes.contains('iclient9-mapboxgl')) { |
| 42 | + inputScript("../../dist/iclient9-mapboxgl.min.js"); |
| 43 | + } |
| 44 | + if(includes.contains('echarts')){ |
| 45 | + inputScript("http://cdn.bootcss.com/echarts/3.6.2/echarts.min.js"); |
| 46 | + inputScript("http://iclient.supermapol.com/libs/echartsLayer/EchartsLayer.js"); |
| 47 | + } |
| 48 | + if(includes.contains('proj4')){ |
| 49 | + inputScript("https://cdn.bootcss.com/proj4js/2.4.3/proj4.js"); |
| 50 | + } |
| 51 | + } |
| 52 | + load(); |
| 53 | +})(); |
0 commit comments