민서네집

leaflet.js 팝업(Context Menu) 띄우기 본문

WEB (HTML, CSS)

leaflet.js 팝업(Context Menu) 띄우기

브라이언7 2018. 10. 19. 14:52

https://gis.stackexchange.com/questions/49869/how-to-open-popup-menu-on-right-click-in-leaflet


Opens new popup on right click, don't forget to set the coordinate where the popup window should be placed by calling setLatLng function, otherwise you will get following error: leaflet.js:5 Uncaught TypeError: Cannot read property 'lat' of undefined at Object.project

map.on('contextmenu',(e) => {
  L.popup()
  .setLatLng(e.latlng)
  .setContent('<pre>Hello</pre>')
  .addTo(map)
  .openOn(map);
});


Comments