Skip to content

Commit

Permalink
More refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Sullivan committed Dec 25, 2014
1 parent 836aa66 commit 52c341f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 16 deletions.
11 changes: 4 additions & 7 deletions dist/angular-mapbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
addMapInstance: addMapInstance,
getMarkers: getMarkers,
addMarker: addMarker,
fitMapToMarkers: fitMapToMarkers
fitMapToMarkers: fitMapToMarkers,
getOptionsForMap: getOptionsForMap
};
return service;

Expand Down Expand Up @@ -155,9 +156,6 @@
scope.map.setView([attrs.lat, attrs.lng], zoom);
}

// TODO: refactor this option into mapService
scope.isClusteringMarkers = attrs.clusterMarkers !== undefined;

if(attrs.onReposition) {
scope.map.on('dragend', function() {
scope[attrs.onReposition](scope.map.getBounds());
Expand Down Expand Up @@ -254,7 +252,7 @@
marker.bindPopup(popupContent);
}

if(controller.$scope.isClusteringMarkers && opts.excludeFromClustering !== true) {
if(mapboxService.getOptionsForMap(map).clusterMarkers && opts.excludeFromClustering !== true) {
controller.$scope.clusterGroup.addLayer(marker);
} else {
marker.addTo(map);
Expand All @@ -267,7 +265,6 @@
}

mapboxService.addMarker(marker);
//mapboxService.fitMapToMarkers(map); // TODO: debounce this

return marker;
};
Expand Down Expand Up @@ -324,7 +321,7 @@
}

element.bind('$destroy', function() {
if(controller.$scope.isClusteringMarkers) {
if(mapboxService.getOptionsForMap(map).clusterMarkers) {
controller.$scope.clusterGroup.removeLayer(marker);
} else {
map.removeLayer(marker);
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-mapbox.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<body ng-app="angular-mapbox-example" ng-controller="demoController">
<input type="text" ng-model="status">
{{ status }}
<mapbox map-id="licyeus.XXXi9pkgkg8"
<mapbox map-id="licyeus.i9pkgkg8"
lat="47.643569"
lng="-122.329453"
on-reposition="mapMovedCallback"
Expand Down
3 changes: 0 additions & 3 deletions src/directives/mapbox.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
scope.map.setView([attrs.lat, attrs.lng], zoom);
}

// TODO: refactor this option into mapService
scope.isClusteringMarkers = attrs.clusterMarkers !== undefined;

if(attrs.onReposition) {
scope.map.on('dragend', function() {
scope[attrs.onReposition](scope.map.getBounds());
Expand Down
5 changes: 2 additions & 3 deletions src/directives/marker.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
marker.bindPopup(popupContent);
}

if(controller.$scope.isClusteringMarkers && opts.excludeFromClustering !== true) {
if(mapboxService.getOptionsForMap(map).clusterMarkers && opts.excludeFromClustering !== true) {
controller.$scope.clusterGroup.addLayer(marker);
} else {
marker.addTo(map);
Expand All @@ -71,7 +71,6 @@
}

mapboxService.addMarker(marker);
//mapboxService.fitMapToMarkers(map); // TODO: debounce this

return marker;
};
Expand Down Expand Up @@ -128,7 +127,7 @@
}

element.bind('$destroy', function() {
if(controller.$scope.isClusteringMarkers) {
if(mapboxService.getOptionsForMap(map).clusterMarkers) {
controller.$scope.clusterGroup.removeLayer(marker);
} else {
map.removeLayer(marker);
Expand Down
3 changes: 2 additions & 1 deletion src/mapbox.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
addMapInstance: addMapInstance,
getMarkers: getMarkers,
addMarker: addMarker,
fitMapToMarkers: fitMapToMarkers
fitMapToMarkers: fitMapToMarkers,
getOptionsForMap: getOptionsForMap
};
return service;

Expand Down

0 comments on commit 52c341f

Please sign in to comment.