Leaflet/debug/leaflet-include.js

118 lines
3.0 KiB
JavaScript
Raw Normal View History

2010-12-15 23:14:59 +08:00
(function() {
//TODO replace script list with the one from ../buid/deps.js
2010-12-15 23:14:59 +08:00
var scripts = [
'Leaflet.js',
'core/Util.js',
'core/Class.js',
'core/Events.js',
'core/Browser.js',
2010-12-16 00:41:35 +08:00
'geometry/Point.js',
'geometry/Bounds.js',
'geometry/Transformation.js',
2011-02-26 01:01:29 +08:00
'geometry/LineUtil.js',
2011-03-01 23:41:33 +08:00
'geometry/PolyUtil.js',
2010-12-16 00:41:35 +08:00
2010-12-15 23:14:59 +08:00
'dom/DomEvent.js',
'dom/DomEvent.DoubleTap.js',
2010-12-15 23:14:59 +08:00
'dom/DomUtil.js',
'dom/Draggable.js',
'dom/transition/Transition.js',
'dom/transition/Transition.Native.js',
'dom/transition/Transition.Timer.js',
'geo/LatLng.js',
'geo/LatLngBounds.js',
'geo/projection/Projection.js',
'geo/projection/Projection.SphericalMercator.js',
'geo/projection/Projection.LonLat.js',
'geo/projection/Projection.Mercator.js',
'geo/crs/CRS.js',
'geo/crs/CRS.EPSG3857.js',
'geo/crs/CRS.EPSG4326.js',
'geo/crs/CRS.EPSG3395.js',
2010-12-15 23:14:59 +08:00
'layer/LayerGroup.js',
'layer/FeatureGroup.js',
2011-05-28 01:20:54 +08:00
'layer/tile/TileLayer.js',
'layer/tile/TileLayer.WMS.js',
'layer/tile/TileLayer.Canvas.js',
2010-12-15 23:14:59 +08:00
'layer/ImageOverlay.js',
2010-12-16 01:55:57 +08:00
'layer/Popup.js',
2011-02-26 01:01:29 +08:00
2011-01-21 17:55:08 +08:00
'layer/marker/Icon.js',
'layer/marker/Marker.js',
'layer/marker/Marker.Popup.js',
2010-12-15 23:14:59 +08:00
2011-02-26 01:01:29 +08:00
'layer/vector/Path.js',
2011-06-21 22:58:26 +08:00
'layer/vector/Path.Popup.js',
'layer/vector/Path.SVG.js',
'layer/vector/Path.VML.js',
'layer/vector/canvas/Path.Canvas.js',
2011-02-26 01:01:29 +08:00
'layer/vector/Polyline.js',
'layer/vector/canvas/Polyline.Canvas.js',
2011-03-01 16:26:42 +08:00
'layer/vector/Polygon.js',
'layer/vector/canvas/Polygon.Canvas.js',
'layer/vector/MultiPoly.js',
2011-03-01 23:41:33 +08:00
'layer/vector/Circle.js',
'layer/vector/canvas/Circle.Canvas.js',
'layer/vector/CircleMarker.js',
2011-02-26 01:01:29 +08:00
2011-06-10 19:26:16 +08:00
'layer/GeoJSON.js',
2010-12-15 23:14:59 +08:00
'handler/Handler.js',
'handler/MapDrag.js',
'handler/TouchZoom.js',
'handler/DoubleClickZoom.js',
'handler/ScrollWheelZoom.js',
2011-03-22 01:09:43 +08:00
'handler/ShiftDragZoom.js',
'handler/MarkerDrag.js',
2010-12-15 23:14:59 +08:00
'control/Control.js',
'control/Control.Zoom.js',
'control/Control.Attribution.js',
2011-07-13 01:19:29 +08:00
'control/Control.Layers.js',
2010-12-15 23:14:59 +08:00
'map/Map.js',
2011-01-21 17:55:08 +08:00
'map/ext/Map.Geolocation.js',
'map/ext/Map.Popup.js',
'map/ext/Map.PanAnimation.js',
'map/ext/Map.ZoomAnimation.js',
'map/ext/Map.Control.js'
2010-12-15 23:14:59 +08:00
];
2011-06-02 22:07:56 +08:00
function getSrcUrl() {
var scripts = document.getElementsByTagName('script');
for (var i = 0; i < scripts.length; i++) {
var src = scripts[i].src;
if (src) {
var res = src.match(/^(.*)leaflet-include\.js$/);
if (res) {
2011-06-02 22:07:56 +08:00
return res[1] + '../src/';
}
}
}
}
var path = getSrcUrl();
2010-12-15 23:14:59 +08:00
for (var i = 0; i < scripts.length; i++) {
document.writeln("<script type='text/javascript' src='" + path + "../src/" + scripts[i] + "'></script>");
2010-12-15 23:14:59 +08:00
}
})();
2011-08-11 19:30:46 +08:00
function getRandomLatLng(map) {
var bounds = map.getBounds(),
southWest = bounds.getSouthWest(),
northEast = bounds.getNorthEast(),
lngSpan = northEast.lng - southWest.lng,
latSpan = northEast.lat - southWest.lat;
return new L.LatLng(
southWest.lat + latSpan * Math.random(),
southWest.lng + lngSpan * Math.random());
}