I am using AngularJS leaflet directive. I am trying to use events to display a context menu. I am using the guide from following link leaflet directive events
but its not working out.
Though i am able to see logs on console but I am not able to see any alerts which i want to see.
Here is the code from my controller. No matter which event i try contextmenu or click its not working for me.
(function(){
var baseMapController = function($scope, $http, leafletData, Base64, leafletMapEvents) {
angular.extend($scope, {
berlin: {
lat: 40.726468,
lng: -74.005639,
zoom: 14
},
markers: {
m1: {
lat: 52.52,
lng: 13.40
}
},
layers: {
baselayers: {
googleTerrain: {
name: 'Google Terrain',
layerType: 'TERRAIN',
type: 'google'
},
googleHybrid: {
name: 'Google Hybrid',
layerType: 'HYBRID',
type: 'google'
},
googleRoadmap: {
name: 'Google Streets',
layerType: 'ROADMAP',
type: 'google'
}
}
},
events: {
map: {
enable: ['zoomstart', 'contextmenu', 'drag', 'click', 'mousemove', 'popupopen'],
logic: 'broadcast'
}
},
defaults: {
scrollWheelZoom: false
},
geojson:{}
});
$scope.$on('leafletDirectiveMap.click', function(event){
alert("Click");
});
// Mouse over function, called from the Leaflet Map Events
var countryMouseover = function (feature, leafletEvent) {
var layer = leafletEvent.target;
layer.setStyle({
weight: 2,
color: '#666',
fillColor: 'white'
});
layer.bringToFront();
};
$scope.$on("leafletDirectiveGeoJson.mouseover", function(ev, leafletPayload) {
countryMouseover(leafletPayload.leafletObject.feature, leafletPayload.leafletEvent);
});
};
baseMapController.$inject = ['$scope', '$http', 'leafletData', 'Base64', 'leafletMapEvents'];
}());
and this is what i see on browser's console