Skip to content

Commit c5cabfe

Browse files
committed
feature(markersCompilation): support compilation even if the marker is not watched.
1 parent 0cb0165 commit c5cabfe

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/directives/markers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ angular.module("leaflet-directive").directive('markers', function ($log, $rootSc
122122

123123
if (shouldWatch) {
124124
addMarkerWatcher(marker, newName, leafletScope, layers, map);
125-
listenMarkerEvents(marker, markerData, leafletScope);
126125
}
127126

127+
listenMarkerEvents(marker, markerData, leafletScope, shouldWatch);
128128
bindMarkerEvents(marker, newName, markerData, leafletScope);
129129
}
130130
}

src/services/leafletMarkersHelpers.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,22 @@ angular.module("leaflet-directive").factory('leafletMarkersHelpers', function ($
192192
groups[groupName].addLayer(marker);
193193
},
194194

195-
listenMarkerEvents: function(marker, markerData, leafletScope) {
195+
listenMarkerEvents: function(marker, markerData, leafletScope, watching) {
196196
marker.on("popupopen", function(/* event */) {
197-
safeApply(leafletScope, function() {
198-
markerData.focus = true;
199-
});
197+
if (watching) {
198+
safeApply(leafletScope, function() {
199+
markerData.focus = true;
200+
});
201+
} else {
202+
_manageOpenPopup(marker, markerData);
203+
}
200204
});
201205
marker.on("popupclose", function(/* event */) {
202-
safeApply(leafletScope, function() {
203-
markerData.focus = false;
204-
});
206+
if (watching) {
207+
safeApply(leafletScope, function() {
208+
markerData.focus = false;
209+
});
210+
}
205211
});
206212
},
207213

0 commit comments

Comments
 (0)