angular-leaflet-directive


Detecting right click position on angular leaflet map


I have a mobile page showing a map using angular-leaflet-directive 0.7.11, and have declared my required events like so:
$scope.map = {
events: [
'mousedown',
'contextmenu'
],
...
}
$scope.$on('leafletDirectiveMap.mousedown', function (event) {
debugger;
});
Where the debugger statement is, the event variable contains no information about where the map was clicked. The same event format was provided by the directive when the contextmenu event is triggered.
In fact, if I inspect the entire event variable, it is just an Object, not an Event:
Are the docs wrong? Is the example missing something? How can I obtain the X/Y or Lat/Lng for the particular position that I have right-clicked (tap-hold)?
You need to use the 'leafletEvent'. Try this:
myApp.controller('YourController', ['$scope', 'leafletEvent', function($scope) {
$scope.$on('leafletDirectiveMap.mousedown', function (event, leafletEvent) {
leafletData.getMap().then(function(map) {
map.on('click', function(e) {
console.log('e');
console.log(e);
console.log('e.latlng:');
console.log(e.latlng); // L.LatLng {lat: 19.642587534013046, lng: -4.5703125}
});
});
});
}]);

Related Links

Leaflet angular directive blank map
angular-leaflet-directive : loading spinner in leaflet when load layer
Detecting right click position on angular leaflet map

Categories

HOME
date
reflection
gremlin
heroku
google-play
lodash
iot
webstorm
jsp-tags
cvs
microservices
sql-server-2016
networkx
session-variables
orchardcms
fortumo
visual-studio-cordova
ups
workload-scheduler
apache-metamodel
jqwidget
reverse-proxy
kryo
mps
core-text
emgucv
android-widget
p-value
poltergeist
internet-explorer-9
virtualdub
rst2pdf
msys2
webkitspeechrecognition
tasklet
karaf
catel
caret
android-nestedscrollview
mapbox-gl
android-ble
dartium
qwerty
swisscomdev
uft-api
unobtrusive-validation
user-controls
tasker
trim
ws-security
particles.js
netcdf4
reactive-cocoa-5
node-sass
executenonquery
scorm
azure-application-gateway
termination
dds
celery-task
aurelia-validation
lowpass-filter
tactic
libusb-win32
python-cryptography
color-profile
crosswalk-runtime
background-service
specrun
google-cdn
livequery
wapiti
netmq
ford-fulkerson
pervasive-sql
cyclomatic-complexity
jmeter-maven-plugin
apache-commons-fileupload
clipperlib
gulp-less
mesa
jquery-layout
xceed-datagrid
hyprlinkr
prettify
gnu-smalltalk
spring-io
pushbackinputstream
xamlparseexception
orchardcms-1.7
first-responder
postgresql-performance
dotnethighcharts
gnu-prolog
cinema-4d
rfc1123
propagation
dentrix
icanhaz.js
multi-tier
webkit.net
backcolor
boost-smart-ptr
document-conversion
misv

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App