Skip to content

Commit

Permalink
Add None option to Destinations layer picker
Browse files Browse the repository at this point in the history
The fix for this is awkward. In order to not mess up the
order in which the layer groups draw in the picker, we
have to ensure that we add the "None" layer immediately
before the remaining destinations layers. The group layer
control doesn't give us a way to specify a particular order.

If we only add based on whether the ctl.destinationsNoneLayer
exists or not, we create it too early during the first scope
resolution, and the Destinations draw before the Overlays.

If we just create based on whether layers are present in the
$q.all callback, we may double create the none layer.

Opened:
ismyrnow/leaflet-groupedlayercontrol#54
  • Loading branch information
CloudNiner committed Aug 2, 2017
1 parent eaf8617 commit 945faab
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/angularjs/src/app/places/detail/place-map.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@
});

$q.all(destLayerPromises).then(function (layers) {
if (!ctl.destinationsNoneLayer && layers && layers.length) {
var noneLayer = L.geoJSON({type:'FeatureCollection', features: []});
ctl.destinationsNoneLayer = noneLayer
ctl.layerControl.addOverlay(ctl.destinationsNoneLayer, 'None', 'Destinations');
ctl.map.addLayer(ctl.destinationsNoneLayer);
}
_.forEach(_.sortBy(layers, 'label'), function (layer) {
ctl.layerControl.addOverlay(layer.layer, layer.label, 'Destinations');
});
Expand Down

0 comments on commit 945faab

Please sign in to comment.