instantiate default renderers in map, fix #2523
This commit is contained in:
parent
1a7b12604b
commit
b8897f26fb
@ -38,9 +38,9 @@
|
|||||||
var circle = L.circle([35, 0], 700000, {color: 'green', renderer: canvas}).addTo(map).bindPopup('Hello Circle');
|
var circle = L.circle([35, 0], 700000, {color: 'green', renderer: canvas}).addTo(map).bindPopup('Hello Circle');
|
||||||
var circleMarker = L.circleMarker([35, 30], {color: 'magenta', radius: 30}).addTo(map).bindPopup('Happy New Year!');
|
var circleMarker = L.circleMarker([35, 30], {color: 'magenta', radius: 30}).addTo(map).bindPopup('Happy New Year!');
|
||||||
|
|
||||||
map.on('mousemove', function (e) {
|
// map.on('mousemove', function (e) {
|
||||||
circle.setLatLng(e.latlng);
|
// circle.setLatLng(e.latlng);
|
||||||
});
|
// });
|
||||||
|
|
||||||
map.setView([36, 52], 3);
|
map.setView([36, 52], 3);
|
||||||
|
|
||||||
@ -51,7 +51,7 @@
|
|||||||
'circle': circle,
|
'circle': circle,
|
||||||
'circleMarker': circleMarker,
|
'circleMarker': circleMarker,
|
||||||
'canvas': canvas,
|
'canvas': canvas,
|
||||||
'svg': L.SVG.instance,
|
'svg': map._renderer,
|
||||||
}, {collapsed: false});
|
}, {collapsed: false});
|
||||||
map.addControl(layersControl);
|
map.addControl(layersControl);
|
||||||
</script>
|
</script>
|
||||||
|
@ -241,8 +241,6 @@ L.canvas = function (options) {
|
|||||||
return L.Browser.canvas ? new L.Canvas(options) : null;
|
return L.Browser.canvas ? new L.Canvas(options) : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
L.Canvas.instance = L.canvas();
|
|
||||||
|
|
||||||
L.Polyline.prototype._containsPoint = function (p, closed) {
|
L.Polyline.prototype._containsPoint = function (p, closed) {
|
||||||
var i, j, k, len, len2, part,
|
var i, j, k, len, len2, part,
|
||||||
w = this._clickTolerance();
|
w = this._clickTolerance();
|
||||||
|
@ -64,8 +64,11 @@ L.Renderer = L.Layer.extend({
|
|||||||
L.Map.include({
|
L.Map.include({
|
||||||
// used by each vector layer to decide which renderer to use
|
// used by each vector layer to decide which renderer to use
|
||||||
getRenderer: function (layer) {
|
getRenderer: function (layer) {
|
||||||
var renderer = layer.options.renderer || this.options.renderer ||
|
var renderer = layer.options.renderer || this.options.renderer || this._renderer;
|
||||||
(L.SVG && L.SVG.instance) || (L.Canvas && L.Canvas.instance);
|
|
||||||
|
if (!renderer) {
|
||||||
|
renderer = this._renderer = (L.SVG && L.svg()) || (L.Canvas && L.canvas());
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.hasLayer(renderer)) {
|
if (!this.hasLayer(renderer)) {
|
||||||
this.addLayer(renderer);
|
this.addLayer(renderer);
|
||||||
|
@ -132,6 +132,4 @@ if (L.Browser.vml) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
L.SVG.instance = L.svg();
|
|
||||||
}
|
}
|
||||||
|
@ -184,6 +184,3 @@ L.Browser.svg = !!(document.createElementNS && L.SVG.create('svg').createSVGRect
|
|||||||
L.svg = function (options) {
|
L.svg = function (options) {
|
||||||
return L.Browser.svg || L.Browser.vml ? new L.SVG(options) : null;
|
return L.Browser.svg || L.Browser.vml ? new L.SVG(options) : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
// default instance to use when adding vectors to the map
|
|
||||||
L.SVG.instance = L.svg();
|
|
||||||
|
Loading…
Reference in New Issue
Block a user