Esri / esri-leaflet-vector

Display ArcGIS Online vector basemaps w/ Esri Leaflet
Apache License 2.0
56 stars 57 forks source link

Allow users to set preserveDrawingBuffer in the options #199

Closed sheeley820 closed 1 year ago

sheeley820 commented 1 year ago

It was discovered that printing maps rendered with esri-leaflet-vector does not work in Firefox.

An issue was created here.

This PR fixes that issue by allowing the user to set preserveDrawingBuffer to true, which resolves the issue. It is set to false by default in the maplibre-gl-js project in the scr/ui/map.ts file for performance optimizations. Adding the ability for a user to toggle this value through esri-leaflet-vector, but maintaining a default of false will help users who want to provide printing capabilities, while maintaining the performance optimization for those who do not have this need.

gavinr-maps commented 1 year ago

Thank you for the PR.

If we Expose the MaplibreGLJSLayer Variable (#197), this PR #199 is not needed, correct? Because you could modify the preserveDrawingBuffer property on the exposed MaplibreGLJSLayer Variable.

sheeley820 commented 1 year ago

@gavinr-maps So technically it is possible to do the following even without MaplibreGLJSLayer being exposed:

const vector = L.esri.Vector.vectorBasemapLayer(basemapEnum, {
        apiKey: apiKey
    })
vector.options.preserveDrawingBuffer = true
vector.addTo(map)

And this resolves the printing error, but for me it seems like since we already allow MapLibre options to be passed directly into the VectorTileLayer initialization (pane, opacity) it would make sense to allow perserveDrawingBuffer to be passed in through the VectorBasemapLayer and VectorTileLayer constructors as well.

gavinr-maps commented 1 year ago

Looks good. In the future if people need access to more options, we should introduce a mapLibreMapOptions property. But we can avoid prematurely optimizing by just going with this for now.

gavinr-maps commented 1 year ago

This was released in v4.2.0.