Esri / esri-leaflet-vector

Display ArcGIS Online vector basemaps w/ Esri Leaflet
52 stars 53 forks source link

Expose MaplibreGLJSLayer Variable #197

Closed sheeley820 closed 12 months ago

sheeley820 commented 1 year ago

We are wanting to implement printing in our application using this plugin, and one of the things that this plugin does is a layer cloning process. While cloning the VectorBasemapLayer does generate the MaplibreGLJSLayer, it also throws a warning that it cannot identify this layer. However, if the MaplibreGLJSLayer were exposed this would not be an issue.

Upon looking through the code I could not identify a reason why MaplibreGLJSLayer should not be exposed.

gavinr-maps commented 1 year ago

Hi @sheeley820, thanks for the PR. Could you give us a few more details on the replication case of when you're using the print plugin what is the error that you're seeing? Preferably is a JSBin or something so we can see the same issue you're seeing. Thanks!

iammcgaber commented 1 year ago

@gavinr-maps I am working with the Leaflet Browser Print plugin which replicates layers for printing, and one of the layers is the MapGL layer that is defined in this project. While calling the constructor for the vector layer does recreate the MapGL layer for printing it throws an error as the printing plugin is unable to identify the type of the MapGL layer. So exposing that variable would allow me to map the type directly to that layer and eliminate that error.

gavinr-maps commented 1 year ago

Thanks @iammcgaber. Would you be able to create a codepen or jsbin that demonstrates the issue? You can start with this template: https://jsbin.com/zutofox/edit

sheeley820 commented 1 year ago

See this jsbin: https://jsbin.com/buhajar/edit?html,output

Printing shows the warning:

runner-4.1.8.min.js:1 Unknown layer, cannot clone this layer. Leaflet version: 1.9.4
...
For additional information please refer to documentation...

Obviously registering the MaplibreGLJSLayer only works if it is exposed, so even though I attempt to register it here we still get the warning as it is using the stock code.

It is just a warning, so if we don't want to expose that type it isn't the end of the world, but it would also be nice to eliminate that warning.

gavinr-maps commented 1 year ago

@sheeley820 thank you for the jsbin example. I'm not getting a valid print (Gray area) when I use your Jsbin example - is that expected?

image image

sheeley820 commented 1 year ago

@gavinr-maps This appears to be an issue with JS Bin. See this CodePen where the print preview appears as expected: https://codepen.io/McGaber/pen/vYvryVK

gavinr-maps commented 11 months ago

This was released in v4.2.0.