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
@@ -0,0 +1,68 @@
|
|
1
|
+
L.GeometryUtil = {
|
2
|
+
// Ported from the OpenLayers implementation. See https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Geometry/LinearRing.js#L270
|
3
|
+
geodesicArea: function (latLngs) {
|
4
|
+
var pointsCount = latLngs.length,
|
5
|
+
area = 0.0,
|
6
|
+
d2r = L.LatLng.DEG_TO_RAD,
|
7
|
+
p1, p2;
|
8
|
+
|
9
|
+
if (pointsCount > 2) {
|
10
|
+
for (var i = 0; i < pointsCount; i++) {
|
11
|
+
p1 = latLngs[i];
|
12
|
+
p2 = latLngs[(i + 1) % pointsCount];
|
13
|
+
area += ((p2.lng - p1.lng) * d2r) *
|
14
|
+
(2 + Math.sin(p1.lat * d2r) + Math.sin(p2.lat * d2r));
|
15
|
+
}
|
16
|
+
area = area * 6378137.0 * 6378137.0 / 2.0;
|
17
|
+
}
|
18
|
+
|
19
|
+
return Math.abs(area);
|
20
|
+
},
|
21
|
+
|
22
|
+
readableArea: function (area, isMetric) {
|
23
|
+
var areaStr;
|
24
|
+
|
25
|
+
if (isMetric) {
|
26
|
+
if (area >= 10000) {
|
27
|
+
areaStr = (area * 0.0001).toFixed(2) + ' ha';
|
28
|
+
} else {
|
29
|
+
areaStr = area.toFixed(2) + ' m²';
|
30
|
+
}
|
31
|
+
} else {
|
32
|
+
area *= 0.836127; // Square yards in 1 meter
|
33
|
+
|
34
|
+
if (area >= 3097600) { //3097600 square yards in 1 square mile
|
35
|
+
areaStr = (area / 3097600).toFixed(2) + ' mi²';
|
36
|
+
} else if (area >= 4840) {//48040 square yards in 1 acre
|
37
|
+
areaStr = (area / 4840).toFixed(2) + ' acres';
|
38
|
+
} else {
|
39
|
+
areaStr = Math.ceil(area) + ' yd²';
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
return areaStr;
|
44
|
+
},
|
45
|
+
|
46
|
+
readableDistance: function (distance, isMetric) {
|
47
|
+
var distanceStr;
|
48
|
+
|
49
|
+
if (isMetric) {
|
50
|
+
// show metres when distance is < 1km, then show km
|
51
|
+
if (distance > 1000) {
|
52
|
+
distanceStr = (distance / 1000).toFixed(2) + ' km';
|
53
|
+
} else {
|
54
|
+
distanceStr = Math.ceil(distance) + ' m';
|
55
|
+
}
|
56
|
+
} else {
|
57
|
+
distance *= 1.09361;
|
58
|
+
|
59
|
+
if (distance > 1760) {
|
60
|
+
distanceStr = (distance / 1760).toFixed(2) + ' miles';
|
61
|
+
} else {
|
62
|
+
distanceStr = Math.ceil(distance) + ' yd';
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
return distanceStr;
|
67
|
+
}
|
68
|
+
};
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
3
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
4
|
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
5
|
+
width="540px" height="60px" viewBox="0 0 540 60" enable-background="new 0 0 540 60" xml:space="preserve">
|
6
|
+
<g>
|
7
|
+
<path fill="#464646" d="M18,36v6h6v-6H18z M22,40h-2v-2h2V40z"/>
|
8
|
+
<path fill="#464646" d="M36,18v6h6v-6H36z M40,22h-2v-2h2V22z"/>
|
9
|
+
<polygon fill="#464646" points="23.142,39.145 20.857,36.854 36.857,20.857 39.142,23.142 "/>
|
10
|
+
</g>
|
11
|
+
<polygon fill="#464646" points="83.07,42 76,28.773 86.463,18 100,24.565 97.904,39.396 "/>
|
12
|
+
<rect x="140" y="20" fill="#464646" width="20" height="20"/>
|
13
|
+
<path fill="#464646" d="M221,30c0,6.078-4.926,11-11,11s-11-4.922-11-11c0-6.074,4.926-11,11-11S221,23.926,221,30z"/>
|
14
|
+
<path fill="#464646" d="M270,19c-4.971,0-9,4.029-9,9c0,4.971,5.001,12,9,14c4.001-2,9-9.029,9-14C279,23.029,274.971,19,270,19z
|
15
|
+
M270,31.5c-2.484,0-4.5-2.014-4.5-4.5c0-2.484,2.016-4.5,4.5-4.5c2.485,0,4.5,2.016,4.5,4.5C274.5,29.486,272.485,31.5,270,31.5z"
|
16
|
+
/>
|
17
|
+
<g>
|
18
|
+
<path fill="#464646" d="M337,30.156v0.407v5.604c0,1.658-1.344,3-3,3h-10c-1.655,0-3-1.342-3-3v-10c0-1.657,1.345-3,3-3h6.345
|
19
|
+
l3.19-3.17H324c-3.313,0-6,2.687-6,6v10c0,3.313,2.687,6,6,6h10c3.314,0,6-2.687,6-6v-8.809L337,30.156"/>
|
20
|
+
<polygon fill="#464646" points="329.828,33.529 327,33.529 327,30.699 335.891,21.809 338.719,24.637 "/>
|
21
|
+
|
22
|
+
<rect x="338.697" y="17.826" transform="matrix(-0.707 -0.7072 0.7072 -0.707 567.5655 274.7729)" fill="#464646" width="4" height="4"/>
|
23
|
+
</g>
|
24
|
+
<g>
|
25
|
+
<path fill="#464646" d="M381,42h18V24h-18V42z M395,26h2v14h-2V26z M391,26h2v14h-2V26z M387,26h2v14h-2V26z M383,26h2v14h-2V26z"
|
26
|
+
/>
|
27
|
+
<path fill="#464646" d="M395,20v-2v-2h-10v2v2h-6v2h22v-2H395z M393,20h-6v-2h6V20z"/>
|
28
|
+
</g>
|
29
|
+
<g>
|
30
|
+
<path fill="#BBBBBB" d="M458,30.156v0.407v5.604c0,1.658-1.344,3-3,3h-10c-1.655,0-3-1.342-3-3v-10c0-1.657,1.345-3,3-3h6.345
|
31
|
+
l3.19-3.17H445c-3.313,0-6,2.687-6,6v10c0,3.313,2.687,6,6,6h10c3.314,0,6-2.687,6-6v-8.809L458,30.156"/>
|
32
|
+
<polygon fill="#BBBBBB" points="450.828,33.529 448,33.529 448,30.699 456.891,21.809 459.719,24.637 "/>
|
33
|
+
|
34
|
+
<rect x="459.697" y="17.826" transform="matrix(-0.707 -0.7072 0.7072 -0.707 774.118 360.3402)" fill="#BBBBBB" width="4" height="4"/>
|
35
|
+
</g>
|
36
|
+
<g>
|
37
|
+
<path fill="#BBBBBB" d="M501,42h18V24h-18V42z M515,26h2v14h-2V26z M511,26h2v14h-2V26z M507,26h2v14h-2V26z M503,26h2v14h-2V26z"
|
38
|
+
/>
|
39
|
+
<path fill="#BBBBBB" d="M515,20v-2v-2h-10v2v2h-6v2h22v-2H515z M513,20h-6v-2h6V20z"/>
|
40
|
+
</g>
|
41
|
+
</svg>
|
@@ -5,11 +5,43 @@ Leaflet.draw Changelog
|
|
5
5
|
|
6
6
|
An in-progress version being developed on the master branch.
|
7
7
|
|
8
|
+
### Plugin improvements
|
9
|
+
|
10
|
+
* Improved performance when setting label content.
|
11
|
+
|
12
|
+
### Bug fixes
|
13
|
+
|
14
|
+
* Fixed issue where labels could appear blurry after zoom.
|
15
|
+
|
16
|
+
## 0.2.0 (August 20, 2013)
|
17
|
+
|
18
|
+
### Plugin improvements
|
19
|
+
|
20
|
+
* Removed need to call `showLabel` when adding a static label to the map.
|
21
|
+
* Added support for changing the direction of the label in relation to the marker. Added auto mode that switches depending on which side of the screen you are on. (adapted from [@erictheise](https://github.com/erictheise) pull request) [#17](https://github.com/Leaflet/Leaflet.label/pull/17)
|
22
|
+
* Added `labelAnchor` option to `L.CircleMarker`.
|
23
|
+
|
24
|
+
### Bug fixes
|
25
|
+
|
26
|
+
* Fix bug where map view hard reset did not update labels. (by [@dagjomar](https://github.com/dagjomar)). [#43](https://github.com/Leaflet/Leaflet.label/pull/43)
|
27
|
+
* Fix issue where non static labels would remain visible if the latlng of the marker changed.
|
28
|
+
|
29
|
+
## 0.1.4 (August 20, 2013)
|
30
|
+
|
31
|
+
### Bug fixes
|
32
|
+
|
33
|
+
* Fixed error in IE < 9 when trying to set the label z-index. (by [@arthur-e](https://github.com/arthur-e)). [#13](https://github.com/Leaflet/Leaflet.label/pull/25)
|
34
|
+
* Fixed an issue when removing the click handler from the container to close labels in touch devices.
|
35
|
+
|
36
|
+
## 0.1.3 (May 02, 2013)
|
37
|
+
|
8
38
|
### Plugin improvements
|
9
39
|
|
10
40
|
* Added method `L.Marker.setLabelNoHide()` to allow toggling of static marker labels. (inspired by [@kpwebb](https://github.com/kpwebb)). [#20](https://github.com/Leaflet/Leaflet.label/pull/20)
|
11
41
|
* Non-static labels will now hide when map container is tapped on touch devices. (by [@snkashis](https://github.com/snkashis)). [#26](https://github.com/Leaflet/Leaflet.label/pull/26)
|
12
42
|
* Added ability to set the opacity of the label along with the marker. (inspired by [@snkashis](https://github.com/snkashis)). [#20](https://github.com/Leaflet/Leaflet.label/pull/27)
|
43
|
+
* Added support for mouse event to L.Label.
|
44
|
+
* Added public getter to L.Marker to retrieve the label associated to a marker.
|
13
45
|
|
14
46
|
### Bug fixes
|
15
47
|
|
data/lib/leaflet.label/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
Leaflet.label
|
2
2
|
=============
|
3
3
|
|
4
|
+
**NOTE: lastest Leaflet.label master requires Leaflet 0.7-dev**
|
5
|
+
|
4
6
|
Leaflet.label is plugin for adding labels to markers & shapes on leaflet powered maps.
|
5
7
|
|
6
8
|
Check out the [demo](http://leaflet.github.com/Leaflet.label/).
|
@@ -28,18 +30,33 @@ If you would prefer the label to be always visible set the ````noHide: true````
|
|
28
30
|
````js
|
29
31
|
L.marker([-37.785, 175.263])
|
30
32
|
.bindLabel('A sweet static label!', { noHide: true })
|
31
|
-
.addTo(map)
|
32
|
-
.showLabel();
|
33
|
+
.addTo(map);
|
33
34
|
````
|
34
35
|
|
35
|
-
*N.B.* if you call `showLabel()` before it is added to the map the label will not show.
|
36
|
-
|
37
36
|
##Options
|
38
37
|
|
39
38
|
When you call ````bindLabel()```` you can pass in an options object. These options are:
|
40
39
|
|
41
40
|
- **noHide**: doesn't attach event handler for showing/hiding the label on mouseover/out.
|
42
41
|
- **className**: the css class to add to the label element
|
42
|
+
- **direction**: one of `left`|`right`(default)|`auto`. The direction the label displays in relation to the marker. `auto` will choose the optimal direction depending on the position of the marker.
|
43
|
+
|
44
|
+
E.g. To create a static label that automatically positions the label
|
45
|
+
|
46
|
+
````js
|
47
|
+
var myIcon = L.icon({
|
48
|
+
iconUrl: 'my-icon.png',
|
49
|
+
iconSize: [20, 20],
|
50
|
+
iconAnchor: [10, 10],
|
51
|
+
labelAnchor: [6, 0] // as I want the label to appear 2px past the icon (10 + 2 - 6)
|
52
|
+
});
|
53
|
+
L.marker([-37.7772, 175.2606], {
|
54
|
+
icon: myIcon
|
55
|
+
}).bindLabel('My label', {
|
56
|
+
noHide: true,
|
57
|
+
direction: 'auto'
|
58
|
+
});
|
59
|
+
````
|
43
60
|
|
44
61
|
##Positioning the label for custom icons
|
45
62
|
|
@@ -3,7 +3,7 @@ var fs = require('fs'),
|
|
3
3
|
UglifyJS = require('uglify-js'),
|
4
4
|
|
5
5
|
deps = require('./deps.js').deps,
|
6
|
-
hintrc = require('./hintrc.js')
|
6
|
+
hintrc = require('./hintrc.js');
|
7
7
|
|
8
8
|
|
9
9
|
function lintFiles(files) {
|
@@ -13,7 +13,7 @@ function lintFiles(files) {
|
|
13
13
|
|
14
14
|
for (i = 0, len = files.length; i < len; i++) {
|
15
15
|
|
16
|
-
jshint.JSHINT(fs.readFileSync(files[i], 'utf8'), hintrc);
|
16
|
+
jshint.JSHINT(fs.readFileSync(files[i], 'utf8'), hintrc.config, hintrc.globals);
|
17
17
|
errors = jshint.JSHINT.errors;
|
18
18
|
|
19
19
|
for (j = 0, len2 = errors.length; j < len2; j++) {
|
@@ -11,15 +11,28 @@
|
|
11
11
|
* Leaflet.label assumes that you have already included the Leaflet library.
|
12
12
|
*/
|
13
13
|
|
14
|
-
L.labelVersion = '0.1
|
14
|
+
L.labelVersion = '0.2.1-dev';
|
15
|
+
|
16
|
+
L.Label = L.Class.extend({
|
17
|
+
|
18
|
+
includes: L.Mixin.Events,
|
15
19
|
|
16
|
-
L.Label = L.Popup.extend({
|
17
20
|
options: {
|
18
|
-
autoPan: false,
|
19
21
|
className: '',
|
20
|
-
|
22
|
+
clickable: false,
|
23
|
+
direction: 'right',
|
21
24
|
noHide: false,
|
22
|
-
offset:
|
25
|
+
offset: [12, -15], // 6 (width of the label triangle) + 6 (padding)
|
26
|
+
opacity: 1,
|
27
|
+
zoomAnimation: true
|
28
|
+
},
|
29
|
+
|
30
|
+
initialize: function (options, source) {
|
31
|
+
L.setOptions(this, options);
|
32
|
+
|
33
|
+
this._source = source;
|
34
|
+
this._animated = L.Browser.any3d && this.options.zoomAnimation;
|
35
|
+
this._isOpen = false;
|
23
36
|
},
|
24
37
|
|
25
38
|
onAdd: function (map) {
|
@@ -30,16 +43,18 @@ L.Label = L.Popup.extend({
|
|
30
43
|
if (!this._container) {
|
31
44
|
this._initLayout();
|
32
45
|
}
|
33
|
-
this._updateContent();
|
34
|
-
|
35
|
-
var animFade = map.options.fadeAnimation;
|
36
46
|
|
37
|
-
if (animFade) {
|
38
|
-
L.DomUtil.setOpacity(this._container, 0);
|
39
|
-
}
|
40
47
|
this._pane.appendChild(this._container);
|
41
48
|
|
42
|
-
|
49
|
+
this._initInteraction();
|
50
|
+
|
51
|
+
this._update();
|
52
|
+
|
53
|
+
this.setOpacity(this.options.opacity);
|
54
|
+
|
55
|
+
map
|
56
|
+
.on('moveend', this._onMoveEnd, this)
|
57
|
+
.on('viewreset', this._onViewReset, this);
|
43
58
|
|
44
59
|
if (this._animated) {
|
45
60
|
map.on('zoomanim', this._zoomAnimation, this);
|
@@ -48,39 +63,47 @@ L.Label = L.Popup.extend({
|
|
48
63
|
if (L.Browser.touch && !this.options.noHide) {
|
49
64
|
L.DomEvent.on(this._container, 'click', this.close, this);
|
50
65
|
}
|
51
|
-
|
52
|
-
this._update();
|
53
|
-
|
54
|
-
if (animFade) {
|
55
|
-
L.DomUtil.setOpacity(this._container, 1);
|
56
|
-
}
|
57
66
|
},
|
58
67
|
|
59
68
|
onRemove: function (map) {
|
60
69
|
this._pane.removeChild(this._container);
|
61
70
|
|
62
|
-
L.Util.falseFn(this._container.offsetWidth); // force reflow
|
63
|
-
|
64
71
|
map.off({
|
65
|
-
|
66
|
-
|
72
|
+
zoomanim: this._zoomAnimation,
|
73
|
+
moveend: this._onMoveEnd,
|
74
|
+
viewreset: this._onViewReset
|
67
75
|
}, this);
|
68
76
|
|
69
|
-
|
70
|
-
L.DomUtil.setOpacity(this._container, 0);
|
71
|
-
}
|
77
|
+
this._removeInteraction();
|
72
78
|
|
73
79
|
this._map = null;
|
74
80
|
},
|
75
81
|
|
82
|
+
setLatLng: function (latlng) {
|
83
|
+
this._latlng = L.latLng(latlng);
|
84
|
+
if (this._map) {
|
85
|
+
this._updatePosition();
|
86
|
+
}
|
87
|
+
return this;
|
88
|
+
},
|
89
|
+
|
90
|
+
setContent: function (content) {
|
91
|
+
// Backup previous content and store new content
|
92
|
+
this._previousContent = this._content;
|
93
|
+
this._content = content;
|
94
|
+
|
95
|
+
this._updateContent();
|
96
|
+
|
97
|
+
return this;
|
98
|
+
},
|
99
|
+
|
76
100
|
close: function () {
|
77
101
|
var map = this._map;
|
78
|
-
if (L.Browser.touch && !this.options.noHide) {
|
79
|
-
L.DomEvent.off(this._container, 'click', this.close);
|
80
|
-
}
|
81
102
|
|
82
103
|
if (map) {
|
83
|
-
|
104
|
+
if (L.Browser.touch && !this.options.noHide) {
|
105
|
+
L.DomEvent.off(this._container, 'click', this.close);
|
106
|
+
}
|
84
107
|
|
85
108
|
map.removeLayer(this);
|
86
109
|
}
|
@@ -89,26 +112,47 @@ L.Label = L.Popup.extend({
|
|
89
112
|
updateZIndex: function (zIndex) {
|
90
113
|
this._zIndex = zIndex;
|
91
114
|
|
92
|
-
if (this._container) {
|
115
|
+
if (this._container && this._zIndex) {
|
93
116
|
this._container.style.zIndex = zIndex;
|
94
117
|
}
|
95
118
|
},
|
96
119
|
|
120
|
+
setOpacity: function (opacity) {
|
121
|
+
this.options.opacity = opacity;
|
122
|
+
|
123
|
+
if (this._container) {
|
124
|
+
L.DomUtil.setOpacity(this._container, opacity);
|
125
|
+
}
|
126
|
+
},
|
127
|
+
|
97
128
|
_initLayout: function () {
|
98
129
|
this._container = L.DomUtil.create('div', 'leaflet-label ' + this.options.className + ' leaflet-zoom-animated');
|
99
130
|
this.updateZIndex(this._zIndex);
|
100
131
|
},
|
101
132
|
|
133
|
+
_update: function () {
|
134
|
+
if (!this._map) { return; }
|
135
|
+
|
136
|
+
this._container.style.visibility = 'hidden';
|
137
|
+
|
138
|
+
this._updateContent();
|
139
|
+
this._updatePosition();
|
140
|
+
|
141
|
+
this._container.style.visibility = '';
|
142
|
+
},
|
143
|
+
|
102
144
|
_updateContent: function () {
|
103
|
-
if (!this._content) {
|
145
|
+
if (!this._content || !this._map || this._prevContent === this._content) {
|
146
|
+
return;
|
147
|
+
}
|
104
148
|
|
105
149
|
if (typeof this._content === 'string') {
|
106
150
|
this._container.innerHTML = this._content;
|
107
|
-
}
|
108
|
-
},
|
109
151
|
|
110
|
-
|
111
|
-
|
152
|
+
this._prevContent = this._content;
|
153
|
+
|
154
|
+
this._labelWidth = this._container.offsetWidth;
|
155
|
+
}
|
112
156
|
},
|
113
157
|
|
114
158
|
_updatePosition: function () {
|
@@ -118,42 +162,120 @@ L.Label = L.Popup.extend({
|
|
118
162
|
},
|
119
163
|
|
120
164
|
_setPosition: function (pos) {
|
121
|
-
|
165
|
+
var map = this._map,
|
166
|
+
container = this._container,
|
167
|
+
centerPoint = map.latLngToContainerPoint(map.getCenter()),
|
168
|
+
labelPoint = map.layerPointToContainerPoint(pos),
|
169
|
+
direction = this.options.direction,
|
170
|
+
labelWidth = this._labelWidth,
|
171
|
+
offset = L.point(this.options.offset);
|
172
|
+
|
173
|
+
// position to the right (right or auto & needs to)
|
174
|
+
if (direction === 'right' || direction === 'auto' && labelPoint.x < centerPoint.x) {
|
175
|
+
L.DomUtil.addClass(container, 'leaflet-label-right');
|
176
|
+
L.DomUtil.removeClass(container, 'leaflet-label-left');
|
177
|
+
|
178
|
+
pos = pos.add(offset);
|
179
|
+
} else { // position to the left
|
180
|
+
L.DomUtil.addClass(container, 'leaflet-label-left');
|
181
|
+
L.DomUtil.removeClass(container, 'leaflet-label-right');
|
182
|
+
|
183
|
+
pos = pos.add(L.point(-offset.x - labelWidth, offset.y));
|
184
|
+
}
|
122
185
|
|
123
|
-
L.DomUtil.setPosition(
|
186
|
+
L.DomUtil.setPosition(container, pos);
|
124
187
|
},
|
125
188
|
|
126
189
|
_zoomAnimation: function (opt) {
|
127
|
-
var pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center);
|
190
|
+
var pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center).round();
|
128
191
|
|
129
192
|
this._setPosition(pos);
|
130
|
-
}
|
131
|
-
});
|
193
|
+
},
|
132
194
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
}
|
195
|
+
_onMoveEnd: function () {
|
196
|
+
if (!this._animated || this.options.direction === 'auto') {
|
197
|
+
this._updatePosition();
|
198
|
+
}
|
199
|
+
},
|
137
200
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
201
|
+
_onViewReset: function (e) {
|
202
|
+
/* if map resets hard, we must update the label */
|
203
|
+
if (e && e.hard) {
|
204
|
+
this._update();
|
205
|
+
}
|
206
|
+
},
|
207
|
+
|
208
|
+
_initInteraction: function () {
|
209
|
+
if (!this.options.clickable) { return; }
|
210
|
+
|
211
|
+
var container = this._container,
|
212
|
+
events = ['dblclick', 'mousedown', 'mouseover', 'mouseout', 'contextmenu'];
|
213
|
+
|
214
|
+
L.DomUtil.addClass(container, 'leaflet-clickable');
|
215
|
+
L.DomEvent.on(container, 'click', this._onMouseClick, this);
|
216
|
+
|
217
|
+
for (var i = 0; i < events.length; i++) {
|
218
|
+
L.DomEvent.on(container, events[i], this._fireMouseEvent, this);
|
219
|
+
}
|
220
|
+
},
|
221
|
+
|
222
|
+
_removeInteraction: function () {
|
223
|
+
if (!this.options.clickable) { return; }
|
224
|
+
|
225
|
+
var container = this._container,
|
226
|
+
events = ['dblclick', 'mousedown', 'mouseover', 'mouseout', 'contextmenu'];
|
227
|
+
|
228
|
+
L.DomUtil.removeClass(container, 'leaflet-clickable');
|
229
|
+
L.DomEvent.off(container, 'click', this._onMouseClick, this);
|
230
|
+
|
231
|
+
for (var i = 0; i < events.length; i++) {
|
232
|
+
L.DomEvent.off(container, events[i], this._fireMouseEvent, this);
|
233
|
+
}
|
234
|
+
},
|
235
|
+
|
236
|
+
_onMouseClick: function (e) {
|
237
|
+
if (this.hasEventListeners(e.type)) {
|
238
|
+
L.DomEvent.stopPropagation(e);
|
239
|
+
}
|
240
|
+
|
241
|
+
this.fire(e.type, {
|
242
|
+
originalEvent: e
|
243
|
+
});
|
244
|
+
},
|
245
|
+
|
246
|
+
_fireMouseEvent: function (e) {
|
247
|
+
this.fire(e.type, {
|
248
|
+
originalEvent: e
|
249
|
+
});
|
250
|
+
|
251
|
+
// TODO proper custom event propagation
|
252
|
+
// this line will always be called if marker is in a FeatureGroup
|
253
|
+
if (e.type === 'contextmenu' && this.hasEventListeners(e.type)) {
|
254
|
+
L.DomEvent.preventDefault(e);
|
255
|
+
}
|
256
|
+
if (e.type !== 'mousedown') {
|
257
|
+
L.DomEvent.stopPropagation(e);
|
258
|
+
} else {
|
259
|
+
L.DomEvent.preventDefault(e);
|
260
|
+
}
|
261
|
+
}
|
142
262
|
});
|
143
263
|
|
144
|
-
|
264
|
+
|
265
|
+
// This object is a mixin for L.Marker and L.CircleMarker. We declare it here as both need to include the contents.
|
266
|
+
L.BaseMarkerMethods = {
|
145
267
|
showLabel: function () {
|
146
|
-
if (this.
|
147
|
-
this.
|
148
|
-
this._map.showLabel(this.
|
268
|
+
if (this.label && this._map) {
|
269
|
+
this.label.setLatLng(this._latlng);
|
270
|
+
this._map.showLabel(this.label);
|
149
271
|
}
|
150
272
|
|
151
273
|
return this;
|
152
274
|
},
|
153
275
|
|
154
276
|
hideLabel: function () {
|
155
|
-
if (this.
|
156
|
-
this.
|
277
|
+
if (this.label) {
|
278
|
+
this.label.close();
|
157
279
|
}
|
158
280
|
return this;
|
159
281
|
},
|
@@ -175,7 +297,8 @@ L.Marker.include({
|
|
175
297
|
},
|
176
298
|
|
177
299
|
bindLabel: function (content, options) {
|
178
|
-
var
|
300
|
+
var labelAnchor = this.options.icon ? this.options.icon.options.labelAnchor : this.options.labelAnchor,
|
301
|
+
anchor = L.point(labelAnchor) || L.point(0, 0);
|
179
302
|
|
180
303
|
anchor = anchor.add(L.Label.prototype.options.offset);
|
181
304
|
|
@@ -187,29 +310,30 @@ L.Marker.include({
|
|
187
310
|
|
188
311
|
this._labelNoHide = options.noHide;
|
189
312
|
|
190
|
-
if (!this.
|
313
|
+
if (!this.label) {
|
191
314
|
if (!this._labelNoHide) {
|
192
315
|
this._addLabelRevealHandlers();
|
193
316
|
}
|
194
317
|
|
195
318
|
this
|
196
319
|
.on('remove', this.hideLabel, this)
|
197
|
-
.on('move', this._moveLabel, this)
|
320
|
+
.on('move', this._moveLabel, this)
|
321
|
+
.on('add', this._onMarkerAdd, this);
|
198
322
|
|
199
323
|
this._hasLabelHandlers = true;
|
200
324
|
}
|
201
325
|
|
202
|
-
this.
|
326
|
+
this.label = new L.Label(options, this)
|
203
327
|
.setContent(content);
|
204
328
|
|
205
329
|
return this;
|
206
330
|
},
|
207
331
|
|
208
332
|
unbindLabel: function () {
|
209
|
-
if (this.
|
333
|
+
if (this.label) {
|
210
334
|
this.hideLabel();
|
211
335
|
|
212
|
-
this.
|
336
|
+
this.label = null;
|
213
337
|
|
214
338
|
if (this._hasLabelHandlers) {
|
215
339
|
if (!this._labelNoHide) {
|
@@ -218,7 +342,8 @@ L.Marker.include({
|
|
218
342
|
|
219
343
|
this
|
220
344
|
.off('remove', this.hideLabel, this)
|
221
|
-
.off('move', this._moveLabel, this)
|
345
|
+
.off('move', this._moveLabel, this)
|
346
|
+
.off('add', this._onMarkerAdd, this);
|
222
347
|
}
|
223
348
|
|
224
349
|
this._hasLabelHandlers = false;
|
@@ -227,8 +352,18 @@ L.Marker.include({
|
|
227
352
|
},
|
228
353
|
|
229
354
|
updateLabelContent: function (content) {
|
230
|
-
if (this.
|
231
|
-
this.
|
355
|
+
if (this.label) {
|
356
|
+
this.label.setContent(content);
|
357
|
+
}
|
358
|
+
},
|
359
|
+
|
360
|
+
getLabel: function () {
|
361
|
+
return this.label;
|
362
|
+
},
|
363
|
+
|
364
|
+
_onMarkerAdd: function () {
|
365
|
+
if (this._labelNoHide) {
|
366
|
+
this.showLabel();
|
232
367
|
}
|
233
368
|
},
|
234
369
|
|
@@ -245,9 +380,7 @@ L.Marker.include({
|
|
245
380
|
_removeLabelRevealHandlers: function () {
|
246
381
|
this
|
247
382
|
.off('mouseover', this.showLabel, this)
|
248
|
-
.off('mouseout', this.hideLabel, this)
|
249
|
-
.off('remove', this.hideLabel, this)
|
250
|
-
.off('move', this._moveLabel, this);
|
383
|
+
.off('mouseout', this.hideLabel, this);
|
251
384
|
|
252
385
|
if (L.Browser.touch) {
|
253
386
|
this.off('click', this.showLabel, this);
|
@@ -255,9 +388,23 @@ L.Marker.include({
|
|
255
388
|
},
|
256
389
|
|
257
390
|
_moveLabel: function (e) {
|
258
|
-
this.
|
259
|
-
}
|
391
|
+
this.label.setLatLng(e.latlng);
|
392
|
+
}
|
393
|
+
};
|
260
394
|
|
395
|
+
// Add in an option to icon that is used to set where the label anchor is
|
396
|
+
L.Icon.Default.mergeOptions({
|
397
|
+
labelAnchor: new L.Point(9, -20)
|
398
|
+
});
|
399
|
+
|
400
|
+
// Have to do this since Leaflet is loaded before this plugin and initializes
|
401
|
+
// L.Marker.options.icon therefore missing our mixin above.
|
402
|
+
L.Marker.mergeOptions({
|
403
|
+
icon: new L.Icon.Default()
|
404
|
+
});
|
405
|
+
|
406
|
+
L.Marker.include(L.BaseMarkerMethods);
|
407
|
+
L.Marker.include({
|
261
408
|
_originalUpdateZIndex: L.Marker.prototype._updateZIndex,
|
262
409
|
|
263
410
|
_updateZIndex: function (offset) {
|
@@ -265,19 +412,57 @@ L.Marker.include({
|
|
265
412
|
|
266
413
|
this._originalUpdateZIndex(offset);
|
267
414
|
|
268
|
-
if (this.
|
269
|
-
this.
|
415
|
+
if (this.label) {
|
416
|
+
this.label.updateZIndex(zIndex);
|
417
|
+
}
|
418
|
+
},
|
419
|
+
|
420
|
+
_originalSetOpacity: L.Marker.prototype.setOpacity,
|
421
|
+
|
422
|
+
setOpacity: function (opacity, labelHasSemiTransparency) {
|
423
|
+
this.options.labelHasSemiTransparency = labelHasSemiTransparency;
|
424
|
+
|
425
|
+
this._originalSetOpacity(opacity);
|
426
|
+
},
|
427
|
+
|
428
|
+
_originalUpdateOpacity: L.Marker.prototype._updateOpacity,
|
429
|
+
|
430
|
+
_updateOpacity: function () {
|
431
|
+
var absoluteOpacity = this.options.opacity === 0 ? 0 : 1;
|
432
|
+
|
433
|
+
this._originalUpdateOpacity();
|
434
|
+
|
435
|
+
if (this.label) {
|
436
|
+
this.label.setOpacity(this.options.labelHasSemiTransparency ? this.options.opacity : absoluteOpacity);
|
437
|
+
}
|
438
|
+
},
|
439
|
+
|
440
|
+
_originalSetLatLng: L.Marker.prototype.setLatLng,
|
441
|
+
|
442
|
+
setLatLng: function (latlng) {
|
443
|
+
if (this.label && !this._labelNoHide) {
|
444
|
+
this.hideLabel();
|
270
445
|
}
|
446
|
+
|
447
|
+
return this._originalSetLatLng(latlng);
|
271
448
|
}
|
272
449
|
});
|
273
450
|
|
451
|
+
// Add in an option to icon that is used to set where the label anchor is
|
452
|
+
L.CircleMarker.mergeOptions({
|
453
|
+
labelAnchor: new L.Point(0, 0)
|
454
|
+
});
|
455
|
+
|
456
|
+
|
457
|
+
L.CircleMarker.include(L.BaseMarkerMethods);
|
458
|
+
|
274
459
|
L.Path.include({
|
275
460
|
bindLabel: function (content, options) {
|
276
|
-
if (!this.
|
277
|
-
this.
|
461
|
+
if (!this.label || this.label.options !== options) {
|
462
|
+
this.label = new L.Label(options, this);
|
278
463
|
}
|
279
464
|
|
280
|
-
this.
|
465
|
+
this.label.setContent(content);
|
281
466
|
|
282
467
|
if (!this._showLabelAdded) {
|
283
468
|
this
|
@@ -295,9 +480,9 @@ L.Path.include({
|
|
295
480
|
},
|
296
481
|
|
297
482
|
unbindLabel: function () {
|
298
|
-
if (this.
|
483
|
+
if (this.label) {
|
299
484
|
this._hideLabel();
|
300
|
-
this.
|
485
|
+
this.label = null;
|
301
486
|
this._showLabelAdded = false;
|
302
487
|
this
|
303
488
|
.off('mouseover', this._showLabel, this)
|
@@ -308,29 +493,27 @@ L.Path.include({
|
|
308
493
|
},
|
309
494
|
|
310
495
|
updateLabelContent: function (content) {
|
311
|
-
if (this.
|
312
|
-
this.
|
496
|
+
if (this.label) {
|
497
|
+
this.label.setContent(content);
|
313
498
|
}
|
314
499
|
},
|
315
500
|
|
316
501
|
_showLabel: function (e) {
|
317
|
-
this.
|
318
|
-
this._map.showLabel(this.
|
502
|
+
this.label.setLatLng(e.latlng);
|
503
|
+
this._map.showLabel(this.label);
|
319
504
|
},
|
320
505
|
|
321
506
|
_moveLabel: function (e) {
|
322
|
-
this.
|
507
|
+
this.label.setLatLng(e.latlng);
|
323
508
|
},
|
324
509
|
|
325
510
|
_hideLabel: function () {
|
326
|
-
this.
|
511
|
+
this.label.close();
|
327
512
|
}
|
328
513
|
});
|
329
514
|
|
330
515
|
L.Map.include({
|
331
516
|
showLabel: function (label) {
|
332
|
-
this._label = label;
|
333
|
-
|
334
517
|
return this.addLayer(label);
|
335
518
|
}
|
336
519
|
});
|