Skip to content

Commit

Permalink
New compiled version
Browse files Browse the repository at this point in the history
  • Loading branch information
tombatossals committed Dec 14, 2013
1 parent 343a662 commit d95193c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
27 changes: 17 additions & 10 deletions dist/angular-leaflet-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,23 +405,30 @@ angular.module("leaflet-directive").directive('layers', function ($log, $q, leaf
leafletLayers.controls = {};
leafletLayers.controls.layers = new L.control.layers();
leafletLayers.controls.layers.setPosition(defaults.controlLayersPosition);
leafletLayers.controls.layers.addTo(map);


// Setup all baselayers definitions
var top = false;
for (var layerName in layers.baselayers) {
var newBaseLayer = createLayer(layers.baselayers[layerName]);
if (isDefined(newBaseLayer)) {
leafletLayers.baselayers[layerName] = newBaseLayer;
// Only add the visible layer to the map, layer control manages the addition to the map
// of layers in its control
if (layers.baselayers[layerName].top === true) {
map.addLayer(leafletLayers.baselayers[layerName]);
top = true;
}
leafletLayers.controls.layers.addBaseLayer(leafletLayers.baselayers[layerName], layers.baselayers[layerName].name);
if (!isDefined(newBaseLayer)) {
delete layers.baselayers[layerName];
continue;
}
leafletLayers.baselayers[layerName] = newBaseLayer;
// Only add the visible layer to the map, layer control manages the addition to the map
// of layers in its control
if (layers.baselayers[layerName].top === true) {
map.addLayer(leafletLayers.baselayers[layerName]);
top = true;
}

leafletLayers.controls.layers.addBaseLayer(leafletLayers.baselayers[layerName], layers.baselayers[layerName].name);
}

// Only add the layers switch selector control if we have more than one baselayer
if (Object.keys(layers.baselayers).length > 1) {
leafletLayers.controls.layers.addTo(map);
}

// If there is no visible layer add first to the map
Expand Down
Loading

0 comments on commit d95193c

Please sign in to comment.