|
| 1 | +(function () { |
| 2 | + var r = new RegExp("(^|(.*?\\/))(include-leaflet-local\.js)(\\?|$)"), |
| 3 | + s = document.getElementsByTagName('script'), |
| 4 | + targetScript, targetUrl; |
| 5 | + for (var i = 0; i < s.length; i++) { |
| 6 | + var src = s[i].getAttribute('src'); |
| 7 | + if (src) { |
| 8 | + var m = src.match(r); |
| 9 | + if (m) { |
| 10 | + targetUrl = src; |
| 11 | + targetScript = s[i]; |
| 12 | + break; |
| 13 | + } |
| 14 | + } |
| 15 | + } |
| 16 | + |
| 17 | + function inputScript(url) { |
| 18 | + var script = '<script type="text/javascript" src="' + url + '"><' + '/script>'; |
| 19 | + document.writeln(script); |
| 20 | + } |
| 21 | + |
| 22 | + function inputCSS(url) { |
| 23 | + var css = '<link rel="stylesheet" href="' + url + '">'; |
| 24 | + document.writeln(css); |
| 25 | + } |
| 26 | + |
| 27 | + function inArray(arr, item) { |
| 28 | + for (i in arr) { |
| 29 | + if (arr[i].toLowerCase() == item) { |
| 30 | + return true; |
| 31 | + } |
| 32 | + } |
| 33 | + return false; |
| 34 | + } |
| 35 | + |
| 36 | + function getInitPath() { |
| 37 | + //"./static/libs/include-leaflet-local-local.js" ==> "./static/libs/" |
| 38 | + var loadPath = targetUrl.split("/include-leaflet-local"); |
| 39 | + return loadPath[0]; |
| 40 | + } |
| 41 | + |
| 42 | + //comman leaflet librarys |
| 43 | + function load() { |
| 44 | + |
| 45 | + var includes = (targetScript.getAttribute('include') || "").split(","); |
| 46 | + var excludes = (targetScript.getAttribute('exclude') || "").split(","); |
| 47 | + |
| 48 | + var httpUrl = getInitPath(); |
| 49 | + |
| 50 | + if (!inArray(excludes, 'leaflet')) { |
| 51 | + inputCSS(httpUrl + "/cdn/leaflet/leaflet.css"); |
| 52 | + inputScript(httpUrl + "/cdn/leaflet/leaflet.js"); |
| 53 | + } |
| 54 | + if (inArray(includes, 'json')) { |
| 55 | + inputScript(httpUrl + "/cdn/json/jsonExtend.js"); |
| 56 | + } |
| 57 | + if (inArray(includes, 'proj4')) { |
| 58 | + inputScript(httpUrl + "/cdn/proj4/proj4.js"); |
| 59 | + inputScript(httpUrl + "/cdn/leaflet-plugins/Proj4Leaflet/lib/proj4-compressed.js"); |
| 60 | + inputScript(httpUrl + "/cdn/leaflet-plugins/Proj4Leaflet/src/proj4leaflet.js"); |
| 61 | + } |
| 62 | + if (inArray(includes, 'd3')) { |
| 63 | + inputScript(httpUrl + "/cdn/d3/d3.min.js"); |
| 64 | + inputScript(httpUrl + "/cdn/d3/d3-hexbin.min.js"); |
| 65 | + inputScript(httpUrl + "/cdn/d3/d3layer.js"); |
| 66 | + } |
| 67 | + if (inArray(includes, 'mapv')) { |
| 68 | + inputScript(httpUrl + "/cdn/mapv/mapv.min.js"); |
| 69 | + } |
| 70 | + if (inArray(includes, 'echarts')) { |
| 71 | + inputScript(httpUrl + "/cdn/echarts/echarts.min.js"); |
| 72 | + inputScript(httpUrl + "/cdn/echarts/echartsgl.min.js"); |
| 73 | + } |
| 74 | + if (inArray(includes, 'vectortile')) { |
| 75 | + // inputScript(httpUrl + "/cdn/leaflet-plugins/Leaflet-VectorGrid/dist/Leaflet.VectorGrid.min.js"); |
| 76 | + inputCSS(httpUrl + "/cdn/mapboxgl/mapbox-gl.css"); |
| 77 | + inputScript(httpUrl + "/cdn/mapboxgl/mapbox-gl.js"); |
| 78 | + inputScript(httpUrl + "/cdn/leaflet-plugins/mapbox-gl-leaflet/leaflet-mapbox-gl.js"); |
| 79 | + } |
| 80 | + if (inArray(includes, 'mvt')) { |
| 81 | + inputCSS(httpUrl + "/cdn/leaflet-plugins/leaflet-mapbox/mapbox-gl.css"); |
| 82 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-mapbox/mapbox-gl.js"); |
| 83 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-mapbox/leaflet-mapbox-gl.js"); |
| 84 | + } |
| 85 | + if (inArray(includes, 'cluster')) { |
| 86 | + inputCSS(httpUrl + "/cdn/leaflet-plugins/Leaflet.markercluster-1.4.1/dist/MarkerCluster.css"); |
| 87 | + inputCSS(httpUrl + "/cdn/leaflet-plugins/Leaflet.markercluster-1.4.1/dist/MarkerCluster.Default.css"); |
| 88 | + inputScript(httpUrl + "/cdn/leaflet-plugins/Leaflet.markercluster-1.4.1/dist/leaflet.markercluster.js"); |
| 89 | + } |
| 90 | + if (inArray(includes, 'colors-marker')) { |
| 91 | + inputCSS(httpUrl + "/cdn/leaflet-plugins/Leaflet.awesome-markers/examples/css/font-awesome.min.css"); |
| 92 | + inputCSS(httpUrl + "/cdn/leaflet-plugins/Leaflet.awesome-markers/dist/leaflet.awesome-markers.css"); |
| 93 | + inputScript(httpUrl + "/cdn/leaflet-plugins/Leaflet.awesome-markers/dist/leaflet.awesome-markers.js"); |
| 94 | + } |
| 95 | + if (inArray(includes, 'heater')) { |
| 96 | + inputScript(httpUrl + "/cdn/leaflet-plugins/Leaflet.heat/dist/leaflet-heat.js"); |
| 97 | + inputScript(httpUrl + "/cdn/leaflet-plugins/heatmapjs/heatmap.min.js"); |
| 98 | + inputScript(httpUrl + "/cdn/leaflet-plugins/heatmapjs/leaflet-heatmap.js"); |
| 99 | + } |
| 100 | + if (inArray(includes, 'animate-marker')) { |
| 101 | + inputScript(httpUrl + "/cdn/leaflet-plugins/Leaflet.AnimatedMarker/src/AnimatedMarker.js"); |
| 102 | + |
| 103 | + } |
| 104 | + if (inArray(includes, 'realmove-marker')) { |
| 105 | + inputScript(httpUrl + "/cdn/leaflet-plugins/Leaflet.MovingMarker/MovingMarker.js"); |
| 106 | + } |
| 107 | + if (inArray(includes, 'elasticsearch')) { |
| 108 | + inputScript(httpUrl + "/cdn/elasticsearch/14.1.0/elasticsearch.min.js"); |
| 109 | + } |
| 110 | + if (inArray(includes, 'ant-path')) { |
| 111 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-ant-path/dist/leaflet-ant-path.js"); |
| 112 | + } |
| 113 | + if (inArray(includes, 'migrate')) { |
| 114 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet.MigrationLayer/dist/leaflet.migrationLayer.js"); |
| 115 | + } |
| 116 | + if (inArray(includes, 'elasticsearch')) { |
| 117 | + inputScript(httpUrl + "/cdn/elasticsearch/14.1.0/elasticsearch.min.js"); |
| 118 | + } |
| 119 | + if (inArray(includes, 'els-mapgis')) { |
| 120 | + inputScript(httpUrl + "/cdn/zondyclient/els-mapgis.js"); |
| 121 | + } |
| 122 | + if (inArray(includes, 'geohash')) { |
| 123 | + inputScript(httpUrl + "/cdn/geohash/geohash.js"); |
| 124 | + } |
| 125 | + if (inArray(includes, 'geojson')) { |
| 126 | + inputScript(httpUrl + "/cdn/geojson/geojson.min.js"); |
| 127 | + inputScript(httpUrl + "/cdn/geojson/topojson.min.js"); |
| 128 | + } |
| 129 | + if (inArray(includes, 'shapefile')) { |
| 130 | + inputScript(httpUrl + "/cdn/shapefile/shapefile.js"); |
| 131 | + } |
| 132 | + if (inArray(includes, 'turf')) { |
| 133 | + inputScript(httpUrl + "/cdn/turf/turf.min.js"); |
| 134 | + } |
| 135 | + if (inArray(includes, 'measure')) { |
| 136 | + inputCSS(httpUrl + "/cdn/leaflet-plugins/leaflet-measure/leaflet-measure.css"); |
| 137 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-measure/leaflet-measure.js"); |
| 138 | + } |
| 139 | + if (inArray(includes, 'measurement')) { |
| 140 | + inputCSS(httpUrl + "/cdn/leaflet-plugins/leaflet-measurement/leaflet-ruler.css"); |
| 141 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-measurement/leaflet-ruler.js"); |
| 142 | + } |
| 143 | + if (inArray(includes, 'editable')) { |
| 144 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Editable/Leaflet.Editable.js"); |
| 145 | + } |
| 146 | + if (inArray(includes, 'wfs')) { |
| 147 | + inputScript(httpUrl + "/cdn/leaflet-plugins/Leaflet-WFST/dist/leaflet-wfst.src.js"); |
| 148 | + } |
| 149 | + if (inArray(includes, 'draw')) { |
| 150 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/Leaflet.draw.js"); |
| 151 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/Leaflet.Draw.Event.js"); |
| 152 | + inputCSS(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/leaflet.draw.css"); |
| 153 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/Toolbar.js"); |
| 154 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/Tooltip.js"); |
| 155 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/GeometryUtil.js"); |
| 156 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/LatLngUtil.js"); |
| 157 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/LineUtil.Intersect.js"); |
| 158 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/Polygon.Intersect.js"); |
| 159 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/Polyline.Intersect.js"); |
| 160 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/TouchEvents.js"); |
| 161 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/DrawToolbar.js"); |
| 162 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/Draw.Feature.js"); |
| 163 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/Draw.SimpleShape.js"); |
| 164 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/Draw.Polyline.js"); |
| 165 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/Draw.Marker.js"); |
| 166 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/Draw.Circle.js"); |
| 167 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/Draw.CircleMarker.js"); |
| 168 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/Draw.Polygon.js"); |
| 169 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/Draw.Rectangle.js"); |
| 170 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/EditToolbar.js"); |
| 171 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/EditToolbar.Edit.js"); |
| 172 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/EditToolbar.Delete.js"); |
| 173 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/Control.Draw.js"); |
| 174 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/Edit.Poly.js"); |
| 175 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/Edit.SimpleShape.js"); |
| 176 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/Edit.Rectangle.js"); |
| 177 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/Edit.Marker.js"); |
| 178 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/Edit.CircleMarker.js"); |
| 179 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Draw/Edit.Circle.js"); |
| 180 | + } |
| 181 | + if (inArray(includes, 'toolbar')) { |
| 182 | + //inputCSS(httpUrl + "/cdn/leaflet-plugins/leaflet-Toolbar/bootstrap.min.css"); |
| 183 | + inputCSS(httpUrl + "/cdn/leaflet-plugins/leaflet-Toolbar/bootstrap-theme.min.css"); |
| 184 | + inputCSS(httpUrl + "/cdn/leaflet-plugins/leaflet-Toolbar/leaflet.draw.css"); |
| 185 | + inputCSS(httpUrl + "/cdn/leaflet-plugins/leaflet-Toolbar/leaflet.toolbar.css"); |
| 186 | + inputCSS(httpUrl + "/cdn/leaflet-plugins/leaflet-Toolbar/leaflet.draw-toolbar.css"); |
| 187 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Toolbar/leaflet.toolbar-src.js"); |
| 188 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Toolbar/leaflet.draw-src.js"); |
| 189 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Toolbar/leaflet.draw-toolbar.js"); |
| 190 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Toolbar/ColorPicker.js"); |
| 191 | + } |
| 192 | + if (inArray(includes, 'fullscreen')) { |
| 193 | + inputCSS(httpUrl + "/cdn/leaflet-plugins/leaflet-fullscreen/leaflet.fullscreen.css"); |
| 194 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-fullscreen/Leaflet.fullscreen.js"); |
| 195 | + } |
| 196 | + if (inArray(includes, 'mouseposition')) { |
| 197 | + inputCSS(httpUrl + "/cdn/leaflet-plugins/Leaflet.MousePosition/src/L.Control.MousePosition.css"); |
| 198 | + inputScript(httpUrl + "/cdn/leaflet-plugins/Leaflet.MousePosition/src/L.Control.MousePosition.js"); |
| 199 | + } |
| 200 | + if (inArray(includes, 'minimap')) { |
| 201 | + inputCSS(httpUrl + "/cdn/leaflet-plugins/Leaflet-MiniMap/dist/Control.MiniMap.min.css"); |
| 202 | + inputScript(httpUrl + "/cdn/leaflet-plugins/Leaflet-MiniMap/dist/Control.MiniMap.min.js"); |
| 203 | + } |
| 204 | + if (inArray(includes, 'iconglyph')) { |
| 205 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-IconGlyph/Leaflet.Icon.Glyph.js"); |
| 206 | + } |
| 207 | + |
| 208 | + if (inArray(includes, 'pathdrag')) { |
| 209 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-PathDrag/Path.Drag.js"); |
| 210 | + } |
| 211 | + if (inArray(includes, 'graticule')) { |
| 212 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-Graticule/Leaflet.Graticule.js"); |
| 213 | + } |
| 214 | + if (inArray(includes, 'export')) { |
| 215 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet_outmap/bundle.js"); |
| 216 | + } |
| 217 | + if (inArray(includes, 'china')) { |
| 218 | + inputScript(httpUrl + "/cdn/leaflet-plugins/Leaflet.ChineseTmsProviders/src/leaflet.ChineseTmsProviders.js"); |
| 219 | + } |
| 220 | + if (inArray(includes, 'magnifying')) { |
| 221 | + inputCSS(httpUrl + "/cdn/leaflet-plugins/Leaflet.MagnifyingGlass/leaflet.magnifyingglass.css"); |
| 222 | + inputScript(httpUrl + "/cdn/leaflet-plugins/Leaflet.MagnifyingGlass/leaflet.magnifyingglass.js"); |
| 223 | + } |
| 224 | + if (inArray(includes, 'opacity')) { |
| 225 | + inputCSS(httpUrl + "/cdn/leaflet-plugins/Leaflet.OpacityControls/lib/opacity/Control.Opacity.css"); |
| 226 | + inputScript(httpUrl + "/cdn/leaflet-plugins/Leaflet.OpacityControls/lib/opacity/Control.Opacity.js"); |
| 227 | + inputCSS(httpUrl + "/cdn/leaflet-plugins/Leaflet.OpacityControls/lib/jquery/jquery-ui-1.10.3.custom.min.css"); |
| 228 | + inputScript(httpUrl + "/cdn/leaflet-plugins/Leaflet.OpacityControls/lib/jquery/jquery-1.9.1.js"); |
| 229 | + inputScript(httpUrl + "/cdn/leaflet-plugins/Leaflet.OpacityControls/lib/jquery/jquery-ui-1.10.3.custom.min.js"); |
| 230 | + } |
| 231 | + if (inArray(includes, 'arrow')) { |
| 232 | + inputScript(httpUrl + "/cdn/leaflet-plugins/Leaflet.PolylineDecorator/dist/leaflet.polylineDecorator.js"); |
| 233 | + } |
| 234 | + if (inArray(includes, 'snake')) { |
| 235 | + inputScript(httpUrl + "/cdn/leaflet-plugins/Leaflet.Polyline.SnakeAnim/L.Polyline.SnakeAnim.js"); |
| 236 | + } |
| 237 | + if (inArray(includes, 'iconpulse')) { |
| 238 | + inputCSS(httpUrl + "/cdn/leaflet-plugins/leaflet-icon-pulse/src/L.Icon.Pulse.css"); |
| 239 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-icon-pulse/src/L.Icon.Pulse.js"); |
| 240 | + } |
| 241 | + if (inArray(includes, 'picture')) { |
| 242 | + inputScript(httpUrl + "/cdn/filesaver/dist/FileSaver.min.js"); |
| 243 | + } |
| 244 | + if (inArray(includes, 'pdf')) { |
| 245 | + inputScript(httpUrl + "/cdn/jspdf/dist/jspdf.min.js"); |
| 246 | + } |
| 247 | + if (inArray(includes, 'bing')) { |
| 248 | + inputScript(httpUrl + "/cdn/leaflet-plugins/leaflet-bing-layer/leaflet-bing-layer.min.js"); |
| 249 | + } |
| 250 | + if (inArray(includes, 'timedimension')) { |
| 251 | + inputCSS(httpUrl + "/cdn/leaflet-plugins/Leaflet.TimeDimension/dist/leaflet.timedimension.control.css"); |
| 252 | + } |
| 253 | + if (!inArray(excludes, 'plugin')) { |
| 254 | + inputScript(httpUrl + "/cdn/zondyclient/webclient-leaflet-plugin.min.js"); |
| 255 | + } |
| 256 | + } |
| 257 | + |
| 258 | + load(); |
| 259 | + window.webclient = { |
| 260 | + ip: "develop.smaryun.com", |
| 261 | + port: 6163, |
| 262 | + protocol: "http", |
| 263 | + }; |
| 264 | + window.isLocal = false; |
| 265 | + window.server = document.location.toString().match(/file:\/\//) ? "http://localhost:8899" : 'http://' + document.location.host; |
| 266 | +})(); |
0 commit comments