fix VML remove/add losing styles issue, closes #830

This commit is contained in:
Vladimir Agafonkin 2012-07-26 17:33:14 +03:00
parent a7f730690d
commit 65aafc3a8f
5 changed files with 33 additions and 15 deletions

View File

@ -8,7 +8,7 @@
<link rel="stylesheet" href="../css/screen.css" />
<script src="../leaflet-include.js"></script>
<script src="../../dist/leaflet-src.js"></script>
</head>
<body>
@ -26,7 +26,7 @@
var map = new L.Map('map').addLayer(cloudmade).setView(new L.LatLng(50.5, 30.51), 15);
var marker = new L.Marker(new L.LatLng(50.5, 30.505));
var marker = new L.CircleMarker(new L.LatLng(50.5, 30.505), {color: 'red'});
map.addLayer(marker);
marker.bindPopup("Hello World").openPopup();

21
dist/leaflet-src.js vendored
View File

@ -3528,11 +3528,16 @@ L.Path = L.Class.extend({
onAdd: function (map) {
this._map = map;
this._initElements();
this._initEvents();
if (!this._container) {
this._initElements();
this._initEvents();
}
this.projectLatlngs();
this._updatePath();
this._map._pathRoot.appendChild(this._container);
map.on({
'viewreset': this.projectLatlngs,
'moveend': this._updatePath
@ -3545,9 +3550,15 @@ L.Path = L.Class.extend({
},
onRemove: function (map) {
map._pathRoot.removeChild(this._container);
this._map = null;
map._pathRoot.removeChild(this._container);
if (L.Browser.vml) {
this._container = null;
this._stroke = null;
this._fill = null;
}
map.off({
'viewreset': this.projectLatlngs,
@ -3632,8 +3643,6 @@ L.Path = L.Path.extend({
this._path = this._createElement('path');
this._container.appendChild(this._path);
this._map._pathRoot.appendChild(this._container);
},
_initStyle: function () {
@ -3705,7 +3714,7 @@ L.Path = L.Path.extend({
if (!this.hasEventListeners(e.type)) {
return;
}
if (e.type === 'contextmenu') {
L.DomEvent.preventDefault(e);
}

2
dist/leaflet.js vendored

File diff suppressed because one or more lines are too long

View File

@ -39,8 +39,6 @@ L.Path = L.Path.extend({
this._path = this._createElement('path');
this._container.appendChild(this._path);
this._map._pathRoot.appendChild(this._container);
},
_initStyle: function () {
@ -112,7 +110,7 @@ L.Path = L.Path.extend({
if (!this.hasEventListeners(e.type)) {
return;
}
if (e.type === 'contextmenu') {
L.DomEvent.preventDefault(e);
}

View File

@ -36,11 +36,16 @@ L.Path = L.Class.extend({
onAdd: function (map) {
this._map = map;
this._initElements();
this._initEvents();
if (!this._container) {
this._initElements();
this._initEvents();
}
this.projectLatlngs();
this._updatePath();
this._map._pathRoot.appendChild(this._container);
map.on({
'viewreset': this.projectLatlngs,
'moveend': this._updatePath
@ -53,9 +58,15 @@ L.Path = L.Class.extend({
},
onRemove: function (map) {
map._pathRoot.removeChild(this._container);
this._map = null;
map._pathRoot.removeChild(this._container);
if (L.Browser.vml) {
this._container = null;
this._stroke = null;
this._fill = null;
}
map.off({
'viewreset': this.projectLatlngs,