Skip to content

Commit

Permalink
fix(marker): Tests passing again after this new functionality:
Browse files Browse the repository at this point in the history
  • Loading branch information
tombatossals committed Mar 25, 2015
1 parent 9e45710 commit e0c7d2d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 22 deletions.
38 changes: 31 additions & 7 deletions dist/angular-leaflet-directive.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* angular-leaflet-directive 0.7.11 2015-03-24
* angular-leaflet-directive 0.7.11 2015-03-25
* angular-leaflet-directive - An AngularJS directive to easily interact with Leaflet maps
* git: https://github.com/tombatossals/angular-leaflet-directive
*/
Expand Down Expand Up @@ -3188,11 +3188,20 @@ angular.module("leaflet-directive").factory('leafletMarkersHelpers', ["$rootScop
}
}
}
if (Helpers.LabelPlugin.isLoaded() && isDefined(markerData.label) && isDefined(markerData.label.options) && markerData.label.options.noHide === true) {
};

var _manageOpenLabel = function(marker, markerData) {
var markerScope = angular.isFunction(markerData.getMessageScope) ? markerData.getMessageScope() : $rootScope,
labelScope = angular.isFunction(markerData.getLabelScope) ? markerData.getLabelScope() : markerScope,
compileMessage = isDefined(markerData.compileMessage) ? markerData.compileMessage : true;

if (Helpers.LabelPlugin.isLoaded() && isDefined(markerData.label)) {
if (isDefined(markerData.label.options) && markerData.label.options.noHide === true) {
marker.showLabel();
}
if (compileMessage) {
$compile(marker.label._container)(markerScope);
$compile(marker.label._container)(labelScope);
}
marker.showLabel();
}
};

Expand All @@ -3205,6 +3214,8 @@ angular.module("leaflet-directive").factory('leafletMarkersHelpers', ["$rootScop

manageOpenPopup: _manageOpenPopup,

manageOpenLabel: _manageOpenLabel,

createMarker: function(markerData) {
if (!isDefined(markerData)) {
$log.error('[AngularJS - Leaflet] The marker definition is not valid.');
Expand Down Expand Up @@ -3407,9 +3418,22 @@ angular.module("leaflet-directive").factory('leafletMarkersHelpers', ["$rootScop
marker.unbindPopup();
}

// Update the label content
if (Helpers.LabelPlugin.isLoaded() && isDefined(markerData.label) && isDefined(markerData.label.message) && !angular.equals(markerData.label.message, oldMarkerData.label.message)) {
marker.updateLabelContent(markerData.label.message);
// Update the label content or bind a new label if the old one has been removed.
if (Helpers.LabelPlugin.isLoaded()) {
if (isDefined(markerData.label) && isDefined(markerData.label.message)) {
if ('label' in oldMarkerData && 'message' in oldMarkerData.label && !angular.equals(markerData.label.message, oldMarkerData.label.message)) {
marker.updateLabelContent(markerData.label.message);
} else if (!angular.isFunction(marker.getLabel)) {
marker.bindLabel(markerData.label.message, markerData.label.options);
_manageOpenLabel(marker, markerData);
} else {
_manageOpenLabel(marker, markerData);
}
} else if (!('label' in markerData && !('message' in markerData.label))) {
if (angular.isFunction(marker.unbindLabel)) {
marker.unbindLabel();
}
}
}

// There is some text in the popup, so we must show the text or update existing
Expand Down
Loading

0 comments on commit e0c7d2d

Please sign in to comment.