Skip to content

Commit

Permalink
refactor(leaflet): Add load event
Browse files Browse the repository at this point in the history
Add load event for baselayer and emit it
  • Loading branch information
mpfeil committed Jun 4, 2018
1 parent 18a4b66 commit 423194e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/components/leaflet.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,16 @@
map.removeLayer(mapLayers['mouseOver']);
});

L.tileLayer('@@OPENSENSEMAP_MAPTILES_URL', {
var baselayer = L.tileLayer('@@OPENSENSEMAP_MAPTILES_URL', {
subdomains: 'abc',
attribution: '&copy; <a href="http://osm.org/copyright" target="_blank">OpenStreetMap</a> contributors | Tiles &copy; <a href="http://www.mapbox.com/" target="_blank">Mapbox</a>',
detectRetina: true,
reuseTiles: true,
maxZoom: 18
}).addTo(map);

baselayer.on('load', layerLoaded);

L.control.scale().addTo(map);

if (angular.isDefined(scope.events) && !angular.equals({}, scope.events)) {
Expand Down Expand Up @@ -152,6 +154,12 @@
$rootScope.$broadcast('osemMapReady', {});
});

function layerLoaded () {
$rootScope.$broadcast('layerloaded', {});
$rootScope.$apply();
baselayer.off('load', layerLoaded);
}

function onMarkersWatch (newVal, oldVal) {
if (angular.isDefined(newVal) && !angular.equals({}, newVal)) {
mapLayers['activeMarkers'].clearLayers();
Expand Down

0 comments on commit 423194e

Please sign in to comment.