leaflet-ruby 0.3.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +5 -0
- data/LICENSE +21 -0
- data/README.rdoc +55 -0
- data/Rakefile +15 -0
- data/leaflet-ruby.gemspec +24 -0
- data/lib/leaflet-ruby.rb +18 -0
- data/lib/leaflet/CHANGELOG.md +181 -0
- data/lib/leaflet/Jakefile.js +65 -0
- data/lib/leaflet/LICENSE +22 -0
- data/lib/leaflet/README.md +32 -0
- data/lib/leaflet/build/build.html +243 -0
- data/lib/leaflet/build/build.js +79 -0
- data/lib/leaflet/build/deps.js +231 -0
- data/lib/leaflet/build/hint.js +30 -0
- data/lib/leaflet/build/hintrc.js +44 -0
- data/lib/leaflet/debug/control/control-layers.html +47 -0
- data/lib/leaflet/debug/control/map-control.html +29 -0
- data/lib/leaflet/debug/css/mobile.css +6 -0
- data/lib/leaflet/debug/css/screen.css +5 -0
- data/lib/leaflet/debug/geojson/geojson-sample.js +53 -0
- data/lib/leaflet/debug/geojson/geojson.html +56 -0
- data/lib/leaflet/debug/leaflet-include.js +120 -0
- data/lib/leaflet/debug/map/canvas.html +46 -0
- data/lib/leaflet/debug/map/map-mobile.html +42 -0
- data/lib/leaflet/debug/map/map.html +54 -0
- data/lib/leaflet/debug/map/max-bounds.html +36 -0
- data/lib/leaflet/debug/map/scroll.html +35 -0
- data/lib/leaflet/debug/map/wms-marble.html +30 -0
- data/lib/leaflet/debug/map/wms.html +37 -0
- data/lib/leaflet/debug/vector/editable.html +43 -0
- data/lib/leaflet/debug/vector/route.js +1 -0
- data/lib/leaflet/debug/vector/vector-bounds.html +69 -0
- data/lib/leaflet/debug/vector/vector-canvas.html +92 -0
- data/lib/leaflet/debug/vector/vector-mobile.html +38 -0
- data/lib/leaflet/debug/vector/vector-simple.html +63 -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-shadow.png +0 -0
- data/lib/leaflet/dist/images/marker.png +0 -0
- data/lib/leaflet/dist/images/popup-close.png +0 -0
- data/lib/leaflet/dist/images/zoom-in.png +0 -0
- data/lib/leaflet/dist/images/zoom-out.png +0 -0
- data/lib/leaflet/dist/leaflet-src.js +5537 -0
- data/lib/leaflet/dist/leaflet.css +323 -0
- data/lib/leaflet/dist/leaflet.ie.css +48 -0
- data/lib/leaflet/dist/leaflet.js +6 -0
- data/lib/leaflet/lib/jasmine/jasmine-html.js +182 -0
- data/lib/leaflet/lib/jasmine/jasmine.css +166 -0
- data/lib/leaflet/lib/jasmine/jasmine.js +2421 -0
- data/lib/leaflet/spec/runner.html +57 -0
- data/lib/leaflet/spec/suites/LeafletSpec.js +15 -0
- data/lib/leaflet/spec/suites/SpecHelper.js +28 -0
- data/lib/leaflet/spec/suites/core/ClassSpec.js +153 -0
- data/lib/leaflet/spec/suites/core/EventsSpec.js +110 -0
- data/lib/leaflet/spec/suites/core/UtilSpec.js +63 -0
- data/lib/leaflet/spec/suites/dom/DomEventSpec.js +102 -0
- data/lib/leaflet/spec/suites/dom/DomUtilSpec.js +59 -0
- data/lib/leaflet/spec/suites/geo/LatLngBoundsSpec.js +1 -0
- data/lib/leaflet/spec/suites/geo/LatLngSpec.js +76 -0
- data/lib/leaflet/spec/suites/geo/ProjectionSpec.js +42 -0
- data/lib/leaflet/spec/suites/geometry/BoundsSpec.js +53 -0
- data/lib/leaflet/spec/suites/geometry/PointSpec.js +45 -0
- data/lib/leaflet/spec/suites/geometry/TransformationSpec.js +19 -0
- data/lib/leaflet/spec/suites/layer/TileLayerSpec.js +1 -0
- data/lib/leaflet/spec/suites/layer/vector/PolylineGeometrySpec.js +35 -0
- data/lib/leaflet/spec/suites/map/MapSpec.js +1 -0
- data/lib/leaflet/src/Leaflet.js +33 -0
- data/lib/leaflet/src/control/Control.Attribution.js +66 -0
- data/lib/leaflet/src/control/Control.Layers.js +167 -0
- data/lib/leaflet/src/control/Control.Zoom.js +36 -0
- data/lib/leaflet/src/control/Control.js +9 -0
- data/lib/leaflet/src/core/Browser.js +53 -0
- data/lib/leaflet/src/core/Class.js +66 -0
- data/lib/leaflet/src/core/Events.js +62 -0
- data/lib/leaflet/src/core/Handler.js +29 -0
- data/lib/leaflet/src/core/Util.js +108 -0
- data/lib/leaflet/src/dom/DomEvent.DoubleTap.js +43 -0
- data/lib/leaflet/src/dom/DomEvent.js +154 -0
- data/lib/leaflet/src/dom/DomUtil.js +155 -0
- data/lib/leaflet/src/dom/Draggable.js +147 -0
- data/lib/leaflet/src/dom/transition/Transition.Native.js +102 -0
- data/lib/leaflet/src/dom/transition/Transition.Timer.js +126 -0
- data/lib/leaflet/src/dom/transition/Transition.js +28 -0
- data/lib/leaflet/src/geo/LatLng.js +44 -0
- data/lib/leaflet/src/geo/LatLngBounds.js +86 -0
- data/lib/leaflet/src/geo/crs/CRS.EPSG3395.js +13 -0
- data/lib/leaflet/src/geo/crs/CRS.EPSG3857.js +17 -0
- data/lib/leaflet/src/geo/crs/CRS.EPSG4326.js +7 -0
- data/lib/leaflet/src/geo/crs/CRS.js +17 -0
- data/lib/leaflet/src/geo/projection/Projection.LonLat.js +10 -0
- data/lib/leaflet/src/geo/projection/Projection.Mercator.js +51 -0
- data/lib/leaflet/src/geo/projection/Projection.SphericalMercator.js +23 -0
- data/lib/leaflet/src/geo/projection/Projection.js +5 -0
- data/lib/leaflet/src/geometry/Bounds.js +50 -0
- data/lib/leaflet/src/geometry/LineUtil.js +194 -0
- data/lib/leaflet/src/geometry/Point.js +66 -0
- data/lib/leaflet/src/geometry/PolyUtil.js +59 -0
- data/lib/leaflet/src/geometry/Transformation.js +31 -0
- data/lib/leaflet/src/layer/FeatureGroup.js +40 -0
- data/lib/leaflet/src/layer/GeoJSON.js +104 -0
- data/lib/leaflet/src/layer/ImageOverlay.js +58 -0
- data/lib/leaflet/src/layer/LayerGroup.js +74 -0
- data/lib/leaflet/src/layer/Popup.js +179 -0
- data/lib/leaflet/src/layer/marker/Icon.js +58 -0
- data/lib/leaflet/src/layer/marker/Marker.Drag.js +57 -0
- data/lib/leaflet/src/layer/marker/Marker.Popup.js +42 -0
- data/lib/leaflet/src/layer/marker/Marker.js +142 -0
- data/lib/leaflet/src/layer/tile/TileLayer.Canvas.js +41 -0
- data/lib/leaflet/src/layer/tile/TileLayer.WMS.js +47 -0
- data/lib/leaflet/src/layer/tile/TileLayer.js +310 -0
- data/lib/leaflet/src/layer/vector/Circle.js +68 -0
- data/lib/leaflet/src/layer/vector/CircleMarker.js +25 -0
- data/lib/leaflet/src/layer/vector/MultiPoly.js +34 -0
- data/lib/leaflet/src/layer/vector/Path.Popup.js +24 -0
- data/lib/leaflet/src/layer/vector/Path.SVG.js +138 -0
- data/lib/leaflet/src/layer/vector/Path.VML.js +93 -0
- data/lib/leaflet/src/layer/vector/Path.js +88 -0
- data/lib/leaflet/src/layer/vector/Polygon.js +64 -0
- data/lib/leaflet/src/layer/vector/Polyline.js +146 -0
- data/lib/leaflet/src/layer/vector/canvas/Circle.Canvas.js +18 -0
- data/lib/leaflet/src/layer/vector/canvas/Path.Canvas.js +146 -0
- data/lib/leaflet/src/layer/vector/canvas/Polygon.Canvas.js +34 -0
- data/lib/leaflet/src/layer/vector/canvas/Polyline.Canvas.js +27 -0
- data/lib/leaflet/src/map/Map.js +613 -0
- data/lib/leaflet/src/map/anim/Map.PanAnimation.js +70 -0
- data/lib/leaflet/src/map/anim/Map.ZoomAnimation.js +133 -0
- data/lib/leaflet/src/map/ext/Map.Control.js +50 -0
- data/lib/leaflet/src/map/ext/Map.Geolocation.js +86 -0
- data/lib/leaflet/src/map/ext/Map.Popup.js +20 -0
- data/lib/leaflet/src/map/handler/Map.BoxZoom.js +73 -0
- data/lib/leaflet/src/map/handler/Map.DoubleClickZoom.js +18 -0
- data/lib/leaflet/src/map/handler/Map.Drag.js +81 -0
- data/lib/leaflet/src/map/handler/Map.ScrollWheelZoom.js +55 -0
- data/lib/leaflet/src/map/handler/Map.TouchZoom.js +93 -0
- data/lib/zerista/CRS.Cartesian.js +20 -0
- data/lib/zerista/Projection.Identity.js +11 -0
- data/lib/zerista/zerista_layer.js +97 -0
- data/vendor/assets/javascripts/leaflet.js +139 -0
- data/vendor/assets/stylesheets/leaflet.css +1 -0
- data/vendor/assets/stylesheets/leaflet.ie.css +1 -0
- metadata +185 -0
@@ -0,0 +1,68 @@
|
|
1
|
+
/*
|
2
|
+
* L.Circle is a circle overlay (with a certain radius in meters).
|
3
|
+
*/
|
4
|
+
|
5
|
+
L.Circle = L.Path.extend({
|
6
|
+
initialize: function (latlng, radius, options) {
|
7
|
+
L.Path.prototype.initialize.call(this, options);
|
8
|
+
|
9
|
+
this._latlng = latlng;
|
10
|
+
this._mRadius = radius;
|
11
|
+
},
|
12
|
+
|
13
|
+
options: {
|
14
|
+
fill: true
|
15
|
+
},
|
16
|
+
|
17
|
+
setLatLng: function (latlng) {
|
18
|
+
this._latlng = latlng;
|
19
|
+
this._redraw();
|
20
|
+
return this;
|
21
|
+
},
|
22
|
+
|
23
|
+
setRadius: function (radius) {
|
24
|
+
this._mRadius = radius;
|
25
|
+
this._redraw();
|
26
|
+
return this;
|
27
|
+
},
|
28
|
+
|
29
|
+
projectLatlngs: function () {
|
30
|
+
var equatorLength = 40075017,
|
31
|
+
hLength = equatorLength * Math.cos(L.LatLng.DEG_TO_RAD * this._latlng.lat);
|
32
|
+
|
33
|
+
var lngSpan = (this._mRadius / hLength) * 360,
|
34
|
+
latlng2 = new L.LatLng(this._latlng.lat, this._latlng.lng - lngSpan, true),
|
35
|
+
point2 = this._map.latLngToLayerPoint(latlng2);
|
36
|
+
|
37
|
+
this._point = this._map.latLngToLayerPoint(this._latlng);
|
38
|
+
this._radius = Math.round(this._point.x - point2.x);
|
39
|
+
},
|
40
|
+
|
41
|
+
getPathString: function () {
|
42
|
+
var p = this._point,
|
43
|
+
r = this._radius;
|
44
|
+
|
45
|
+
if (this._checkIfEmpty()) {
|
46
|
+
return '';
|
47
|
+
}
|
48
|
+
|
49
|
+
if (L.Browser.svg) {
|
50
|
+
return "M" + p.x + "," + (p.y - r) +
|
51
|
+
"A" + r + "," + r + ",0,1,1," +
|
52
|
+
(p.x - 0.1) + "," + (p.y - r) + " z";
|
53
|
+
} else {
|
54
|
+
p._round();
|
55
|
+
r = Math.round(r);
|
56
|
+
return "AL " + p.x + "," + p.y + " " + r + "," + r + " 0," + (65535 * 360);
|
57
|
+
}
|
58
|
+
},
|
59
|
+
|
60
|
+
_checkIfEmpty: function () {
|
61
|
+
var vp = this._map._pathViewport,
|
62
|
+
r = this._radius,
|
63
|
+
p = this._point;
|
64
|
+
|
65
|
+
return p.x - r > vp.max.x || p.y - r > vp.max.y ||
|
66
|
+
p.x + r < vp.min.x || p.y + r < vp.min.y;
|
67
|
+
}
|
68
|
+
});
|
@@ -0,0 +1,25 @@
|
|
1
|
+
/*
|
2
|
+
* L.CircleMarker is a circle overlay with a permanent pixel radius.
|
3
|
+
*/
|
4
|
+
|
5
|
+
L.CircleMarker = L.Circle.extend({
|
6
|
+
options: {
|
7
|
+
radius: 10,
|
8
|
+
weight: 2
|
9
|
+
},
|
10
|
+
|
11
|
+
initialize: function (latlng, options) {
|
12
|
+
L.Circle.prototype.initialize.call(this, latlng, null, options);
|
13
|
+
this._radius = this.options.radius;
|
14
|
+
},
|
15
|
+
|
16
|
+
projectLatlngs: function () {
|
17
|
+
this._point = this._map.latLngToLayerPoint(this._latlng);
|
18
|
+
},
|
19
|
+
|
20
|
+
setRadius: function (radius) {
|
21
|
+
this._radius = radius;
|
22
|
+
this._redraw();
|
23
|
+
return this;
|
24
|
+
}
|
25
|
+
});
|
@@ -0,0 +1,34 @@
|
|
1
|
+
/*
|
2
|
+
* Contains L.MultiPolyline and L.MultiPolygon layers.
|
3
|
+
*/
|
4
|
+
|
5
|
+
(function () {
|
6
|
+
function createMulti(Klass) {
|
7
|
+
return L.FeatureGroup.extend({
|
8
|
+
initialize: function (latlngs, options) {
|
9
|
+
this._layers = {};
|
10
|
+
this._options = options;
|
11
|
+
this.setLatLngs(latlngs);
|
12
|
+
},
|
13
|
+
|
14
|
+
setLatLngs: function (latlngs) {
|
15
|
+
var i = 0, len = latlngs.length;
|
16
|
+
|
17
|
+
this._iterateLayers(function (layer) {
|
18
|
+
if (i < len) {
|
19
|
+
layer.setLatLngs(latlngs[i++]);
|
20
|
+
} else {
|
21
|
+
this.removeLayer(layer);
|
22
|
+
}
|
23
|
+
}, this);
|
24
|
+
|
25
|
+
while (i < len) {
|
26
|
+
this.addLayer(new Klass(latlngs[i++], this._options));
|
27
|
+
}
|
28
|
+
}
|
29
|
+
});
|
30
|
+
}
|
31
|
+
|
32
|
+
L.MultiPolyline = createMulti(L.Polyline);
|
33
|
+
L.MultiPolygon = createMulti(L.Polygon);
|
34
|
+
}());
|
@@ -0,0 +1,24 @@
|
|
1
|
+
/*
|
2
|
+
* Popup extension to L.Path (polylines, polygons, circles), adding bindPopup method.
|
3
|
+
*/
|
4
|
+
|
5
|
+
L.Path.include({
|
6
|
+
bindPopup: function (content, options) {
|
7
|
+
if (!this._popup || this._popup.options !== options) {
|
8
|
+
this._popup = new L.Popup(options);
|
9
|
+
}
|
10
|
+
this._popup.setContent(content);
|
11
|
+
|
12
|
+
if (!this._openPopupAdded) {
|
13
|
+
this.on('click', this._openPopup, this);
|
14
|
+
this._openPopupAdded = true;
|
15
|
+
}
|
16
|
+
|
17
|
+
return this;
|
18
|
+
},
|
19
|
+
|
20
|
+
_openPopup: function (e) {
|
21
|
+
this._popup.setLatLng(e.latlng);
|
22
|
+
this._map.openPopup(this._popup);
|
23
|
+
}
|
24
|
+
});
|
@@ -0,0 +1,138 @@
|
|
1
|
+
L.Path.SVG_NS = 'http://www.w3.org/2000/svg';
|
2
|
+
|
3
|
+
L.Browser.svg = !!(document.createElementNS && document.createElementNS(L.Path.SVG_NS, 'svg').createSVGRect);
|
4
|
+
|
5
|
+
L.Path = L.Path.extend({
|
6
|
+
statics: {
|
7
|
+
SVG: L.Browser.svg,
|
8
|
+
_createElement: function (name) {
|
9
|
+
return document.createElementNS(L.Path.SVG_NS, name);
|
10
|
+
}
|
11
|
+
},
|
12
|
+
|
13
|
+
getPathString: function () {
|
14
|
+
// form path string here
|
15
|
+
},
|
16
|
+
|
17
|
+
_initElements: function () {
|
18
|
+
this._map._initPathRoot();
|
19
|
+
this._initPath();
|
20
|
+
this._initStyle();
|
21
|
+
},
|
22
|
+
|
23
|
+
_initPath: function () {
|
24
|
+
this._container = L.Path._createElement('g');
|
25
|
+
|
26
|
+
this._path = L.Path._createElement('path');
|
27
|
+
this._container.appendChild(this._path);
|
28
|
+
|
29
|
+
this._map._pathRoot.appendChild(this._container);
|
30
|
+
},
|
31
|
+
|
32
|
+
_initStyle: function () {
|
33
|
+
if (this.options.stroke) {
|
34
|
+
this._path.setAttribute('stroke-linejoin', 'round');
|
35
|
+
this._path.setAttribute('stroke-linecap', 'round');
|
36
|
+
}
|
37
|
+
if (this.options.fill) {
|
38
|
+
this._path.setAttribute('fill-rule', 'evenodd');
|
39
|
+
} else {
|
40
|
+
this._path.setAttribute('fill', 'none');
|
41
|
+
}
|
42
|
+
this._updateStyle();
|
43
|
+
},
|
44
|
+
|
45
|
+
_updateStyle: function () {
|
46
|
+
if (this.options.stroke) {
|
47
|
+
this._path.setAttribute('stroke', this.options.color);
|
48
|
+
this._path.setAttribute('stroke-opacity', this.options.opacity);
|
49
|
+
this._path.setAttribute('stroke-width', this.options.weight);
|
50
|
+
}
|
51
|
+
if (this.options.fill) {
|
52
|
+
this._path.setAttribute('fill', this.options.fillColor || this.options.color);
|
53
|
+
this._path.setAttribute('fill-opacity', this.options.fillOpacity);
|
54
|
+
}
|
55
|
+
},
|
56
|
+
|
57
|
+
_updatePath: function () {
|
58
|
+
var str = this.getPathString();
|
59
|
+
if (!str) {
|
60
|
+
// fix webkit empty string parsing bug
|
61
|
+
str = 'M0 0';
|
62
|
+
}
|
63
|
+
this._path.setAttribute('d', str);
|
64
|
+
},
|
65
|
+
|
66
|
+
// TODO remove duplication with L.Map
|
67
|
+
_initEvents: function () {
|
68
|
+
if (this.options.clickable) {
|
69
|
+
if (!L.Browser.vml) {
|
70
|
+
this._path.setAttribute('class', 'leaflet-clickable');
|
71
|
+
}
|
72
|
+
|
73
|
+
L.DomEvent.addListener(this._container, 'click', this._onMouseClick, this);
|
74
|
+
|
75
|
+
var events = ['dblclick', 'mousedown', 'mouseover', 'mouseout', 'mousemove'];
|
76
|
+
for (var i = 0; i < events.length; i++) {
|
77
|
+
L.DomEvent.addListener(this._container, events[i], this._fireMouseEvent, this);
|
78
|
+
}
|
79
|
+
}
|
80
|
+
},
|
81
|
+
|
82
|
+
_onMouseClick: function (e) {
|
83
|
+
if (this._map.dragging && this._map.dragging.moved()) {
|
84
|
+
return;
|
85
|
+
}
|
86
|
+
this._fireMouseEvent(e);
|
87
|
+
},
|
88
|
+
|
89
|
+
_fireMouseEvent: function (e) {
|
90
|
+
if (!this.hasEventListeners(e.type)) {
|
91
|
+
return;
|
92
|
+
}
|
93
|
+
this.fire(e.type, {
|
94
|
+
latlng: this._map.mouseEventToLatLng(e),
|
95
|
+
layerPoint: this._map.mouseEventToLayerPoint(e)
|
96
|
+
});
|
97
|
+
L.DomEvent.stopPropagation(e);
|
98
|
+
}
|
99
|
+
});
|
100
|
+
|
101
|
+
L.Map.include({
|
102
|
+
_initPathRoot: function () {
|
103
|
+
if (!this._pathRoot) {
|
104
|
+
this._pathRoot = L.Path._createElement('svg');
|
105
|
+
this._panes.overlayPane.appendChild(this._pathRoot);
|
106
|
+
|
107
|
+
this.on('moveend', this._updateSvgViewport);
|
108
|
+
this._updateSvgViewport();
|
109
|
+
}
|
110
|
+
},
|
111
|
+
|
112
|
+
_updateSvgViewport: function () {
|
113
|
+
this._updatePathViewport();
|
114
|
+
|
115
|
+
var vp = this._pathViewport,
|
116
|
+
min = vp.min,
|
117
|
+
max = vp.max,
|
118
|
+
width = max.x - min.x,
|
119
|
+
height = max.y - min.y,
|
120
|
+
root = this._pathRoot,
|
121
|
+
pane = this._panes.overlayPane;
|
122
|
+
|
123
|
+
// Hack to make flicker on drag end on mobile webkit less irritating
|
124
|
+
// Unfortunately I haven't found a good workaround for this yet
|
125
|
+
if (L.Browser.webkit) {
|
126
|
+
pane.removeChild(root);
|
127
|
+
}
|
128
|
+
|
129
|
+
L.DomUtil.setPosition(root, min);
|
130
|
+
root.setAttribute('width', width);
|
131
|
+
root.setAttribute('height', height);
|
132
|
+
root.setAttribute('viewBox', [min.x, min.y, width, height].join(' '));
|
133
|
+
|
134
|
+
if (L.Browser.webkit) {
|
135
|
+
pane.appendChild(root);
|
136
|
+
}
|
137
|
+
}
|
138
|
+
});
|
@@ -0,0 +1,93 @@
|
|
1
|
+
/*
|
2
|
+
* Vector rendering for IE6-8 through VML.
|
3
|
+
* Thanks to Dmitry Baranovsky and his Raphael library for inspiration!
|
4
|
+
*/
|
5
|
+
|
6
|
+
L.Browser.vml = (function () {
|
7
|
+
var d = document.createElement('div'), s;
|
8
|
+
d.innerHTML = '<v:shape adj="1"/>';
|
9
|
+
s = d.firstChild;
|
10
|
+
s.style.behavior = 'url(#default#VML)';
|
11
|
+
|
12
|
+
return (s && (typeof s.adj === 'object'));
|
13
|
+
}());
|
14
|
+
|
15
|
+
L.Path = L.Browser.svg || !L.Browser.vml ? L.Path : L.Path.extend({
|
16
|
+
statics: {
|
17
|
+
VML: true,
|
18
|
+
CLIP_PADDING: 0.02,
|
19
|
+
_createElement: (function () {
|
20
|
+
try {
|
21
|
+
document.namespaces.add('lvml', 'urn:schemas-microsoft-com:vml');
|
22
|
+
return function (name) {
|
23
|
+
return document.createElement('<lvml:' + name + ' class="lvml">');
|
24
|
+
};
|
25
|
+
} catch (e) {
|
26
|
+
return function (name) {
|
27
|
+
return document.createElement('<' + name + ' xmlns="urn:schemas-microsoft.com:vml" class="lvml">');
|
28
|
+
};
|
29
|
+
}
|
30
|
+
}())
|
31
|
+
},
|
32
|
+
|
33
|
+
_initPath: function () {
|
34
|
+
this._container = L.Path._createElement('shape');
|
35
|
+
this._container.className += ' leaflet-vml-shape' +
|
36
|
+
(this.options.clickable ? ' leaflet-clickable' : '');
|
37
|
+
this._container.coordsize = '1 1';
|
38
|
+
|
39
|
+
this._path = L.Path._createElement('path');
|
40
|
+
this._container.appendChild(this._path);
|
41
|
+
|
42
|
+
this._map._pathRoot.appendChild(this._container);
|
43
|
+
},
|
44
|
+
|
45
|
+
_initStyle: function () {
|
46
|
+
if (this.options.stroke) {
|
47
|
+
this._stroke = L.Path._createElement('stroke');
|
48
|
+
this._stroke.endcap = 'round';
|
49
|
+
this._container.appendChild(this._stroke);
|
50
|
+
} else {
|
51
|
+
this._container.stroked = false;
|
52
|
+
}
|
53
|
+
if (this.options.fill) {
|
54
|
+
this._container.filled = true;
|
55
|
+
this._fill = L.Path._createElement('fill');
|
56
|
+
this._container.appendChild(this._fill);
|
57
|
+
} else {
|
58
|
+
this._container.filled = false;
|
59
|
+
}
|
60
|
+
this._updateStyle();
|
61
|
+
},
|
62
|
+
|
63
|
+
_updateStyle: function () {
|
64
|
+
if (this.options.stroke) {
|
65
|
+
this._stroke.weight = this.options.weight + 'px';
|
66
|
+
this._stroke.color = this.options.color;
|
67
|
+
this._stroke.opacity = this.options.opacity;
|
68
|
+
}
|
69
|
+
if (this.options.fill) {
|
70
|
+
this._fill.color = this.options.fillColor || this.options.color;
|
71
|
+
this._fill.opacity = this.options.fillOpacity;
|
72
|
+
}
|
73
|
+
},
|
74
|
+
|
75
|
+
_updatePath: function () {
|
76
|
+
this._container.style.display = 'none';
|
77
|
+
this._path.v = this.getPathString() + ' '; // the space fixes IE empty path string bug
|
78
|
+
this._container.style.display = '';
|
79
|
+
}
|
80
|
+
});
|
81
|
+
|
82
|
+
L.Map.include(L.Browser.svg || !L.Browser.vml ? {} : {
|
83
|
+
_initPathRoot: function () {
|
84
|
+
if (!this._pathRoot) {
|
85
|
+
this._pathRoot = document.createElement('div');
|
86
|
+
this._pathRoot.className = 'leaflet-vml-container';
|
87
|
+
this._panes.overlayPane.appendChild(this._pathRoot);
|
88
|
+
|
89
|
+
this.on('moveend', this._updatePathViewport);
|
90
|
+
this._updatePathViewport();
|
91
|
+
}
|
92
|
+
}
|
93
|
+
});
|
@@ -0,0 +1,88 @@
|
|
1
|
+
/*
|
2
|
+
* L.Path is a base class for rendering vector paths on a map. It's inherited by Polyline, Circle, etc.
|
3
|
+
*/
|
4
|
+
|
5
|
+
L.Path = L.Class.extend({
|
6
|
+
includes: [L.Mixin.Events],
|
7
|
+
|
8
|
+
statics: {
|
9
|
+
// how much to extend the clip area around the map view
|
10
|
+
// (relative to its size, e.g. 0.5 is half the screen in each direction)
|
11
|
+
CLIP_PADDING: 0.5
|
12
|
+
},
|
13
|
+
|
14
|
+
options: {
|
15
|
+
stroke: true,
|
16
|
+
color: '#0033ff',
|
17
|
+
weight: 5,
|
18
|
+
opacity: 0.5,
|
19
|
+
|
20
|
+
fill: false,
|
21
|
+
fillColor: null, //same as color by default
|
22
|
+
fillOpacity: 0.2,
|
23
|
+
|
24
|
+
clickable: true,
|
25
|
+
|
26
|
+
// TODO remove this, as all paths now update on moveend
|
27
|
+
updateOnMoveEnd: true
|
28
|
+
},
|
29
|
+
|
30
|
+
initialize: function (options) {
|
31
|
+
L.Util.setOptions(this, options);
|
32
|
+
},
|
33
|
+
|
34
|
+
onAdd: function (map) {
|
35
|
+
this._map = map;
|
36
|
+
|
37
|
+
this._initElements();
|
38
|
+
this._initEvents();
|
39
|
+
this.projectLatlngs();
|
40
|
+
this._updatePath();
|
41
|
+
|
42
|
+
map.on('viewreset', this.projectLatlngs, this);
|
43
|
+
|
44
|
+
this._updateTrigger = this.options.updateOnMoveEnd ? 'moveend' : 'viewreset';
|
45
|
+
map.on(this._updateTrigger, this._updatePath, this);
|
46
|
+
},
|
47
|
+
|
48
|
+
onRemove: function (map) {
|
49
|
+
this._map = null;
|
50
|
+
|
51
|
+
map._pathRoot.removeChild(this._container);
|
52
|
+
|
53
|
+
map.off('viewreset', this.projectLatlngs, this);
|
54
|
+
map.off(this._updateTrigger, this._updatePath, this);
|
55
|
+
},
|
56
|
+
|
57
|
+
projectLatlngs: function () {
|
58
|
+
// do all projection stuff here
|
59
|
+
},
|
60
|
+
|
61
|
+
setStyle: function (style) {
|
62
|
+
L.Util.setOptions(this, style);
|
63
|
+
if (this._container) {
|
64
|
+
this._updateStyle();
|
65
|
+
}
|
66
|
+
return this;
|
67
|
+
},
|
68
|
+
|
69
|
+
_redraw: function () {
|
70
|
+
if (this._map) {
|
71
|
+
this.projectLatlngs();
|
72
|
+
this._updatePath();
|
73
|
+
}
|
74
|
+
}
|
75
|
+
});
|
76
|
+
|
77
|
+
L.Map.include({
|
78
|
+
_updatePathViewport: function () {
|
79
|
+
var p = L.Path.CLIP_PADDING,
|
80
|
+
size = this.getSize(),
|
81
|
+
//TODO this._map._getMapPanePos()
|
82
|
+
panePos = L.DomUtil.getPosition(this._mapPane),
|
83
|
+
min = panePos.multiplyBy(-1).subtract(size.multiplyBy(p)),
|
84
|
+
max = min.add(size.multiplyBy(1 + p * 2));
|
85
|
+
|
86
|
+
this._pathViewport = new L.Bounds(min, max);
|
87
|
+
}
|
88
|
+
});
|