alturium
alturium

Reputation: 583

Leaflet contextmenu is not working or responding to events

(Posting this for fellow noobs who might make the same mistake as me...)

I combined two github projects: Leaflet.contextmenu with the bootleaf project.

I started with bootleaf and added <script>, <link> to the index.html. Since I was using the bootleaf index.html, it already had the <script src=".../app.js"> where the map was created:

map = L.map("map", { ... });

Unfortunately, I added the dist/leaflet.contextmenu.js and src/Map.ContextMenu.js files also but added them AFTER app.js. This caused the code to not be initialized (since it is a plug-in).

Upvotes: 1

Views: 776

Answers (1)

alturium
alturium

Reputation: 583

Make sure to get the right order for the like thus:

  <script src="node_modules/leaflet-contextmenu/dist/leaflet.contextmenu.js"></script>
  <script src="node_modules/leaflet-contextmenu/src/Map.ContextMenu.js"></script>

  <script src="assets/js/app.js"></script>

Upvotes: 1

Related Questions