Leaflet.contextmenu icon indicating copy to clipboard operation
Leaflet.contextmenu copied to clipboard

Issue when using Leaflet.contextmenu with Cartodb.js

Open boldtrn opened this issue 7 years ago • 5 comments

Hi,

I just recently updated my version of the contextmenu. I use cartodb.js . This library stopped working when updating to the new version of the Leaflet.contextmenu.

I was able to track it down to the changes made in this commit. So with the version before that commit everything works as expected. With this version it stopped working. I am not sure why this happens, there are no exception or anything, it just stops working. Haven't had too many issues with other libs and Cartodb, so maybe there is something we could change to make it working again? Sorry but I have no idea what could be wrong, maybe you have an idea?

I will also open an issue at Cartodb and link to this one.

Best, Robin

boldtrn avatar Feb 15 '17 00:02 boldtrn

Hi Robin, I'm not familiar with cartodb.js so I can only suggest some starting points to debugging the problem. Check there are no errors in the browser's error console, check the cartodb library is being loaded by the browser, check if the global cartodb object is available in the page onload handler, load an unminified version of the library and put some strategic debug statements in there.

aratcliffe avatar Feb 15 '17 02:02 aratcliffe

@aratcliffe Thanks for your reply.

If I use this version of Leaflet.contextmenu everything works. If I use this version, it stops working. So some incompatibility was introduced. I have no idea what exactly caused the problem. So I was wondering if you would have an idea what could have caused the issue. Maybe you are overwriting any globals or something?

boldtrn avatar Feb 15 '17 03:02 boldtrn

I didn't do the work on the UMD wrapper, which appears to be the major change introduced in that version, but the plugin itself shouldn't be doing anything with any globals. How did you get on with the debugging suggestions I made earlier?

aratcliffe avatar Feb 15 '17 04:02 aratcliffe

How did you get on with the debugging suggestions I made earlier?

Well the cartodb object is available. There is also one request fired towards carto.com that is getting some generic data about my carto viz. But nothing more. When I use an older version of Leaflet.contextmenu there are a couple of requests done, retrieving my actual carto viz.

I haven't done any actual debugging attempts of the carto code (mostly because it is a massive pile of code). My issue is kind of fixed with using the older version. However, it is a bit frustrating that there seems to be an interference with the two libraries. Since I don't know which library is "breaking out of its bounds" I opened an issue for both. The problem is, that once you break out of the bounds the interference is not limited to the combination of Leaflet.contextmenu and cartodb but probably happens with other libs, as well.

boldtrn avatar Feb 15 '17 05:02 boldtrn

As I mentioned earlier the major change in that release was the introduction of the UMD wrapper. The code for that is contained in src/copyright.js and src/end.js. I would look at including the src version of this library and setting a breakpoint in the wrapper function to check that it's selecting for the correct runtime environment.

aratcliffe avatar Feb 15 '17 05:02 aratcliffe