leaflet-js 0.6.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/CHANGELOG.rdoc +32 -0
- data/LICENSE +21 -0
- data/README.rdoc +54 -0
- data/Rakefile +15 -0
- data/leaflet-js.gemspec +28 -0
- data/lib/leaflet-js.rb +10 -0
- data/lib/leaflet.draw/BREAKINGCHANGES.md +54 -0
- data/lib/leaflet.draw/CHANGELOG.md +73 -0
- data/lib/leaflet.draw/Jakefile.js +26 -0
- data/lib/leaflet.draw/MIT-LICENCE.txt +20 -0
- data/lib/leaflet.draw/README.md +364 -0
- data/lib/leaflet.draw/TODO.md +62 -0
- data/lib/leaflet.draw/build/build.html +243 -0
- data/lib/leaflet.draw/build/build.js +189 -0
- data/lib/leaflet.draw/build/deps.js +75 -0
- data/lib/leaflet.draw/build/hintrc.js +47 -0
- data/lib/leaflet.draw/build/leaflet.draw-include.js +42 -0
- data/lib/leaflet.draw/dist/images/spritesheet.png +0 -0
- data/lib/leaflet.draw/dist/leaflet.draw-src.js +2429 -0
- data/lib/leaflet.draw/dist/leaflet.draw.css +212 -0
- data/lib/leaflet.draw/dist/leaflet.draw.ie.css +44 -0
- data/lib/leaflet.draw/dist/leaflet.draw.js +10 -0
- data/lib/leaflet.draw/examples/basic.html +106 -0
- data/lib/leaflet.draw/examples/edithandlers.html +67 -0
- data/lib/leaflet.draw/examples/libs/images/layers.png +0 -0
- data/lib/leaflet.draw/examples/libs/images/marker-icon.png +0 -0
- data/lib/leaflet.draw/examples/libs/images/marker-icon@2x.png +0 -0
- data/lib/leaflet.draw/examples/libs/images/marker-shadow.png +0 -0
- data/lib/leaflet.draw/examples/libs/leaflet-src.js +8587 -0
- data/lib/leaflet.draw/examples/libs/leaflet.css +459 -0
- data/lib/leaflet.draw/examples/libs/leaflet.ie.css +51 -0
- data/lib/leaflet.draw/package.json +37 -0
- data/lib/leaflet.draw/spec/after.js +2 -0
- data/lib/leaflet.draw/spec/before.js +3 -0
- data/lib/leaflet.draw/spec/expect.js +1253 -0
- data/lib/leaflet.draw/spec/happen.js +93 -0
- data/lib/leaflet.draw/spec/index.html +36 -0
- data/lib/leaflet.draw/spec/karma.conf.js +69 -0
- data/lib/leaflet.draw/spec/sinon.js +4223 -0
- data/lib/leaflet.draw/spec/suites/DrawControlSpec.js +15 -0
- data/lib/leaflet.draw/spec/suites/SpecHelper.js +26 -0
- data/lib/leaflet.draw/src/Control.Draw.js +101 -0
- data/lib/leaflet.draw/src/Leaflet.draw.js +5 -0
- data/lib/leaflet.draw/src/Toolbar.js +187 -0
- data/lib/leaflet.draw/src/Tooltip.js +52 -0
- data/lib/leaflet.draw/src/copyright.js +8 -0
- data/lib/leaflet.draw/src/draw/DrawToolbar.js +107 -0
- data/lib/leaflet.draw/src/draw/handler/Draw.Circle.js +59 -0
- data/lib/leaflet.draw/src/draw/handler/Draw.Feature.js +74 -0
- data/lib/leaflet.draw/src/draw/handler/Draw.Marker.js +97 -0
- data/lib/leaflet.draw/src/draw/handler/Draw.Polygon.js +79 -0
- data/lib/leaflet.draw/src/draw/handler/Draw.Polyline.js +360 -0
- data/lib/leaflet.draw/src/draw/handler/Draw.Rectangle.js +41 -0
- data/lib/leaflet.draw/src/draw/handler/Draw.SimpleShape.js +67 -0
- data/lib/leaflet.draw/src/edit/EditToolbar.js +93 -0
- data/lib/leaflet.draw/src/edit/handler/Edit.Circle.js +63 -0
- data/lib/leaflet.draw/src/edit/handler/Edit.Poly.js +267 -0
- data/lib/leaflet.draw/src/edit/handler/Edit.Rectangle.js +117 -0
- data/lib/leaflet.draw/src/edit/handler/Edit.SimpleShape.js +138 -0
- data/lib/leaflet.draw/src/edit/handler/EditToolbar.Delete.js +109 -0
- data/lib/leaflet.draw/src/edit/handler/EditToolbar.Edit.js +233 -0
- data/lib/leaflet.draw/src/ext/LatLngUtil.js +18 -0
- data/lib/leaflet.draw/src/ext/LineUtil.Intersect.js +15 -0
- data/lib/leaflet.draw/src/ext/Polygon.Intersect.js +27 -0
- data/lib/leaflet.draw/src/ext/Polyline.Intersect.js +85 -0
- data/lib/leaflet.label/CHANGELOG.md +35 -0
- data/lib/leaflet.label/Jakefile.js +21 -0
- data/lib/leaflet.label/MIT-LICENCE.txt +20 -0
- data/lib/leaflet.label/README.md +86 -0
- data/lib/leaflet.label/build/build.js +155 -0
- data/lib/leaflet.label/build/deps.js +24 -0
- data/lib/leaflet.label/build/hint.js +30 -0
- data/lib/leaflet.label/build/hintrc.js +47 -0
- data/lib/leaflet.label/dist/images/death.png +0 -0
- data/lib/leaflet.label/dist/leaflet.label-src.js +359 -0
- data/lib/leaflet.label/dist/leaflet.label.css +33 -0
- data/lib/leaflet.label/dist/leaflet.label.js +9 -0
- data/lib/leaflet.label/example/label.html +82 -0
- data/lib/leaflet.label/libs/leaflet/images/layers.png +0 -0
- data/lib/leaflet.label/libs/leaflet/images/marker-icon.png +0 -0
- data/lib/leaflet.label/libs/leaflet/images/marker-icon@2x.png +0 -0
- data/lib/leaflet.label/libs/leaflet/images/marker-shadow.png +0 -0
- data/lib/leaflet.label/libs/leaflet/leaflet-src.js +8587 -0
- data/lib/leaflet.label/libs/leaflet/leaflet.css +459 -0
- data/lib/leaflet.label/libs/leaflet/leaflet.ie.css +51 -0
- data/lib/leaflet.label/libs/leaflet/leaflet.js +8 -0
- data/lib/leaflet.label/src/FeatureGroup.Label.js +20 -0
- data/lib/leaflet.label/src/Label.js +123 -0
- data/lib/leaflet.label/src/Leaflet.label.js +5 -0
- data/lib/leaflet.label/src/Map.Label.js +7 -0
- data/lib/leaflet.label/src/Marker.Label.js +160 -0
- data/lib/leaflet.label/src/Path.Label.js +55 -0
- data/lib/leaflet.label/src/copyright.js +8 -0
- data/lib/leaflet/CHANGELOG.md +637 -0
- data/lib/leaflet/CONTRIBUTING.md +155 -0
- data/lib/leaflet/Jakefile.js +26 -0
- data/lib/leaflet/LICENSE +23 -0
- data/lib/leaflet/README.md +30 -0
- data/lib/leaflet/build/build.html +243 -0
- data/lib/leaflet/build/build.js +193 -0
- data/lib/leaflet/build/deps.js +256 -0
- data/lib/leaflet/build/hintrc.js +37 -0
- data/lib/leaflet/debug/css/mobile.css +6 -0
- data/lib/leaflet/debug/css/screen.css +5 -0
- data/lib/leaflet/debug/hacks/jitter.html +43 -0
- data/lib/leaflet/debug/leaflet-include.js +59 -0
- data/lib/leaflet/debug/map/canvas.html +47 -0
- data/lib/leaflet/debug/map/controls.html +50 -0
- data/lib/leaflet/debug/map/geolocation.html +35 -0
- data/lib/leaflet/debug/map/image-overlay.html +44 -0
- data/lib/leaflet/debug/map/map-mobile.html +35 -0
- data/lib/leaflet/debug/map/map.html +60 -0
- data/lib/leaflet/debug/map/max-bounds.html +37 -0
- data/lib/leaflet/debug/map/scroll.html +36 -0
- data/lib/leaflet/debug/map/simple-proj.html +45 -0
- data/lib/leaflet/debug/map/wms-marble.html +31 -0
- data/lib/leaflet/debug/map/wms.html +41 -0
- data/lib/leaflet/debug/map/zoomlevels.html +46 -0
- data/lib/leaflet/debug/tests/add_remove_layers.html +88 -0
- data/lib/leaflet/debug/tests/bringtoback.html +38 -0
- data/lib/leaflet/debug/tests/click_on_canvas.html +59 -0
- data/lib/leaflet/debug/tests/click_on_canvas_broken.html +49 -0
- data/lib/leaflet/debug/tests/opacity.html +57 -0
- data/lib/leaflet/debug/tests/remove_while_dragging.html +29 -0
- data/lib/leaflet/debug/tests/removetilewhilepan.html +42 -0
- data/lib/leaflet/debug/tests/reuse_popups.html +41 -0
- data/lib/leaflet/debug/tests/svg_clicks.html +55 -0
- data/lib/leaflet/debug/vector/bounds-extend.html +89 -0
- data/lib/leaflet/debug/vector/feature-group-bounds.html +91 -0
- data/lib/leaflet/debug/vector/geojson-sample.js +53 -0
- data/lib/leaflet/debug/vector/geojson.html +174 -0
- data/lib/leaflet/debug/vector/rectangle.html +54 -0
- data/lib/leaflet/debug/vector/route.js +1 -0
- data/lib/leaflet/debug/vector/touchzoomemu.html +195 -0
- data/lib/leaflet/debug/vector/us-states.js +54 -0
- data/lib/leaflet/debug/vector/vector-bounds.html +70 -0
- data/lib/leaflet/debug/vector/vector-canvas.html +93 -0
- data/lib/leaflet/debug/vector/vector-mobile.html +39 -0
- data/lib/leaflet/debug/vector/vector-simple.html +49 -0
- data/lib/leaflet/debug/vector/vector.html +38 -0
- data/lib/leaflet/dist/images/layers.png +0 -0
- data/lib/leaflet/dist/images/marker-icon-2x.png +0 -0
- data/lib/leaflet/dist/images/marker-icon.png +0 -0
- data/lib/leaflet/dist/images/marker-shadow.png +0 -0
- data/lib/leaflet/dist/leaflet-src.js +8579 -0
- data/lib/leaflet/dist/leaflet.css +459 -0
- data/lib/leaflet/dist/leaflet.ie.css +51 -0
- data/lib/leaflet/dist/leaflet.js +8 -0
- data/lib/leaflet/package.json +22 -0
- data/lib/leaflet/spec/after.js +2 -0
- data/lib/leaflet/spec/before.js +3 -0
- data/lib/leaflet/spec/expect.js +1253 -0
- data/lib/leaflet/spec/happen.js +93 -0
- data/lib/leaflet/spec/index.html +78 -0
- data/lib/leaflet/spec/karma.conf.js +64 -0
- data/lib/leaflet/spec/sinon.js +4223 -0
- data/lib/leaflet/spec/suites/LeafletSpec.js +13 -0
- data/lib/leaflet/spec/suites/SpecHelper.js +26 -0
- data/lib/leaflet/spec/suites/control/Control.AttributionSpec.js +68 -0
- data/lib/leaflet/spec/suites/control/Control.LayersSpec.js +67 -0
- data/lib/leaflet/spec/suites/control/Control.ScaleSpec.js +6 -0
- data/lib/leaflet/spec/suites/core/ClassSpec.js +156 -0
- data/lib/leaflet/spec/suites/core/EventsSpec.js +336 -0
- data/lib/leaflet/spec/suites/core/UtilSpec.js +212 -0
- data/lib/leaflet/spec/suites/dom/DomEventSpec.js +102 -0
- data/lib/leaflet/spec/suites/dom/DomUtilSpec.js +89 -0
- data/lib/leaflet/spec/suites/geo/LatLngBoundsSpec.js +136 -0
- data/lib/leaflet/spec/suites/geo/LatLngSpec.js +118 -0
- data/lib/leaflet/spec/suites/geo/ProjectionSpec.js +47 -0
- data/lib/leaflet/spec/suites/geometry/BoundsSpec.js +87 -0
- data/lib/leaflet/spec/suites/geometry/LineUtilSpec.js +75 -0
- data/lib/leaflet/spec/suites/geometry/PointSpec.js +104 -0
- data/lib/leaflet/spec/suites/geometry/PolyUtilSpec.js +27 -0
- data/lib/leaflet/spec/suites/geometry/TransformationSpec.js +31 -0
- data/lib/leaflet/spec/suites/layer/FeatureGroupSpec.js +36 -0
- data/lib/leaflet/spec/suites/layer/GeoJSONSpec.js +86 -0
- data/lib/leaflet/spec/suites/layer/LayerGroupSpec.js +58 -0
- data/lib/leaflet/spec/suites/layer/PopupSpec.js +59 -0
- data/lib/leaflet/spec/suites/layer/TileLayerSpec.js +87 -0
- data/lib/leaflet/spec/suites/layer/vector/CircleMarkerSpec.js +53 -0
- data/lib/leaflet/spec/suites/layer/vector/CircleSpec.js +17 -0
- data/lib/leaflet/spec/suites/layer/vector/PolygonSpec.js +55 -0
- data/lib/leaflet/spec/suites/layer/vector/PolylineGeometrySpec.js +35 -0
- data/lib/leaflet/spec/suites/layer/vector/PolylineSpec.js +55 -0
- data/lib/leaflet/spec/suites/map/MapSpec.js +244 -0
- data/lib/leaflet/src/Leaflet.js +23 -0
- data/lib/leaflet/src/control/Control.Attribution.js +115 -0
- data/lib/leaflet/src/control/Control.Layers.js +243 -0
- data/lib/leaflet/src/control/Control.Scale.js +112 -0
- data/lib/leaflet/src/control/Control.Zoom.js +86 -0
- data/lib/leaflet/src/control/Control.js +107 -0
- data/lib/leaflet/src/copyright.js +4 -0
- data/lib/leaflet/src/core/Browser.js +96 -0
- data/lib/leaflet/src/core/Class.js +106 -0
- data/lib/leaflet/src/core/Events.js +174 -0
- data/lib/leaflet/src/core/Handler.js +28 -0
- data/lib/leaflet/src/core/Util.js +182 -0
- data/lib/leaflet/src/dom/DomEvent.DoubleTap.js +103 -0
- data/lib/leaflet/src/dom/DomEvent.MsTouch.js +146 -0
- data/lib/leaflet/src/dom/DomEvent.js +211 -0
- data/lib/leaflet/src/dom/DomUtil.js +239 -0
- data/lib/leaflet/src/dom/Draggable.js +198 -0
- data/lib/leaflet/src/dom/PosAnimation.Timer.js +67 -0
- data/lib/leaflet/src/dom/PosAnimation.js +83 -0
- data/lib/leaflet/src/geo/LatLng.js +88 -0
- data/lib/leaflet/src/geo/LatLngBounds.js +153 -0
- data/lib/leaflet/src/geo/crs/CRS.EPSG3395.js +14 -0
- data/lib/leaflet/src/geo/crs/CRS.EPSG3857.js +21 -0
- data/lib/leaflet/src/geo/crs/CRS.EPSG4326.js +10 -0
- data/lib/leaflet/src/geo/crs/CRS.Simple.js +12 -0
- data/lib/leaflet/src/geo/crs/CRS.js +27 -0
- data/lib/leaflet/src/geo/projection/Projection.LonLat.js +13 -0
- data/lib/leaflet/src/geo/projection/Projection.Mercator.js +56 -0
- data/lib/leaflet/src/geo/projection/Projection.SphericalMercator.js +27 -0
- data/lib/leaflet/src/geo/projection/Projection.js +5 -0
- data/lib/leaflet/src/geometry/Bounds.js +95 -0
- data/lib/leaflet/src/geometry/LineUtil.js +202 -0
- data/lib/leaflet/src/geometry/Point.js +119 -0
- data/lib/leaflet/src/geometry/PolyUtil.js +55 -0
- data/lib/leaflet/src/geometry/Transformation.js +31 -0
- data/lib/leaflet/src/images/marker.svg +1 -0
- data/lib/leaflet/src/layer/FeatureGroup.js +81 -0
- data/lib/leaflet/src/layer/GeoJSON.js +245 -0
- data/lib/leaflet/src/layer/ImageOverlay.js +132 -0
- data/lib/leaflet/src/layer/LayerGroup.js +110 -0
- data/lib/leaflet/src/layer/Popup.js +316 -0
- data/lib/leaflet/src/layer/marker/DivIcon.js +43 -0
- data/lib/leaflet/src/layer/marker/Icon.Default.js +51 -0
- data/lib/leaflet/src/layer/marker/Icon.js +101 -0
- data/lib/leaflet/src/layer/marker/Marker.Drag.js +66 -0
- data/lib/leaflet/src/layer/marker/Marker.Popup.js +72 -0
- data/lib/leaflet/src/layer/marker/Marker.js +275 -0
- data/lib/leaflet/src/layer/tile/TileLayer.Anim.js +117 -0
- data/lib/leaflet/src/layer/tile/TileLayer.Canvas.js +60 -0
- data/lib/leaflet/src/layer/tile/TileLayer.WMS.js +83 -0
- data/lib/leaflet/src/layer/tile/TileLayer.js +578 -0
- data/lib/leaflet/src/layer/vector/Circle.js +98 -0
- data/lib/leaflet/src/layer/vector/CircleMarker.js +33 -0
- data/lib/leaflet/src/layer/vector/MultiPoly.js +47 -0
- data/lib/leaflet/src/layer/vector/Path.Popup.js +65 -0
- data/lib/leaflet/src/layer/vector/Path.SVG.js +219 -0
- data/lib/leaflet/src/layer/vector/Path.VML.js +125 -0
- data/lib/leaflet/src/layer/vector/Path.js +115 -0
- data/lib/leaflet/src/layer/vector/Polygon.js +81 -0
- data/lib/leaflet/src/layer/vector/Polyline.js +164 -0
- data/lib/leaflet/src/layer/vector/Rectangle.js +27 -0
- data/lib/leaflet/src/layer/vector/canvas/Circle.Canvas.js +18 -0
- data/lib/leaflet/src/layer/vector/canvas/Path.Canvas.js +196 -0
- data/lib/leaflet/src/layer/vector/canvas/Polygon.Canvas.js +37 -0
- data/lib/leaflet/src/layer/vector/canvas/Polyline.Canvas.js +30 -0
- data/lib/leaflet/src/map/Map.js +743 -0
- data/lib/leaflet/src/map/anim/Map.PanAnimation.js +88 -0
- data/lib/leaflet/src/map/anim/Map.ZoomAnimation.js +90 -0
- data/lib/leaflet/src/map/ext/Map.Geolocation.js +91 -0
- data/lib/leaflet/src/map/handler/Map.BoxZoom.js +104 -0
- data/lib/leaflet/src/map/handler/Map.DoubleClickZoom.js +23 -0
- data/lib/leaflet/src/map/handler/Map.Drag.js +146 -0
- data/lib/leaflet/src/map/handler/Map.Keyboard.js +147 -0
- data/lib/leaflet/src/map/handler/Map.ScrollWheelZoom.js +56 -0
- data/lib/leaflet/src/map/handler/Map.TouchZoom.js +121 -0
- data/vendor/assets/images/layers.png +0 -0
- data/vendor/assets/images/marker-icon-2x.png +0 -0
- data/vendor/assets/images/marker-icon.png +0 -0
- data/vendor/assets/images/marker-shadow.png +0 -0
- data/vendor/assets/images/spritesheet.png +0 -0
- data/vendor/assets/javascripts/leaflet.draw.js +39 -0
- data/vendor/assets/javascripts/leaflet.js +145 -0
- data/vendor/assets/javascripts/leaflet.label.js +9 -0
- data/vendor/assets/stylesheets/leaflet.css.erb +459 -0
- data/vendor/assets/stylesheets/leaflet.draw.css.erb +212 -0
- data/vendor/assets/stylesheets/leaflet.draw.ie.css +44 -0
- data/vendor/assets/stylesheets/leaflet.ie.css +51 -0
- data/vendor/assets/stylesheets/leaflet.label.css +33 -0
- metadata +317 -0
@@ -0,0 +1,110 @@
|
|
1
|
+
/*
|
2
|
+
* L.LayerGroup is a class to combine several layers into one so that
|
3
|
+
* you can manipulate the group (e.g. add/remove it) as one layer.
|
4
|
+
*/
|
5
|
+
|
6
|
+
L.LayerGroup = L.Class.extend({
|
7
|
+
initialize: function (layers) {
|
8
|
+
this._layers = {};
|
9
|
+
|
10
|
+
var i, len;
|
11
|
+
|
12
|
+
if (layers) {
|
13
|
+
for (i = 0, len = layers.length; i < len; i++) {
|
14
|
+
this.addLayer(layers[i]);
|
15
|
+
}
|
16
|
+
}
|
17
|
+
},
|
18
|
+
|
19
|
+
addLayer: function (layer) {
|
20
|
+
var id = this.getLayerId(layer);
|
21
|
+
|
22
|
+
this._layers[id] = layer;
|
23
|
+
|
24
|
+
if (this._map) {
|
25
|
+
this._map.addLayer(layer);
|
26
|
+
}
|
27
|
+
|
28
|
+
return this;
|
29
|
+
},
|
30
|
+
|
31
|
+
removeLayer: function (layer) {
|
32
|
+
var id = this.getLayerId(layer);
|
33
|
+
|
34
|
+
if (this._map && this._layers[id]) {
|
35
|
+
this._map.removeLayer(layer);
|
36
|
+
}
|
37
|
+
|
38
|
+
delete this._layers[id];
|
39
|
+
|
40
|
+
return this;
|
41
|
+
},
|
42
|
+
|
43
|
+
hasLayer: function (layer) {
|
44
|
+
if (!layer) { return false; }
|
45
|
+
|
46
|
+
return (this.getLayerId(layer) in this._layers);
|
47
|
+
},
|
48
|
+
|
49
|
+
clearLayers: function () {
|
50
|
+
this.eachLayer(this.removeLayer, this);
|
51
|
+
return this;
|
52
|
+
},
|
53
|
+
|
54
|
+
invoke: function (methodName) {
|
55
|
+
var args = Array.prototype.slice.call(arguments, 1),
|
56
|
+
i, layer;
|
57
|
+
|
58
|
+
for (i in this._layers) {
|
59
|
+
layer = this._layers[i];
|
60
|
+
|
61
|
+
if (layer[methodName]) {
|
62
|
+
layer[methodName].apply(layer, args);
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
return this;
|
67
|
+
},
|
68
|
+
|
69
|
+
onAdd: function (map) {
|
70
|
+
this._map = map;
|
71
|
+
this.eachLayer(map.addLayer, map);
|
72
|
+
},
|
73
|
+
|
74
|
+
onRemove: function (map) {
|
75
|
+
this.eachLayer(map.removeLayer, map);
|
76
|
+
this._map = null;
|
77
|
+
},
|
78
|
+
|
79
|
+
addTo: function (map) {
|
80
|
+
map.addLayer(this);
|
81
|
+
return this;
|
82
|
+
},
|
83
|
+
|
84
|
+
eachLayer: function (method, context) {
|
85
|
+
for (var i in this._layers) {
|
86
|
+
method.call(context, this._layers[i]);
|
87
|
+
}
|
88
|
+
return this;
|
89
|
+
},
|
90
|
+
|
91
|
+
getLayers: function () {
|
92
|
+
var layers = [];
|
93
|
+
for (var i in this._layers) {
|
94
|
+
layers.push(this._layers[i]);
|
95
|
+
}
|
96
|
+
return layers;
|
97
|
+
},
|
98
|
+
|
99
|
+
setZIndex: function (zIndex) {
|
100
|
+
return this.invoke('setZIndex', zIndex);
|
101
|
+
},
|
102
|
+
|
103
|
+
getLayerId: function (layer) {
|
104
|
+
return L.stamp(layer);
|
105
|
+
}
|
106
|
+
});
|
107
|
+
|
108
|
+
L.layerGroup = function (layers) {
|
109
|
+
return new L.LayerGroup(layers);
|
110
|
+
};
|
@@ -0,0 +1,316 @@
|
|
1
|
+
/*
|
2
|
+
* L.Popup is used for displaying popups on the map.
|
3
|
+
*/
|
4
|
+
|
5
|
+
L.Map.mergeOptions({
|
6
|
+
closePopupOnClick: true
|
7
|
+
});
|
8
|
+
|
9
|
+
L.Popup = L.Class.extend({
|
10
|
+
includes: L.Mixin.Events,
|
11
|
+
|
12
|
+
options: {
|
13
|
+
minWidth: 50,
|
14
|
+
maxWidth: 300,
|
15
|
+
maxHeight: null,
|
16
|
+
autoPan: true,
|
17
|
+
closeButton: true,
|
18
|
+
offset: [0, 6],
|
19
|
+
autoPanPadding: [5, 5],
|
20
|
+
keepInView: false,
|
21
|
+
className: '',
|
22
|
+
zoomAnimation: true
|
23
|
+
},
|
24
|
+
|
25
|
+
initialize: function (options, source) {
|
26
|
+
L.setOptions(this, options);
|
27
|
+
|
28
|
+
this._source = source;
|
29
|
+
this._animated = L.Browser.any3d && this.options.zoomAnimation;
|
30
|
+
},
|
31
|
+
|
32
|
+
onAdd: function (map) {
|
33
|
+
this._map = map;
|
34
|
+
|
35
|
+
if (!this._container) {
|
36
|
+
this._initLayout();
|
37
|
+
}
|
38
|
+
this._updateContent();
|
39
|
+
|
40
|
+
var animFade = map.options.fadeAnimation;
|
41
|
+
|
42
|
+
if (animFade) {
|
43
|
+
L.DomUtil.setOpacity(this._container, 0);
|
44
|
+
}
|
45
|
+
map._panes.popupPane.appendChild(this._container);
|
46
|
+
|
47
|
+
map.on(this._getEvents(), this);
|
48
|
+
|
49
|
+
this._update();
|
50
|
+
|
51
|
+
if (animFade) {
|
52
|
+
L.DomUtil.setOpacity(this._container, 1);
|
53
|
+
}
|
54
|
+
|
55
|
+
this.fire('open');
|
56
|
+
|
57
|
+
map.fire('popupopen', {popup: this});
|
58
|
+
|
59
|
+
if (this._source) {
|
60
|
+
this._source.fire('popupopen', {popup: this});
|
61
|
+
}
|
62
|
+
},
|
63
|
+
|
64
|
+
addTo: function (map) {
|
65
|
+
map.addLayer(this);
|
66
|
+
return this;
|
67
|
+
},
|
68
|
+
|
69
|
+
openOn: function (map) {
|
70
|
+
map.openPopup(this);
|
71
|
+
return this;
|
72
|
+
},
|
73
|
+
|
74
|
+
onRemove: function (map) {
|
75
|
+
map._panes.popupPane.removeChild(this._container);
|
76
|
+
|
77
|
+
L.Util.falseFn(this._container.offsetWidth); // force reflow
|
78
|
+
|
79
|
+
map.off(this._getEvents(), this);
|
80
|
+
|
81
|
+
if (map.options.fadeAnimation) {
|
82
|
+
L.DomUtil.setOpacity(this._container, 0);
|
83
|
+
}
|
84
|
+
|
85
|
+
this._map = null;
|
86
|
+
|
87
|
+
this.fire('close');
|
88
|
+
|
89
|
+
map.fire('popupclose', {popup: this});
|
90
|
+
|
91
|
+
if (this._source) {
|
92
|
+
this._source.fire('popupclose', {popup: this});
|
93
|
+
}
|
94
|
+
},
|
95
|
+
|
96
|
+
setLatLng: function (latlng) {
|
97
|
+
this._latlng = L.latLng(latlng);
|
98
|
+
this._update();
|
99
|
+
return this;
|
100
|
+
},
|
101
|
+
|
102
|
+
setContent: function (content) {
|
103
|
+
this._content = content;
|
104
|
+
this._update();
|
105
|
+
return this;
|
106
|
+
},
|
107
|
+
|
108
|
+
_getEvents: function () {
|
109
|
+
var events = {
|
110
|
+
viewreset: this._updatePosition
|
111
|
+
};
|
112
|
+
|
113
|
+
if (this._animated) {
|
114
|
+
events.zoomanim = this._zoomAnimation;
|
115
|
+
}
|
116
|
+
if (this._map.options.closePopupOnClick) {
|
117
|
+
events.preclick = this._close;
|
118
|
+
}
|
119
|
+
if (this.options.keepInView) {
|
120
|
+
events.moveend = this._adjustPan;
|
121
|
+
}
|
122
|
+
|
123
|
+
return events;
|
124
|
+
},
|
125
|
+
|
126
|
+
_close: function () {
|
127
|
+
if (this._map) {
|
128
|
+
this._map.removeLayer(this);
|
129
|
+
}
|
130
|
+
},
|
131
|
+
|
132
|
+
_initLayout: function () {
|
133
|
+
var prefix = 'leaflet-popup',
|
134
|
+
containerClass = prefix + ' ' + this.options.className + ' leaflet-zoom-' +
|
135
|
+
(this._animated ? 'animated' : 'hide'),
|
136
|
+
container = this._container = L.DomUtil.create('div', containerClass),
|
137
|
+
closeButton;
|
138
|
+
|
139
|
+
if (this.options.closeButton) {
|
140
|
+
closeButton = this._closeButton =
|
141
|
+
L.DomUtil.create('a', prefix + '-close-button', container);
|
142
|
+
closeButton.href = '#close';
|
143
|
+
closeButton.innerHTML = '×';
|
144
|
+
L.DomEvent.disableClickPropagation(closeButton);
|
145
|
+
|
146
|
+
L.DomEvent.on(closeButton, 'click', this._onCloseButtonClick, this);
|
147
|
+
}
|
148
|
+
|
149
|
+
var wrapper = this._wrapper =
|
150
|
+
L.DomUtil.create('div', prefix + '-content-wrapper', container);
|
151
|
+
L.DomEvent.disableClickPropagation(wrapper);
|
152
|
+
|
153
|
+
this._contentNode = L.DomUtil.create('div', prefix + '-content', wrapper);
|
154
|
+
L.DomEvent.on(this._contentNode, 'mousewheel', L.DomEvent.stopPropagation);
|
155
|
+
|
156
|
+
this._tipContainer = L.DomUtil.create('div', prefix + '-tip-container', container);
|
157
|
+
this._tip = L.DomUtil.create('div', prefix + '-tip', this._tipContainer);
|
158
|
+
},
|
159
|
+
|
160
|
+
_update: function () {
|
161
|
+
if (!this._map) { return; }
|
162
|
+
|
163
|
+
this._container.style.visibility = 'hidden';
|
164
|
+
|
165
|
+
this._updateContent();
|
166
|
+
this._updateLayout();
|
167
|
+
this._updatePosition();
|
168
|
+
|
169
|
+
this._container.style.visibility = '';
|
170
|
+
|
171
|
+
this._adjustPan();
|
172
|
+
},
|
173
|
+
|
174
|
+
_updateContent: function () {
|
175
|
+
if (!this._content) { return; }
|
176
|
+
|
177
|
+
if (typeof this._content === 'string') {
|
178
|
+
this._contentNode.innerHTML = this._content;
|
179
|
+
} else {
|
180
|
+
while (this._contentNode.hasChildNodes()) {
|
181
|
+
this._contentNode.removeChild(this._contentNode.firstChild);
|
182
|
+
}
|
183
|
+
this._contentNode.appendChild(this._content);
|
184
|
+
}
|
185
|
+
this.fire('contentupdate');
|
186
|
+
},
|
187
|
+
|
188
|
+
_updateLayout: function () {
|
189
|
+
var container = this._contentNode,
|
190
|
+
style = container.style;
|
191
|
+
|
192
|
+
style.width = '';
|
193
|
+
style.whiteSpace = 'nowrap';
|
194
|
+
|
195
|
+
var width = container.offsetWidth;
|
196
|
+
width = Math.min(width, this.options.maxWidth);
|
197
|
+
width = Math.max(width, this.options.minWidth);
|
198
|
+
|
199
|
+
style.width = (width + 1) + 'px';
|
200
|
+
style.whiteSpace = '';
|
201
|
+
|
202
|
+
style.height = '';
|
203
|
+
|
204
|
+
var height = container.offsetHeight,
|
205
|
+
maxHeight = this.options.maxHeight,
|
206
|
+
scrolledClass = 'leaflet-popup-scrolled';
|
207
|
+
|
208
|
+
if (maxHeight && height > maxHeight) {
|
209
|
+
style.height = maxHeight + 'px';
|
210
|
+
L.DomUtil.addClass(container, scrolledClass);
|
211
|
+
} else {
|
212
|
+
L.DomUtil.removeClass(container, scrolledClass);
|
213
|
+
}
|
214
|
+
|
215
|
+
this._containerWidth = this._container.offsetWidth;
|
216
|
+
},
|
217
|
+
|
218
|
+
_updatePosition: function () {
|
219
|
+
if (!this._map) { return; }
|
220
|
+
|
221
|
+
var pos = this._map.latLngToLayerPoint(this._latlng),
|
222
|
+
animated = this._animated,
|
223
|
+
offset = L.point(this.options.offset);
|
224
|
+
|
225
|
+
if (animated) {
|
226
|
+
L.DomUtil.setPosition(this._container, pos);
|
227
|
+
}
|
228
|
+
|
229
|
+
this._containerBottom = -offset.y - (animated ? 0 : pos.y);
|
230
|
+
this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x + (animated ? 0 : pos.x);
|
231
|
+
|
232
|
+
// bottom position the popup in case the height of the popup changes (images loading etc)
|
233
|
+
this._container.style.bottom = this._containerBottom + 'px';
|
234
|
+
this._container.style.left = this._containerLeft + 'px';
|
235
|
+
},
|
236
|
+
|
237
|
+
_zoomAnimation: function (opt) {
|
238
|
+
var pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center);
|
239
|
+
|
240
|
+
L.DomUtil.setPosition(this._container, pos);
|
241
|
+
},
|
242
|
+
|
243
|
+
_adjustPan: function () {
|
244
|
+
if (!this.options.autoPan) { return; }
|
245
|
+
|
246
|
+
var map = this._map,
|
247
|
+
containerHeight = this._container.offsetHeight,
|
248
|
+
containerWidth = this._containerWidth,
|
249
|
+
|
250
|
+
layerPos = new L.Point(this._containerLeft, -containerHeight - this._containerBottom);
|
251
|
+
|
252
|
+
if (this._animated) {
|
253
|
+
layerPos._add(L.DomUtil.getPosition(this._container));
|
254
|
+
}
|
255
|
+
|
256
|
+
var containerPos = map.layerPointToContainerPoint(layerPos),
|
257
|
+
padding = L.point(this.options.autoPanPadding),
|
258
|
+
size = map.getSize(),
|
259
|
+
dx = 0,
|
260
|
+
dy = 0;
|
261
|
+
|
262
|
+
if (containerPos.x + containerWidth > size.x) { // right
|
263
|
+
dx = containerPos.x + containerWidth - size.x + padding.x;
|
264
|
+
}
|
265
|
+
if (containerPos.x - dx < 0) { // left
|
266
|
+
dx = containerPos.x - padding.x;
|
267
|
+
}
|
268
|
+
if (containerPos.y + containerHeight > size.y) { // bottom
|
269
|
+
dy = containerPos.y + containerHeight - size.y + padding.y;
|
270
|
+
}
|
271
|
+
if (containerPos.y - dy < 0) { // top
|
272
|
+
dy = containerPos.y - padding.y;
|
273
|
+
}
|
274
|
+
|
275
|
+
if (dx || dy) {
|
276
|
+
map
|
277
|
+
.fire('autopanstart')
|
278
|
+
.panBy([dx, dy]);
|
279
|
+
}
|
280
|
+
},
|
281
|
+
|
282
|
+
_onCloseButtonClick: function (e) {
|
283
|
+
this._close();
|
284
|
+
L.DomEvent.stop(e);
|
285
|
+
}
|
286
|
+
});
|
287
|
+
|
288
|
+
L.popup = function (options, source) {
|
289
|
+
return new L.Popup(options, source);
|
290
|
+
};
|
291
|
+
|
292
|
+
|
293
|
+
L.Map.include({
|
294
|
+
openPopup: function (popup, latlng, options) { // (Popup) or (String || HTMLElement, LatLng[, Object])
|
295
|
+
this.closePopup();
|
296
|
+
|
297
|
+
if (!(popup instanceof L.Popup)) {
|
298
|
+
var content = popup;
|
299
|
+
|
300
|
+
popup = new L.Popup(options)
|
301
|
+
.setLatLng(latlng)
|
302
|
+
.setContent(content);
|
303
|
+
}
|
304
|
+
|
305
|
+
this._popup = popup;
|
306
|
+
return this.addLayer(popup);
|
307
|
+
},
|
308
|
+
|
309
|
+
closePopup: function () {
|
310
|
+
if (this._popup) {
|
311
|
+
this.removeLayer(this._popup);
|
312
|
+
this._popup = null;
|
313
|
+
}
|
314
|
+
return this;
|
315
|
+
}
|
316
|
+
});
|
@@ -0,0 +1,43 @@
|
|
1
|
+
/*
|
2
|
+
* L.DivIcon is a lightweight HTML-based icon class (as opposed to the image-based L.Icon)
|
3
|
+
* to use with L.Marker.
|
4
|
+
*/
|
5
|
+
|
6
|
+
L.DivIcon = L.Icon.extend({
|
7
|
+
options: {
|
8
|
+
iconSize: [12, 12], // also can be set through CSS
|
9
|
+
/*
|
10
|
+
iconAnchor: (Point)
|
11
|
+
popupAnchor: (Point)
|
12
|
+
html: (String)
|
13
|
+
bgPos: (Point)
|
14
|
+
*/
|
15
|
+
className: 'leaflet-div-icon',
|
16
|
+
html: false
|
17
|
+
},
|
18
|
+
|
19
|
+
createIcon: function () {
|
20
|
+
var div = document.createElement('div'),
|
21
|
+
options = this.options;
|
22
|
+
|
23
|
+
if (options.html !== false) {
|
24
|
+
div.innerHTML = options.html;
|
25
|
+
}
|
26
|
+
|
27
|
+
if (options.bgPos) {
|
28
|
+
div.style.backgroundPosition =
|
29
|
+
(-options.bgPos.x) + 'px ' + (-options.bgPos.y) + 'px';
|
30
|
+
}
|
31
|
+
|
32
|
+
this._setIconStyles(div, 'icon');
|
33
|
+
return div;
|
34
|
+
},
|
35
|
+
|
36
|
+
createShadow: function () {
|
37
|
+
return null;
|
38
|
+
}
|
39
|
+
});
|
40
|
+
|
41
|
+
L.divIcon = function (options) {
|
42
|
+
return new L.DivIcon(options);
|
43
|
+
};
|