leaflet-js 0.6.beta4 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/CHANGELOG.rdoc +3 -0
- data/leaflet-js.gemspec +2 -2
- data/lib/leaflet.draw/CHANGELOG.md +45 -0
- data/lib/leaflet.draw/README.md +70 -23
- data/lib/leaflet.draw/build/deps.js +1 -0
- data/lib/leaflet.draw/dist/images/spritesheet-2x.png +0 -0
- data/lib/leaflet.draw/dist/images/spritesheet.png +0 -0
- data/lib/leaflet.draw/dist/leaflet.draw-src.js +489 -136
- data/lib/leaflet.draw/dist/leaflet.draw.css +34 -2
- data/lib/leaflet.draw/dist/leaflet.draw.ie.css +5 -0
- data/lib/leaflet.draw/dist/leaflet.draw.js +2 -2
- data/lib/leaflet.draw/examples/basic.html +14 -7
- data/lib/leaflet.draw/examples/libs/images/layers-2x.png +0 -0
- data/lib/leaflet.draw/examples/libs/images/layers.png +0 -0
- data/lib/leaflet.draw/examples/libs/images/marker-icon-2x.png +0 -0
- data/lib/leaflet.draw/examples/libs/leaflet-src.js +1129 -608
- data/lib/leaflet.draw/examples/libs/leaflet.css +85 -66
- data/lib/leaflet.draw/package.json +2 -2
- data/lib/leaflet.draw/spec/suites/DrawControlSpec.js +1 -1
- data/lib/leaflet.draw/spec/suites/GeometryUtilSpec.js +25 -0
- data/lib/leaflet.draw/spec/suites/LatLngUtilSpec.js +9 -0
- data/lib/leaflet.draw/src/Control.Draw.js +1 -0
- data/lib/leaflet.draw/src/Leaflet.draw.js +89 -1
- data/lib/leaflet.draw/src/Toolbar.js +2 -6
- data/lib/leaflet.draw/src/Tooltip.js +20 -7
- data/lib/leaflet.draw/src/draw/DrawToolbar.js +26 -22
- data/lib/leaflet.draw/src/draw/handler/Draw.Circle.js +11 -6
- data/lib/leaflet.draw/src/draw/handler/Draw.Feature.js +6 -2
- data/lib/leaflet.draw/src/draw/handler/Draw.Marker.js +7 -2
- data/lib/leaflet.draw/src/draw/handler/Draw.Polygon.js +29 -7
- data/lib/leaflet.draw/src/draw/handler/Draw.Polyline.js +44 -21
- data/lib/leaflet.draw/src/draw/handler/Draw.Rectangle.js +3 -3
- data/lib/leaflet.draw/src/draw/handler/Draw.SimpleShape.js +14 -1
- data/lib/leaflet.draw/src/edit/EditToolbar.js +86 -16
- data/lib/leaflet.draw/src/edit/handler/Edit.Poly.js +10 -7
- data/lib/leaflet.draw/src/edit/handler/Edit.SimpleShape.js +1 -2
- data/lib/leaflet.draw/src/edit/handler/EditToolbar.Delete.js +15 -3
- data/lib/leaflet.draw/src/edit/handler/EditToolbar.Edit.js +56 -38
- data/lib/leaflet.draw/src/ext/GeometryUtil.js +68 -0
- data/lib/leaflet.draw/src/images/spritesheet.svg +41 -0
- data/lib/leaflet.label/CHANGELOG.md +32 -0
- data/lib/leaflet.label/README.md +21 -4
- data/lib/leaflet.label/build/build.js +2 -2
- data/lib/leaflet.label/build/deps.js +2 -0
- data/lib/leaflet.label/build/hintrc.js +4 -0
- data/lib/leaflet.label/dist/leaflet.label-src.js +266 -83
- data/lib/leaflet.label/dist/leaflet.label.css +23 -4
- data/lib/leaflet.label/dist/leaflet.label.js +1 -1
- data/lib/leaflet.label/example/label.html +6 -3
- data/lib/leaflet.label/libs/leaflet/images/layers-2x.png +0 -0
- data/lib/leaflet.label/libs/leaflet/images/layers.png +0 -0
- data/lib/leaflet.label/libs/leaflet/images/marker-icon-2x.png +0 -0
- data/lib/leaflet.label/libs/leaflet/leaflet-src.js +1129 -608
- data/lib/leaflet.label/libs/leaflet/leaflet.css +85 -66
- data/lib/leaflet.label/libs/leaflet/leaflet.js +6 -5
- data/lib/leaflet.label/package.json +19 -0
- data/lib/leaflet.label/src/BaseMarkerMethods.js +129 -0
- data/lib/leaflet.label/src/CircleMarker.Label.js +7 -0
- data/lib/leaflet.label/src/Label.js +161 -37
- data/lib/leaflet.label/src/Leaflet.label.js +1 -1
- data/lib/leaflet.label/src/Map.Label.js +0 -2
- data/lib/leaflet.label/src/Marker.Label.js +15 -120
- data/lib/leaflet.label/src/Path.Label.js +11 -11
- data/lib/leaflet/CHANGELOG.md +299 -31
- data/lib/leaflet/CONTRIBUTING.md +3 -3
- data/lib/leaflet/FAQ.md +138 -0
- data/lib/leaflet/Jakefile.js +24 -4
- data/lib/leaflet/PLUGIN-GUIDE.md +127 -0
- data/lib/leaflet/README.md +10 -6
- data/lib/leaflet/build/build.html +3 -19
- data/lib/leaflet/build/build.js +21 -51
- data/lib/leaflet/build/deps.js +10 -7
- data/lib/leaflet/build/hintrc.js +6 -4
- data/lib/leaflet/debug/hacks/jitter.html +0 -1
- data/lib/leaflet/debug/map/canvas.html +11 -12
- data/lib/leaflet/debug/map/controls.html +3 -4
- data/lib/leaflet/debug/map/geolocation.html +0 -1
- data/lib/leaflet/debug/map/iframe.html +11 -0
- data/lib/leaflet/debug/map/image-overlay.html +0 -1
- data/lib/leaflet/debug/map/map-mobile.html +0 -1
- data/lib/leaflet/debug/map/map.html +1 -2
- data/lib/leaflet/debug/map/max-bounds.html +2 -1
- data/lib/leaflet/debug/map/opacity.html +223 -0
- data/lib/leaflet/debug/map/scroll.html +6 -1
- data/lib/leaflet/debug/map/simple-proj.html +0 -1
- data/lib/leaflet/debug/map/wms-marble.html +4 -5
- data/lib/leaflet/debug/map/wms.html +0 -1
- data/lib/leaflet/debug/map/zoomlevels.html +0 -1
- data/lib/leaflet/debug/tests/add_remove_layers.html +5 -6
- data/lib/leaflet/debug/tests/bringtoback.html +0 -1
- data/lib/leaflet/debug/tests/canvasloop.html +47 -0
- data/lib/leaflet/debug/tests/click_on_canvas.html +0 -1
- data/lib/leaflet/debug/tests/dragging_and_copyworldjump.html +61 -0
- data/lib/leaflet/debug/tests/opacity.html +0 -1
- data/lib/leaflet/debug/tests/popupcontextmenuclicks.html +59 -0
- data/lib/leaflet/debug/tests/remove_while_dragging.html +4 -5
- data/lib/leaflet/debug/tests/removetilewhilepan.html +0 -1
- data/lib/leaflet/debug/tests/reuse_popups.html +0 -1
- data/lib/leaflet/debug/tests/rtl.html +42 -0
- data/lib/leaflet/debug/tests/rtl2.html +27 -0
- data/lib/leaflet/debug/tests/set_icon_reuse_dom.html +43 -0
- data/lib/leaflet/debug/tests/svg_clicks.html +3 -4
- data/lib/leaflet/debug/vector/bounds-extend.html +0 -1
- data/lib/leaflet/debug/vector/feature-group-bounds.html +0 -1
- data/lib/leaflet/debug/vector/geojson.html +0 -1
- data/lib/leaflet/debug/vector/rectangle.html +0 -1
- data/lib/leaflet/debug/vector/touchzoomemu.html +2 -3
- data/lib/leaflet/debug/vector/vector-bounds.html +0 -1
- data/lib/leaflet/debug/vector/vector-canvas.html +0 -1
- data/lib/leaflet/debug/vector/vector-mobile.html +0 -1
- data/lib/leaflet/debug/vector/vector-simple.html +0 -1
- data/lib/leaflet/debug/vector/vector.html +0 -1
- data/lib/leaflet/dist/images/layers-2x.png +0 -0
- data/lib/leaflet/dist/images/layers.png +0 -0
- data/lib/leaflet/dist/leaflet.css +85 -66
- data/lib/leaflet/package.json +25 -20
- data/lib/leaflet/spec/after.js +1 -1
- data/lib/leaflet/spec/index.html +21 -13
- data/lib/leaflet/spec/karma.conf.js +51 -50
- data/lib/leaflet/spec/spec.hintrc.js +25 -0
- data/lib/leaflet/spec/suites/LeafletSpec.js +2 -2
- data/lib/leaflet/spec/suites/SpecHelper.js +37 -21
- data/lib/leaflet/spec/suites/control/Control.LayersSpec.js +1 -1
- data/lib/leaflet/spec/suites/core/ClassSpec.js +12 -12
- data/lib/leaflet/spec/suites/core/EventsSpec.js +74 -18
- data/lib/leaflet/spec/suites/core/UtilSpec.js +69 -25
- data/lib/leaflet/spec/suites/dom/DomEventSpec.js +16 -16
- data/lib/leaflet/spec/suites/dom/DomUtilSpec.js +9 -16
- data/lib/leaflet/spec/suites/dom/PosAnimationSpec.js +27 -0
- data/lib/leaflet/spec/suites/geo/CRSSpec.js +47 -0
- data/lib/leaflet/spec/suites/geo/LatLngBoundsSpec.js +22 -14
- data/lib/leaflet/spec/suites/geo/LatLngSpec.js +22 -8
- data/lib/leaflet/spec/suites/geo/ProjectionSpec.js +21 -20
- data/lib/leaflet/spec/suites/geometry/BoundsSpec.js +15 -15
- data/lib/leaflet/spec/suites/geometry/PointSpec.js +12 -12
- data/lib/leaflet/spec/suites/geometry/TransformationSpec.js +4 -4
- data/lib/leaflet/spec/suites/layer/FeatureGroupSpec.js +59 -9
- data/lib/leaflet/spec/suites/layer/GeoJSONSpec.js +213 -17
- data/lib/leaflet/spec/suites/layer/LayerGroupSpec.js +6 -6
- data/lib/leaflet/spec/suites/layer/PopupSpec.js +65 -5
- data/lib/leaflet/spec/suites/layer/TileLayerSpec.js +16 -15
- data/lib/leaflet/spec/suites/layer/marker/MarkerSpec.js +94 -0
- data/lib/leaflet/spec/suites/layer/vector/CircleMarkerSpec.js +7 -7
- data/lib/leaflet/spec/suites/layer/vector/PolygonSpec.js +38 -2
- data/lib/leaflet/spec/suites/layer/vector/PolylineGeometrySpec.js +4 -4
- data/lib/leaflet/spec/suites/layer/vector/PolylineSpec.js +2 -2
- data/lib/leaflet/spec/suites/map/MapSpec.js +318 -26
- data/lib/leaflet/spec/suites/map/handler/Map.DragSpec.js +38 -0
- data/lib/leaflet/src/Leaflet.js +2 -2
- data/lib/leaflet/src/control/Control.Attribution.js +6 -0
- data/lib/leaflet/src/control/Control.Layers.js +33 -24
- data/lib/leaflet/src/control/Control.Zoom.js +12 -4
- data/lib/leaflet/src/control/Control.js +10 -0
- data/lib/leaflet/src/copyright.js +2 -1
- data/lib/leaflet/src/core/Browser.js +11 -10
- data/lib/leaflet/src/core/Events.js +15 -11
- data/lib/leaflet/src/core/Util.js +19 -14
- data/lib/leaflet/src/dom/DomEvent.DoubleTap.js +13 -12
- data/lib/leaflet/src/dom/DomEvent.Pointer.js +155 -0
- data/lib/leaflet/src/dom/DomEvent.js +57 -19
- data/lib/leaflet/src/dom/DomUtil.js +89 -34
- data/lib/leaflet/src/dom/Draggable.js +26 -89
- data/lib/leaflet/src/dom/PosAnimation.js +13 -2
- data/lib/leaflet/src/geo/LatLng.js +16 -5
- data/lib/leaflet/src/geo/LatLngBounds.js +5 -2
- data/lib/leaflet/src/geo/crs/CRS.EPSG3395.js +2 -2
- data/lib/leaflet/src/geo/crs/CRS.js +5 -0
- data/lib/leaflet/src/geo/projection/Projection.Mercator.js +3 -3
- data/lib/leaflet/src/geometry/LineUtil.js +2 -2
- data/lib/leaflet/src/images/layers.svg +8 -0
- data/lib/leaflet/src/images/marker.svg +61 -1
- data/lib/leaflet/src/layer/FeatureGroup.js +24 -7
- data/lib/leaflet/src/layer/GeoJSON.js +97 -56
- data/lib/leaflet/src/layer/ImageOverlay.js +9 -0
- data/lib/leaflet/src/layer/LayerGroup.js +8 -3
- data/lib/leaflet/src/layer/Popup.js +56 -34
- data/lib/leaflet/src/layer/marker/DivIcon.js +4 -2
- data/lib/leaflet/src/layer/marker/Icon.Default.js +1 -1
- data/lib/leaflet/src/layer/marker/Icon.js +15 -18
- data/lib/leaflet/src/layer/marker/Marker.Drag.js +7 -5
- data/lib/leaflet/src/layer/marker/Marker.Popup.js +22 -5
- data/lib/leaflet/src/layer/marker/Marker.js +75 -32
- data/lib/leaflet/src/layer/tile/TileLayer.Anim.js +14 -26
- data/lib/leaflet/src/layer/tile/TileLayer.Canvas.js +7 -6
- data/lib/leaflet/src/layer/tile/TileLayer.WMS.js +14 -10
- data/lib/leaflet/src/layer/tile/TileLayer.js +53 -32
- data/lib/leaflet/src/layer/vector/CircleMarker.js +11 -0
- data/lib/leaflet/src/layer/vector/MultiPoly.js +10 -0
- data/lib/leaflet/src/layer/vector/Path.SVG.js +14 -3
- data/lib/leaflet/src/layer/vector/Path.VML.js +12 -2
- data/lib/leaflet/src/layer/vector/Path.js +7 -3
- data/lib/leaflet/src/layer/vector/Polygon.js +14 -3
- data/lib/leaflet/src/layer/vector/canvas/CircleMarker.Canvas.js +9 -0
- data/lib/leaflet/src/layer/vector/canvas/Path.Canvas.js +1 -0
- data/lib/leaflet/src/map/Map.js +192 -125
- data/lib/leaflet/src/map/anim/Map.PanAnimation.js +29 -19
- data/lib/leaflet/src/map/anim/Map.ZoomAnimation.js +21 -9
- data/lib/leaflet/src/map/ext/Map.Geolocation.js +11 -4
- data/lib/leaflet/src/map/handler/Map.BoxZoom.js +26 -12
- data/lib/leaflet/src/map/handler/Map.DoubleClickZoom.js +10 -3
- data/lib/leaflet/src/map/handler/Map.Drag.js +12 -6
- data/lib/leaflet/src/map/handler/Map.Keyboard.js +5 -2
- data/lib/leaflet/src/map/handler/Map.ScrollWheelZoom.js +7 -1
- data/lib/leaflet/src/map/handler/Map.Tap.js +107 -0
- data/lib/leaflet/src/map/handler/Map.TouchZoom.js +9 -3
- data/vendor/assets/images/layers-2x.png +0 -0
- data/vendor/assets/images/layers.png +0 -0
- data/vendor/assets/images/spritesheet-2x.png +0 -0
- data/vendor/assets/images/spritesheet.png +0 -0
- data/vendor/assets/javascripts/leaflet.draw.js +2 -4
- data/vendor/assets/javascripts/leaflet.js +3 -1
- data/vendor/assets/javascripts/leaflet.label.js +2 -0
- data/vendor/assets/stylesheets/leaflet.css.erb +337 -318
- data/vendor/assets/stylesheets/leaflet.draw.css.erb +35 -3
- data/vendor/assets/stylesheets/leaflet.draw.ie.css +5 -0
- data/vendor/assets/stylesheets/leaflet.label.css +23 -4
- metadata +40 -14
- data/lib/leaflet.draw/examples/libs/leaflet.ie.css +0 -51
- data/lib/leaflet.label/libs/leaflet/leaflet.ie.css +0 -51
- data/lib/leaflet/dist/leaflet-src.js +0 -8579
- data/lib/leaflet/dist/leaflet.ie.css +0 -51
- data/lib/leaflet/dist/leaflet.js +0 -8
- data/lib/leaflet/spec/happen.js +0 -93
- data/lib/leaflet/src/dom/DomEvent.MsTouch.js +0 -146
- data/vendor/assets/stylesheets/leaflet.ie.css +0 -51
@@ -16,12 +16,13 @@ L.GeoJSON = L.FeatureGroup.extend({
|
|
16
16
|
|
17
17
|
addData: function (geojson) {
|
18
18
|
var features = L.Util.isArray(geojson) ? geojson : geojson.features,
|
19
|
-
i, len;
|
19
|
+
i, len, feature;
|
20
20
|
|
21
21
|
if (features) {
|
22
22
|
for (i = 0, len = features.length; i < len; i++) {
|
23
23
|
// Only add this if geometry or geometries are set and not null
|
24
|
-
|
24
|
+
feature = features[i];
|
25
|
+
if (feature.geometries || feature.geometry || feature.features || feature.coordinates) {
|
25
26
|
this.addData(features[i]);
|
26
27
|
}
|
27
28
|
}
|
@@ -32,8 +33,8 @@ L.GeoJSON = L.FeatureGroup.extend({
|
|
32
33
|
|
33
34
|
if (options.filter && !options.filter(geojson)) { return; }
|
34
35
|
|
35
|
-
var layer = L.GeoJSON.geometryToLayer(geojson, options.pointToLayer, options.coordsToLatLng);
|
36
|
-
layer.feature = geojson;
|
36
|
+
var layer = L.GeoJSON.geometryToLayer(geojson, options.pointToLayer, options.coordsToLatLng, options);
|
37
|
+
layer.feature = L.GeoJSON.asFeature(geojson);
|
37
38
|
|
38
39
|
layer.defaultOptions = layer.options;
|
39
40
|
this.resetStyle(layer);
|
@@ -72,11 +73,11 @@ L.GeoJSON = L.FeatureGroup.extend({
|
|
72
73
|
});
|
73
74
|
|
74
75
|
L.extend(L.GeoJSON, {
|
75
|
-
geometryToLayer: function (geojson, pointToLayer, coordsToLatLng) {
|
76
|
+
geometryToLayer: function (geojson, pointToLayer, coordsToLatLng, vectorOptions) {
|
76
77
|
var geometry = geojson.type === 'Feature' ? geojson.geometry : geojson,
|
77
78
|
coords = geometry.coordinates,
|
78
79
|
layers = [],
|
79
|
-
latlng, latlngs, i, len
|
80
|
+
latlng, latlngs, i, len;
|
80
81
|
|
81
82
|
coordsToLatLng = coordsToLatLng || this.coordsToLatLng;
|
82
83
|
|
@@ -88,37 +89,37 @@ L.extend(L.GeoJSON, {
|
|
88
89
|
case 'MultiPoint':
|
89
90
|
for (i = 0, len = coords.length; i < len; i++) {
|
90
91
|
latlng = coordsToLatLng(coords[i]);
|
91
|
-
|
92
|
-
layers.push(layer);
|
92
|
+
layers.push(pointToLayer ? pointToLayer(geojson, latlng) : new L.Marker(latlng));
|
93
93
|
}
|
94
94
|
return new L.FeatureGroup(layers);
|
95
95
|
|
96
96
|
case 'LineString':
|
97
97
|
latlngs = this.coordsToLatLngs(coords, 0, coordsToLatLng);
|
98
|
-
return new L.Polyline(latlngs);
|
98
|
+
return new L.Polyline(latlngs, vectorOptions);
|
99
99
|
|
100
100
|
case 'Polygon':
|
101
|
+
if (coords.length === 2 && !coords[1].length) {
|
102
|
+
throw new Error('Invalid GeoJSON object.');
|
103
|
+
}
|
101
104
|
latlngs = this.coordsToLatLngs(coords, 1, coordsToLatLng);
|
102
|
-
return new L.Polygon(latlngs);
|
105
|
+
return new L.Polygon(latlngs, vectorOptions);
|
103
106
|
|
104
107
|
case 'MultiLineString':
|
105
108
|
latlngs = this.coordsToLatLngs(coords, 1, coordsToLatLng);
|
106
|
-
return new L.MultiPolyline(latlngs);
|
109
|
+
return new L.MultiPolyline(latlngs, vectorOptions);
|
107
110
|
|
108
111
|
case 'MultiPolygon':
|
109
112
|
latlngs = this.coordsToLatLngs(coords, 2, coordsToLatLng);
|
110
|
-
return new L.MultiPolygon(latlngs);
|
113
|
+
return new L.MultiPolygon(latlngs, vectorOptions);
|
111
114
|
|
112
115
|
case 'GeometryCollection':
|
113
116
|
for (i = 0, len = geometry.geometries.length; i < len; i++) {
|
114
117
|
|
115
|
-
|
118
|
+
layers.push(this.geometryToLayer({
|
116
119
|
geometry: geometry.geometries[i],
|
117
120
|
type: 'Feature',
|
118
121
|
properties: geojson.properties
|
119
|
-
}, pointToLayer);
|
120
|
-
|
121
|
-
layers.push(layer);
|
122
|
+
}, pointToLayer, coordsToLatLng, vectorOptions));
|
122
123
|
}
|
123
124
|
return new L.FeatureGroup(layers);
|
124
125
|
|
@@ -128,7 +129,7 @@ L.extend(L.GeoJSON, {
|
|
128
129
|
},
|
129
130
|
|
130
131
|
coordsToLatLng: function (coords) { // (Array[, Boolean]) -> LatLng
|
131
|
-
return new L.LatLng(coords[1], coords[0]);
|
132
|
+
return new L.LatLng(coords[1], coords[0], coords[2]);
|
132
133
|
},
|
133
134
|
|
134
135
|
coordsToLatLngs: function (coords, levelsDeep, coordsToLatLng) { // (Array[, Number, Function]) -> Array
|
@@ -146,8 +147,13 @@ L.extend(L.GeoJSON, {
|
|
146
147
|
return latlngs;
|
147
148
|
},
|
148
149
|
|
149
|
-
latLngToCoords: function (
|
150
|
-
|
150
|
+
latLngToCoords: function (latlng) {
|
151
|
+
var coords = [latlng.lng, latlng.lat];
|
152
|
+
|
153
|
+
if (latlng.alt !== undefined) {
|
154
|
+
coords.push(latlng.alt);
|
155
|
+
}
|
156
|
+
return coords;
|
151
157
|
},
|
152
158
|
|
153
159
|
latLngsToCoords: function (latLngs) {
|
@@ -158,24 +164,44 @@ L.extend(L.GeoJSON, {
|
|
158
164
|
}
|
159
165
|
|
160
166
|
return coords;
|
167
|
+
},
|
168
|
+
|
169
|
+
getFeature: function (layer, newGeometry) {
|
170
|
+
return layer.feature ? L.extend({}, layer.feature, {geometry: newGeometry}) : L.GeoJSON.asFeature(newGeometry);
|
171
|
+
},
|
172
|
+
|
173
|
+
asFeature: function (geoJSON) {
|
174
|
+
if (geoJSON.type === 'Feature') {
|
175
|
+
return geoJSON;
|
176
|
+
}
|
177
|
+
|
178
|
+
return {
|
179
|
+
type: 'Feature',
|
180
|
+
properties: {},
|
181
|
+
geometry: geoJSON
|
182
|
+
};
|
161
183
|
}
|
162
184
|
});
|
163
185
|
|
164
|
-
|
186
|
+
var PointToGeoJSON = {
|
165
187
|
toGeoJSON: function () {
|
166
|
-
return {
|
188
|
+
return L.GeoJSON.getFeature(this, {
|
167
189
|
type: 'Point',
|
168
190
|
coordinates: L.GeoJSON.latLngToCoords(this.getLatLng())
|
169
|
-
};
|
191
|
+
});
|
170
192
|
}
|
171
|
-
}
|
193
|
+
};
|
194
|
+
|
195
|
+
L.Marker.include(PointToGeoJSON);
|
196
|
+
L.Circle.include(PointToGeoJSON);
|
197
|
+
L.CircleMarker.include(PointToGeoJSON);
|
172
198
|
|
173
199
|
L.Polyline.include({
|
174
200
|
toGeoJSON: function () {
|
175
|
-
return {
|
201
|
+
return L.GeoJSON.getFeature(this, {
|
176
202
|
type: 'LineString',
|
177
203
|
coordinates: L.GeoJSON.latLngsToCoords(this.getLatLngs())
|
178
|
-
};
|
204
|
+
});
|
179
205
|
}
|
180
206
|
});
|
181
207
|
|
@@ -194,51 +220,66 @@ L.Polygon.include({
|
|
194
220
|
}
|
195
221
|
}
|
196
222
|
|
197
|
-
return {
|
223
|
+
return L.GeoJSON.getFeature(this, {
|
198
224
|
type: 'Polygon',
|
199
225
|
coordinates: coords
|
200
|
-
};
|
226
|
+
});
|
201
227
|
}
|
202
228
|
});
|
203
229
|
|
204
230
|
(function () {
|
205
|
-
function
|
206
|
-
|
207
|
-
|
208
|
-
|
231
|
+
function multiToGeoJSON(type) {
|
232
|
+
return function () {
|
233
|
+
var coords = [];
|
234
|
+
|
235
|
+
this.eachLayer(function (layer) {
|
236
|
+
coords.push(layer.toGeoJSON().geometry.coordinates);
|
237
|
+
});
|
238
|
+
|
239
|
+
return L.GeoJSON.getFeature(this, {
|
240
|
+
type: type,
|
241
|
+
coordinates: coords
|
242
|
+
});
|
243
|
+
};
|
244
|
+
}
|
209
245
|
|
210
|
-
|
211
|
-
|
212
|
-
});
|
246
|
+
L.MultiPolyline.include({toGeoJSON: multiToGeoJSON('MultiLineString')});
|
247
|
+
L.MultiPolygon.include({toGeoJSON: multiToGeoJSON('MultiPolygon')});
|
213
248
|
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
249
|
+
L.LayerGroup.include({
|
250
|
+
toGeoJSON: function () {
|
251
|
+
|
252
|
+
var geometry = this.feature && this.feature.geometry,
|
253
|
+
jsons = [],
|
254
|
+
json;
|
255
|
+
|
256
|
+
if (geometry && geometry.type === 'MultiPoint') {
|
257
|
+
return multiToGeoJSON('MultiPoint').call(this);
|
218
258
|
}
|
219
|
-
});
|
220
|
-
}
|
221
259
|
|
222
|
-
|
223
|
-
includeMulti(L.MultiPolygon, 'MultiPolygon');
|
224
|
-
}());
|
260
|
+
var isGeometryCollection = geometry && geometry.type === 'GeometryCollection';
|
225
261
|
|
226
|
-
|
227
|
-
|
228
|
-
|
262
|
+
this.eachLayer(function (layer) {
|
263
|
+
if (layer.toGeoJSON) {
|
264
|
+
json = layer.toGeoJSON();
|
265
|
+
jsons.push(isGeometryCollection ? json.geometry : L.GeoJSON.asFeature(json));
|
266
|
+
}
|
267
|
+
});
|
229
268
|
|
230
|
-
|
231
|
-
|
232
|
-
|
269
|
+
if (isGeometryCollection) {
|
270
|
+
return L.GeoJSON.getFeature(this, {
|
271
|
+
geometries: jsons,
|
272
|
+
type: 'GeometryCollection'
|
273
|
+
});
|
233
274
|
}
|
234
|
-
});
|
235
275
|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
});
|
276
|
+
return {
|
277
|
+
type: 'FeatureCollection',
|
278
|
+
features: jsons
|
279
|
+
};
|
280
|
+
}
|
281
|
+
});
|
282
|
+
}());
|
242
283
|
|
243
284
|
L.geoJson = function (geojson, options) {
|
244
285
|
return new L.GeoJSON(geojson, options);
|
@@ -71,6 +71,15 @@ L.ImageOverlay = L.Class.extend({
|
|
71
71
|
return this;
|
72
72
|
},
|
73
73
|
|
74
|
+
setUrl: function (url) {
|
75
|
+
this._url = url;
|
76
|
+
this._image.src = this._url;
|
77
|
+
},
|
78
|
+
|
79
|
+
getAttribution: function () {
|
80
|
+
return this.options.attribution;
|
81
|
+
},
|
82
|
+
|
74
83
|
_initImage: function () {
|
75
84
|
this._image = L.DomUtil.create('img', 'leaflet-image-layer');
|
76
85
|
|
@@ -29,10 +29,10 @@ L.LayerGroup = L.Class.extend({
|
|
29
29
|
},
|
30
30
|
|
31
31
|
removeLayer: function (layer) {
|
32
|
-
var id = this.getLayerId(layer);
|
32
|
+
var id = layer in this._layers ? layer : this.getLayerId(layer);
|
33
33
|
|
34
34
|
if (this._map && this._layers[id]) {
|
35
|
-
this._map.removeLayer(
|
35
|
+
this._map.removeLayer(this._layers[id]);
|
36
36
|
}
|
37
37
|
|
38
38
|
delete this._layers[id];
|
@@ -43,7 +43,7 @@ L.LayerGroup = L.Class.extend({
|
|
43
43
|
hasLayer: function (layer) {
|
44
44
|
if (!layer) { return false; }
|
45
45
|
|
46
|
-
return (this.getLayerId(layer) in this._layers);
|
46
|
+
return (layer in this._layers || this.getLayerId(layer) in this._layers);
|
47
47
|
},
|
48
48
|
|
49
49
|
clearLayers: function () {
|
@@ -88,8 +88,13 @@ L.LayerGroup = L.Class.extend({
|
|
88
88
|
return this;
|
89
89
|
},
|
90
90
|
|
91
|
+
getLayer: function (id) {
|
92
|
+
return this._layers[id];
|
93
|
+
},
|
94
|
+
|
91
95
|
getLayers: function () {
|
92
96
|
var layers = [];
|
97
|
+
|
93
98
|
for (var i in this._layers) {
|
94
99
|
layers.push(this._layers[i]);
|
95
100
|
}
|
@@ -12,11 +12,13 @@ L.Popup = L.Class.extend({
|
|
12
12
|
options: {
|
13
13
|
minWidth: 50,
|
14
14
|
maxWidth: 300,
|
15
|
-
maxHeight: null,
|
15
|
+
// maxHeight: null,
|
16
16
|
autoPan: true,
|
17
17
|
closeButton: true,
|
18
|
-
offset: [0,
|
18
|
+
offset: [0, 7],
|
19
19
|
autoPanPadding: [5, 5],
|
20
|
+
// autoPanPaddingTopLeft: null,
|
21
|
+
// autoPanPaddingBottomRight: null,
|
20
22
|
keepInView: false,
|
21
23
|
className: '',
|
22
24
|
zoomAnimation: true
|
@@ -27,6 +29,7 @@ L.Popup = L.Class.extend({
|
|
27
29
|
|
28
30
|
this._source = source;
|
29
31
|
this._animated = L.Browser.any3d && this.options.zoomAnimation;
|
32
|
+
this._isOpen = false;
|
30
33
|
},
|
31
34
|
|
32
35
|
onAdd: function (map) {
|
@@ -35,7 +38,6 @@ L.Popup = L.Class.extend({
|
|
35
38
|
if (!this._container) {
|
36
39
|
this._initLayout();
|
37
40
|
}
|
38
|
-
this._updateContent();
|
39
41
|
|
40
42
|
var animFade = map.options.fadeAnimation;
|
41
43
|
|
@@ -46,7 +48,7 @@ L.Popup = L.Class.extend({
|
|
46
48
|
|
47
49
|
map.on(this._getEvents(), this);
|
48
50
|
|
49
|
-
this.
|
51
|
+
this.update();
|
50
52
|
|
51
53
|
if (animFade) {
|
52
54
|
L.DomUtil.setOpacity(this._container, 1);
|
@@ -93,18 +95,43 @@ L.Popup = L.Class.extend({
|
|
93
95
|
}
|
94
96
|
},
|
95
97
|
|
98
|
+
getLatLng: function () {
|
99
|
+
return this._latlng;
|
100
|
+
},
|
101
|
+
|
96
102
|
setLatLng: function (latlng) {
|
97
103
|
this._latlng = L.latLng(latlng);
|
98
|
-
this.
|
104
|
+
if (this._map) {
|
105
|
+
this._updatePosition();
|
106
|
+
this._adjustPan();
|
107
|
+
}
|
99
108
|
return this;
|
100
109
|
},
|
101
110
|
|
111
|
+
getContent: function () {
|
112
|
+
return this._content;
|
113
|
+
},
|
114
|
+
|
102
115
|
setContent: function (content) {
|
103
116
|
this._content = content;
|
104
|
-
this.
|
117
|
+
this.update();
|
105
118
|
return this;
|
106
119
|
},
|
107
120
|
|
121
|
+
update: function () {
|
122
|
+
if (!this._map) { return; }
|
123
|
+
|
124
|
+
this._container.style.visibility = 'hidden';
|
125
|
+
|
126
|
+
this._updateContent();
|
127
|
+
this._updateLayout();
|
128
|
+
this._updatePosition();
|
129
|
+
|
130
|
+
this._container.style.visibility = '';
|
131
|
+
|
132
|
+
this._adjustPan();
|
133
|
+
},
|
134
|
+
|
108
135
|
_getEvents: function () {
|
109
136
|
var events = {
|
110
137
|
viewreset: this._updatePosition
|
@@ -113,7 +140,7 @@ L.Popup = L.Class.extend({
|
|
113
140
|
if (this._animated) {
|
114
141
|
events.zoomanim = this._zoomAnimation;
|
115
142
|
}
|
116
|
-
if (this._map.options.closePopupOnClick) {
|
143
|
+
if ('closeOnClick' in this.options ? this.options.closeOnClick : this._map.options.closePopupOnClick) {
|
117
144
|
events.preclick = this._close;
|
118
145
|
}
|
119
146
|
if (this.options.keepInView) {
|
@@ -125,7 +152,7 @@ L.Popup = L.Class.extend({
|
|
125
152
|
|
126
153
|
_close: function () {
|
127
154
|
if (this._map) {
|
128
|
-
this._map.
|
155
|
+
this._map.closePopup(this);
|
129
156
|
}
|
130
157
|
},
|
131
158
|
|
@@ -151,26 +178,14 @@ L.Popup = L.Class.extend({
|
|
151
178
|
L.DomEvent.disableClickPropagation(wrapper);
|
152
179
|
|
153
180
|
this._contentNode = L.DomUtil.create('div', prefix + '-content', wrapper);
|
154
|
-
|
181
|
+
|
182
|
+
L.DomEvent.disableScrollPropagation(this._contentNode);
|
183
|
+
L.DomEvent.on(wrapper, 'contextmenu', L.DomEvent.stopPropagation);
|
155
184
|
|
156
185
|
this._tipContainer = L.DomUtil.create('div', prefix + '-tip-container', container);
|
157
186
|
this._tip = L.DomUtil.create('div', prefix + '-tip', this._tipContainer);
|
158
187
|
},
|
159
188
|
|
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
189
|
_updateContent: function () {
|
175
190
|
if (!this._content) { return; }
|
176
191
|
|
@@ -255,21 +270,23 @@ L.Popup = L.Class.extend({
|
|
255
270
|
|
256
271
|
var containerPos = map.layerPointToContainerPoint(layerPos),
|
257
272
|
padding = L.point(this.options.autoPanPadding),
|
273
|
+
paddingTL = L.point(this.options.autoPanPaddingTopLeft || padding),
|
274
|
+
paddingBR = L.point(this.options.autoPanPaddingBottomRight || padding),
|
258
275
|
size = map.getSize(),
|
259
276
|
dx = 0,
|
260
277
|
dy = 0;
|
261
278
|
|
262
|
-
if (containerPos.x + containerWidth > size.x) { // right
|
263
|
-
dx = containerPos.x + containerWidth - size.x +
|
279
|
+
if (containerPos.x + containerWidth + paddingBR.x > size.x) { // right
|
280
|
+
dx = containerPos.x + containerWidth - size.x + paddingBR.x;
|
264
281
|
}
|
265
|
-
if (containerPos.x - dx < 0) { // left
|
266
|
-
dx = containerPos.x -
|
282
|
+
if (containerPos.x - dx - paddingTL.x < 0) { // left
|
283
|
+
dx = containerPos.x - paddingTL.x;
|
267
284
|
}
|
268
|
-
if (containerPos.y + containerHeight > size.y) { // bottom
|
269
|
-
dy = containerPos.y + containerHeight - size.y +
|
285
|
+
if (containerPos.y + containerHeight + paddingBR.y > size.y) { // bottom
|
286
|
+
dy = containerPos.y + containerHeight - size.y + paddingBR.y;
|
270
287
|
}
|
271
|
-
if (containerPos.y - dy < 0) { // top
|
272
|
-
dy = containerPos.y -
|
288
|
+
if (containerPos.y - dy - paddingTL.y < 0) { // top
|
289
|
+
dy = containerPos.y - paddingTL.y;
|
273
290
|
}
|
274
291
|
|
275
292
|
if (dx || dy) {
|
@@ -301,16 +318,21 @@ L.Map.include({
|
|
301
318
|
.setLatLng(latlng)
|
302
319
|
.setContent(content);
|
303
320
|
}
|
321
|
+
popup._isOpen = true;
|
304
322
|
|
305
323
|
this._popup = popup;
|
306
324
|
return this.addLayer(popup);
|
307
325
|
},
|
308
326
|
|
309
|
-
closePopup: function () {
|
310
|
-
if (this._popup) {
|
311
|
-
this.
|
327
|
+
closePopup: function (popup) {
|
328
|
+
if (!popup || popup === this._popup) {
|
329
|
+
popup = this._popup;
|
312
330
|
this._popup = null;
|
313
331
|
}
|
332
|
+
if (popup) {
|
333
|
+
this.removeLayer(popup);
|
334
|
+
popup._isOpen = false;
|
335
|
+
}
|
314
336
|
return this;
|
315
337
|
}
|
316
338
|
});
|