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,35 @@
|
|
1
|
+
describe('PolylineGeometry', function() {
|
2
|
+
|
3
|
+
var c = document.createElement('div');
|
4
|
+
c.style.width = '400px';
|
5
|
+
c.style.height = '400px';
|
6
|
+
var map = new L.Map(c);
|
7
|
+
map.setView(new L.LatLng(55.8, 37.6), 6);
|
8
|
+
|
9
|
+
describe("#distanceTo", function() {
|
10
|
+
it("calculates distances to points", function() {
|
11
|
+
var p1 = map.latLngToLayerPoint(new L.LatLng(55.8, 37.6));
|
12
|
+
var p2 = map.latLngToLayerPoint(new L.LatLng(57.123076977278, 44.861962891635));
|
13
|
+
var latlngs = [[56.485503424111, 35.545556640339], [55.972522915346, 36.116845702918], [55.502459116923, 34.930322265253], [55.31534617509, 38.973291015816]]
|
14
|
+
.map(function(ll) {
|
15
|
+
return new L.LatLng(ll[0], ll[1]);
|
16
|
+
});
|
17
|
+
var polyline = new L.Polyline([], {
|
18
|
+
'noClip': true
|
19
|
+
});
|
20
|
+
map.addLayer(polyline);
|
21
|
+
|
22
|
+
expect(polyline.closestLayerPoint(p1)).to.be(null);
|
23
|
+
|
24
|
+
polyline.setLatLngs(latlngs);
|
25
|
+
var point = polyline.closestLayerPoint(p1);
|
26
|
+
expect(point).not.to.be(null);
|
27
|
+
expect(point.distance).to.not.be(Infinity);
|
28
|
+
expect(point.distance).to.not.be(NaN);
|
29
|
+
|
30
|
+
var point2 = polyline.closestLayerPoint(p2);
|
31
|
+
|
32
|
+
expect(point.distance).to.be.lessThan(point2.distance);
|
33
|
+
});
|
34
|
+
});
|
35
|
+
});
|
@@ -0,0 +1,55 @@
|
|
1
|
+
describe('Polyline', function() {
|
2
|
+
|
3
|
+
var c = document.createElement('div');
|
4
|
+
c.style.width = '400px';
|
5
|
+
c.style.height = '400px';
|
6
|
+
var map = new L.Map(c);
|
7
|
+
map.setView(new L.LatLng(55.8, 37.6), 6);
|
8
|
+
|
9
|
+
describe("#initialize", function() {
|
10
|
+
it("doesn't overwrite the given latlng array", function () {
|
11
|
+
var originalLatLngs = [
|
12
|
+
[1, 2],
|
13
|
+
[3, 4]
|
14
|
+
];
|
15
|
+
var sourceLatLngs = originalLatLngs.slice();
|
16
|
+
|
17
|
+
var polyline = new L.Polyline(sourceLatLngs);
|
18
|
+
|
19
|
+
expect(sourceLatLngs).to.eql(originalLatLngs);
|
20
|
+
expect(polyline._latlngs).to.not.eql(sourceLatLngs);
|
21
|
+
});
|
22
|
+
});
|
23
|
+
|
24
|
+
describe("#setLatLngs", function () {
|
25
|
+
it("doesn't overwrite the given latlng array", function () {
|
26
|
+
var originalLatLngs = [
|
27
|
+
[1, 2],
|
28
|
+
[3, 4]
|
29
|
+
];
|
30
|
+
var sourceLatLngs = originalLatLngs.slice();
|
31
|
+
|
32
|
+
var polyline = new L.Polyline(sourceLatLngs);
|
33
|
+
|
34
|
+
polyline.setLatLngs(sourceLatLngs);
|
35
|
+
|
36
|
+
expect(sourceLatLngs).to.eql(originalLatLngs);
|
37
|
+
});
|
38
|
+
});
|
39
|
+
|
40
|
+
describe("#spliceLatLngs", function () {
|
41
|
+
it("splices the internal latLngs", function () {
|
42
|
+
var latLngs = [
|
43
|
+
[1, 2],
|
44
|
+
[3, 4],
|
45
|
+
[5, 6]
|
46
|
+
];
|
47
|
+
|
48
|
+
var polyline = new L.Polyline(latLngs);
|
49
|
+
|
50
|
+
polyline.spliceLatLngs(1, 1, [7, 8]);
|
51
|
+
|
52
|
+
expect(polyline._latlngs).to.eql([L.latLng([1, 2]), L.latLng([7, 8]), L.latLng([5, 6])]);
|
53
|
+
});
|
54
|
+
});
|
55
|
+
});
|
@@ -0,0 +1,244 @@
|
|
1
|
+
describe("Map", function () {
|
2
|
+
var map,
|
3
|
+
spy;
|
4
|
+
beforeEach(function () {
|
5
|
+
map = L.map(document.createElement('div'));
|
6
|
+
});
|
7
|
+
|
8
|
+
describe("#remove", function () {
|
9
|
+
it("fires an unload event if loaded", function () {
|
10
|
+
var container = document.createElement('div'),
|
11
|
+
map = new L.Map(container).setView([0, 0], 0),
|
12
|
+
spy = sinon.spy();
|
13
|
+
map.on('unload', spy);
|
14
|
+
map.remove();
|
15
|
+
expect(spy.called).to.be.ok();
|
16
|
+
});
|
17
|
+
|
18
|
+
it("fires no unload event if not loaded", function () {
|
19
|
+
var container = document.createElement('div'),
|
20
|
+
map = new L.Map(container),
|
21
|
+
spy = sinon.spy();
|
22
|
+
map.on('unload', spy);
|
23
|
+
map.remove();
|
24
|
+
expect(spy.called).not.to.be.ok();
|
25
|
+
});
|
26
|
+
|
27
|
+
describe("corner case checking", function () {
|
28
|
+
it("throws an exception upon reinitialization", function () {
|
29
|
+
var container = document.createElement('div'),
|
30
|
+
map = new L.Map(container);
|
31
|
+
expect(function () {
|
32
|
+
new L.Map(container);
|
33
|
+
}).to.throwException(function(e) {
|
34
|
+
expect(e.message).to.eql("Map container is already initialized.");
|
35
|
+
});
|
36
|
+
map.remove();
|
37
|
+
});
|
38
|
+
|
39
|
+
it("throws an exception if a container is not found", function () {
|
40
|
+
expect(function () {
|
41
|
+
new L.Map('nonexistentdivelement');
|
42
|
+
}).to.throwException(function(e) {
|
43
|
+
expect(e.message).to.eql("Map container not found.");
|
44
|
+
});
|
45
|
+
map.remove();
|
46
|
+
});
|
47
|
+
});
|
48
|
+
|
49
|
+
it("undefines container._leaflet", function () {
|
50
|
+
var container = document.createElement('div'),
|
51
|
+
map = new L.Map(container);
|
52
|
+
map.remove();
|
53
|
+
expect(container._leaflet).to.be(undefined);
|
54
|
+
});
|
55
|
+
|
56
|
+
it("unbinds events", function () {
|
57
|
+
var container = document.createElement('div'),
|
58
|
+
map = new L.Map(container).setView([0, 0], 1),
|
59
|
+
spy = sinon.spy();
|
60
|
+
|
61
|
+
map.on('click dblclick mousedown mouseup mousemove', spy);
|
62
|
+
map.remove();
|
63
|
+
|
64
|
+
happen.click(container);
|
65
|
+
happen.dblclick(container);
|
66
|
+
happen.mousedown(container);
|
67
|
+
happen.mouseup(container);
|
68
|
+
happen.mousemove(container);
|
69
|
+
|
70
|
+
expect(spy.called).to.not.be.ok();
|
71
|
+
});
|
72
|
+
});
|
73
|
+
|
74
|
+
describe('#getCenter', function () {
|
75
|
+
it ('throws if not set before', function () {
|
76
|
+
expect(function () {
|
77
|
+
map.getCenter();
|
78
|
+
}).to.throwError();
|
79
|
+
});
|
80
|
+
});
|
81
|
+
|
82
|
+
describe("#whenReady", function () {
|
83
|
+
describe("when the map has not yet been loaded", function () {
|
84
|
+
it("calls the callback when the map is loaded", function () {
|
85
|
+
var spy = sinon.spy();
|
86
|
+
map.whenReady(spy);
|
87
|
+
expect(spy.called).to.not.be.ok();
|
88
|
+
|
89
|
+
map.setView([0, 0], 1);
|
90
|
+
expect(spy.called).to.be.ok();
|
91
|
+
});
|
92
|
+
});
|
93
|
+
|
94
|
+
describe("when the map has already been loaded", function () {
|
95
|
+
it("calls the callback immediately", function () {
|
96
|
+
var spy = sinon.spy();
|
97
|
+
map.setView([0, 0], 1);
|
98
|
+
map.whenReady(spy);
|
99
|
+
|
100
|
+
expect(spy.called).to.be.ok();
|
101
|
+
});
|
102
|
+
});
|
103
|
+
});
|
104
|
+
|
105
|
+
describe("#setView", function () {
|
106
|
+
it("sets the view of the map", function () {
|
107
|
+
expect(map.setView([51.505, -0.09], 13)).to.be(map);
|
108
|
+
expect(map.getZoom()).to.be(13);
|
109
|
+
expect(map.getCenter().distanceTo([51.505, -0.09])).to.be.lessThan(5);
|
110
|
+
});
|
111
|
+
});
|
112
|
+
|
113
|
+
describe("#getBounds", function () {
|
114
|
+
it("is safe to call from within a moveend callback during initial load (#1027)", function () {
|
115
|
+
map.on("moveend", function () {
|
116
|
+
map.getBounds();
|
117
|
+
});
|
118
|
+
|
119
|
+
map.setView([51.505, -0.09], 13);
|
120
|
+
});
|
121
|
+
});
|
122
|
+
|
123
|
+
describe("#getMinZoom and #getMaxZoom", function () {
|
124
|
+
it("minZoom and maxZoom options overrides any minZoom and maxZoom set on layers", function () {
|
125
|
+
var c = document.createElement('div'),
|
126
|
+
map = L.map(c, { minZoom: 5, maxZoom: 10 });
|
127
|
+
L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map);
|
128
|
+
L.tileLayer("{z}{x}{y}", { minZoom:5, maxZoom: 15 }).addTo(map);
|
129
|
+
expect(map.getMinZoom()).to.be(5);
|
130
|
+
expect(map.getMaxZoom()).to.be(10);
|
131
|
+
});
|
132
|
+
});
|
133
|
+
|
134
|
+
describe("#addLayer", function () {
|
135
|
+
describe("When the first layer is added to a map", function () {
|
136
|
+
it("fires a zoomlevelschange event", function () {
|
137
|
+
var spy = sinon.spy();
|
138
|
+
map.on("zoomlevelschange", spy);
|
139
|
+
expect(spy.called).not.to.be.ok();
|
140
|
+
L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map);
|
141
|
+
expect(spy.called).to.be.ok();
|
142
|
+
});
|
143
|
+
});
|
144
|
+
|
145
|
+
describe("when a new layer with greater zoomlevel coverage than the current layer is added to a map", function () {
|
146
|
+
it("fires a zoomlevelschange event", function () {
|
147
|
+
var spy = sinon.spy();
|
148
|
+
L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map);
|
149
|
+
map.on("zoomlevelschange", spy);
|
150
|
+
expect(spy.called).not.to.be.ok();
|
151
|
+
L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 15 }).addTo(map);
|
152
|
+
expect(spy.called).to.be.ok();
|
153
|
+
});
|
154
|
+
});
|
155
|
+
|
156
|
+
describe("when a new layer with the same or lower zoomlevel coverage as the current layer is added to a map", function () {
|
157
|
+
it("fires no zoomlevelschange event", function () {
|
158
|
+
var spy = sinon.spy();
|
159
|
+
L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map);
|
160
|
+
map.on("zoomlevelschange", spy);
|
161
|
+
expect(spy.called).not.to.be.ok();
|
162
|
+
L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map);
|
163
|
+
expect(spy.called).not.to.be.ok();
|
164
|
+
L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 5 }).addTo(map);
|
165
|
+
expect(spy.called).not.to.be.ok();
|
166
|
+
});
|
167
|
+
});
|
168
|
+
});
|
169
|
+
|
170
|
+
describe("#removeLayer", function () {
|
171
|
+
describe("when the last tile layer on a map is removed", function () {
|
172
|
+
it("fires a zoomlevelschange event", function () {
|
173
|
+
map.whenReady(function(){
|
174
|
+
var spy = sinon.spy();
|
175
|
+
var tl = L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map);
|
176
|
+
|
177
|
+
map.on("zoomlevelschange", spy);
|
178
|
+
expect(spy.called).not.to.be.ok();
|
179
|
+
map.removeLayer(tl);
|
180
|
+
expect(spy.called).to.be.ok();
|
181
|
+
});
|
182
|
+
});
|
183
|
+
});
|
184
|
+
|
185
|
+
describe("when a tile layer is removed from a map and it had greater zoom level coverage than the remainding layer", function () {
|
186
|
+
it("fires a zoomlevelschange event", function () {
|
187
|
+
map.whenReady(function(){
|
188
|
+
var spy = sinon.spy(),
|
189
|
+
tl = L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map),
|
190
|
+
t2 = L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 15 }).addTo(map);
|
191
|
+
|
192
|
+
map.on("zoomlevelschange", spy);
|
193
|
+
expect(spy.called).to.not.be.ok();
|
194
|
+
map.removeLayer(t2);
|
195
|
+
expect(spy.called).to.be.ok();
|
196
|
+
});
|
197
|
+
});
|
198
|
+
});
|
199
|
+
|
200
|
+
describe("when a tile layer is removed from a map it and it had lesser or the sa,e zoom level coverage as the remainding layer(s)", function () {
|
201
|
+
it("fires no zoomlevelschange event", function () {
|
202
|
+
map.whenReady(function(){
|
203
|
+
var tl = L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map),
|
204
|
+
t2 = L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map),
|
205
|
+
t3 = L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 5 }).addTo(map);
|
206
|
+
|
207
|
+
map.on("zoomlevelschange", spy);
|
208
|
+
expect(spy).not.toHaveBeenCalled();
|
209
|
+
map.removeLayer(t2);
|
210
|
+
expect(spy).not.toHaveBeenCalled();
|
211
|
+
map.removeLayer(t3);
|
212
|
+
expect(spy).not.toHaveBeenCalled();
|
213
|
+
});
|
214
|
+
});
|
215
|
+
});
|
216
|
+
});
|
217
|
+
|
218
|
+
describe("#eachLayer", function () {
|
219
|
+
it("returns self", function () {
|
220
|
+
expect(map.eachLayer(function () {})).to.be(map);
|
221
|
+
});
|
222
|
+
|
223
|
+
it("calls the provided function for each layer", function () {
|
224
|
+
var t1 = L.tileLayer("{z}{x}{y}").addTo(map),
|
225
|
+
t2 = L.tileLayer("{z}{x}{y}").addTo(map),
|
226
|
+
spy = sinon.spy();
|
227
|
+
|
228
|
+
map.eachLayer(spy);
|
229
|
+
|
230
|
+
expect(spy.callCount).to.eql(2);
|
231
|
+
expect(spy.firstCall.args).to.eql([t1]);
|
232
|
+
expect(spy.secondCall.args).to.eql([t2]);
|
233
|
+
});
|
234
|
+
|
235
|
+
it("calls the provided function with the provided context", function () {
|
236
|
+
var t1 = L.tileLayer("{z}{x}{y}").addTo(map),
|
237
|
+
spy = sinon.spy();
|
238
|
+
|
239
|
+
map.eachLayer(spy, map);
|
240
|
+
|
241
|
+
expect(spy.thisValues[0]).to.eql(map);
|
242
|
+
});
|
243
|
+
});
|
244
|
+
});
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
var oldL = window.L,
|
3
|
+
L = {};
|
4
|
+
|
5
|
+
L.version = '0.6-dev';
|
6
|
+
|
7
|
+
// define Leaflet for Node module pattern loaders, including Browserify
|
8
|
+
if (typeof module === 'object' && typeof module.exports === 'object') {
|
9
|
+
module.exports = L;
|
10
|
+
|
11
|
+
// define Leaflet as an AMD module
|
12
|
+
} else if (typeof define === 'function' && define.amd) {
|
13
|
+
define('leaflet', [], function () { return L; });
|
14
|
+
}
|
15
|
+
|
16
|
+
// define Leaflet as a global L variable, saving the original L to restore later if needed
|
17
|
+
|
18
|
+
L.noConflict = function () {
|
19
|
+
window.L = oldL;
|
20
|
+
return this;
|
21
|
+
};
|
22
|
+
|
23
|
+
window.L = L;
|
@@ -0,0 +1,115 @@
|
|
1
|
+
/*
|
2
|
+
* L.Control.Attribution is used for displaying attribution on the map (added by default).
|
3
|
+
*/
|
4
|
+
|
5
|
+
L.Control.Attribution = L.Control.extend({
|
6
|
+
options: {
|
7
|
+
position: 'bottomright',
|
8
|
+
prefix: '<a href="http://leafletjs.com" title="A JS library for interactive maps">Leaflet</a>'
|
9
|
+
},
|
10
|
+
|
11
|
+
initialize: function (options) {
|
12
|
+
L.setOptions(this, options);
|
13
|
+
|
14
|
+
this._attributions = {};
|
15
|
+
},
|
16
|
+
|
17
|
+
onAdd: function (map) {
|
18
|
+
this._container = L.DomUtil.create('div', 'leaflet-control-attribution');
|
19
|
+
L.DomEvent.disableClickPropagation(this._container);
|
20
|
+
|
21
|
+
map
|
22
|
+
.on('layeradd', this._onLayerAdd, this)
|
23
|
+
.on('layerremove', this._onLayerRemove, this);
|
24
|
+
|
25
|
+
this._update();
|
26
|
+
|
27
|
+
return this._container;
|
28
|
+
},
|
29
|
+
|
30
|
+
onRemove: function (map) {
|
31
|
+
map
|
32
|
+
.off('layeradd', this._onLayerAdd)
|
33
|
+
.off('layerremove', this._onLayerRemove);
|
34
|
+
|
35
|
+
},
|
36
|
+
|
37
|
+
setPrefix: function (prefix) {
|
38
|
+
this.options.prefix = prefix;
|
39
|
+
this._update();
|
40
|
+
return this;
|
41
|
+
},
|
42
|
+
|
43
|
+
addAttribution: function (text) {
|
44
|
+
if (!text) { return; }
|
45
|
+
|
46
|
+
if (!this._attributions[text]) {
|
47
|
+
this._attributions[text] = 0;
|
48
|
+
}
|
49
|
+
this._attributions[text]++;
|
50
|
+
|
51
|
+
this._update();
|
52
|
+
|
53
|
+
return this;
|
54
|
+
},
|
55
|
+
|
56
|
+
removeAttribution: function (text) {
|
57
|
+
if (!text) { return; }
|
58
|
+
|
59
|
+
if (this._attributions[text]) {
|
60
|
+
this._attributions[text]--;
|
61
|
+
this._update();
|
62
|
+
}
|
63
|
+
|
64
|
+
return this;
|
65
|
+
},
|
66
|
+
|
67
|
+
_update: function () {
|
68
|
+
if (!this._map) { return; }
|
69
|
+
|
70
|
+
var attribs = [];
|
71
|
+
|
72
|
+
for (var i in this._attributions) {
|
73
|
+
if (this._attributions[i]) {
|
74
|
+
attribs.push(i);
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
var prefixAndAttribs = [];
|
79
|
+
|
80
|
+
if (this.options.prefix) {
|
81
|
+
prefixAndAttribs.push(this.options.prefix);
|
82
|
+
}
|
83
|
+
if (attribs.length) {
|
84
|
+
prefixAndAttribs.push(attribs.join(', '));
|
85
|
+
}
|
86
|
+
|
87
|
+
this._container.innerHTML = prefixAndAttribs.join(' | ');
|
88
|
+
},
|
89
|
+
|
90
|
+
_onLayerAdd: function (e) {
|
91
|
+
if (e.layer.getAttribution) {
|
92
|
+
this.addAttribution(e.layer.getAttribution());
|
93
|
+
}
|
94
|
+
},
|
95
|
+
|
96
|
+
_onLayerRemove: function (e) {
|
97
|
+
if (e.layer.getAttribution) {
|
98
|
+
this.removeAttribution(e.layer.getAttribution());
|
99
|
+
}
|
100
|
+
}
|
101
|
+
});
|
102
|
+
|
103
|
+
L.Map.mergeOptions({
|
104
|
+
attributionControl: true
|
105
|
+
});
|
106
|
+
|
107
|
+
L.Map.addInitHook(function () {
|
108
|
+
if (this.options.attributionControl) {
|
109
|
+
this.attributionControl = (new L.Control.Attribution()).addTo(this);
|
110
|
+
}
|
111
|
+
});
|
112
|
+
|
113
|
+
L.control.attribution = function (options) {
|
114
|
+
return new L.Control.Attribution(options);
|
115
|
+
};
|