You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, thanks a lot for your nice work! I am trying to make the context menu https://github.com/aratcliffe/Leaflet.contextmenu plugin work with your add-on. In plain JavaScript it would probably be done like this:
varmap=L.map('map',{contextmenu: true,contextmenuWidth: 140,contextmenuItems: [{text: 'some menu item',callback: doSomething});
So my first problem is that this requires extending the MapOptions interface (?!). But this does not seem to be right, because you probably do not want to add more methods to MapOptions every time a new leaflet plugin gets added and even more so it would be nice to use plugins without changing this add-on at all.
varmap=L.map('map');L.setOptions(map,{contextmenu: true,contextmenuWidth: 140,contextmenuItems: [{text: 'some menu item',callback: doSomething}]});map.addHandler('contextmenu',L.Map.ContextMenu)
Can you give some advice how to do this for leaflet4vaadin? Generally, how should a Leaflet.Handler be added to the map? Btw if you are interested in adding context menu here I can also send a PR once I made it work.
The text was updated successfully, but these errors were encountered:
Hi,
Apologies for the Late Reply.
This add-on currently doesn't support leaflet handlers, but I tried to make it flexible, so you can extend MapOptions if you want. If you implemented the context menu plugin and if you want you can send me a PR and I will merge it.
//we need to implement a POJO that stores the options of the context menu plugin such us contextmenuWidth, contextmenuAnchor, etc.
ContextMenuOptions contextMenuOptions = new ContextMenuOptions();
contextMenuOptions.setContextmenuWidth(200);
//we need to implement a POJO that stores the options of each menu item such as text, icon, callback, etc.
List<ContextMenuItem> contexMenuItems = new ArrayList<>();
contexMenuItems.add(new ContextMenuItem(text, icon, callback, ...);
contexMenuItems.add(new ContextMenuItem(text, icon, callback, ...);
//we need to add items to the context menu options
contextMenuOptions.setContextmenuItems(contexMenuItems);
//we need to implement an "apply" or "extend" method in map options which able to extends its properties dynamically.
mapOptions.apply(contextMenuOptions);
LeafletMap leafletMap = new LeafletMap(mapOptions);
leafletMap.setBaseUrl("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png");
addToContent(buttons, leafletMap, pluginRepository);`
Currently the MapOptions serialized as JSON like this: { center: {lat: 17.0, lng: 12.0}, zoom: 12, .... }
but it will look like this after we successfully implement the "apply" method: { center: {lat: 17.0, lng: 12.0}, zoom: 12, contextmenu: true, contextmenuWidth: 200 .... }
Hey, thanks a lot for your nice work! I am trying to make the context menu https://github.com/aratcliffe/Leaflet.contextmenu plugin work with your add-on. In plain JavaScript it would probably be done like this:
So my first problem is that this requires extending the
MapOptions
interface (?!). But this does not seem to be right, because you probably do not want to add more methods toMapOptions
every time a new leaflet plugin gets added and even more so it would be nice to use plugins without changing this add-on at all.So another more flexible way would be adding the ContextMenu (which is implemented as a leaflet Handler: https://github.com/aratcliffe/Leaflet.contextmenu/blob/202b2ca8b302431f6d99ce93edf95684d4ee4422/src/Map.ContextMenu.js#L5) manually after creating the map:
Can you give some advice how to do this for leaflet4vaadin? Generally, how should a Leaflet.Handler be added to the map? Btw if you are interested in adding context menu here I can also send a PR once I made it work.
The text was updated successfully, but these errors were encountered: