esri-leaflet-vector icon indicating copy to clipboard operation
esri-leaflet-vector copied to clipboard

Add suggested conversions between v1 and v2 basemap style enumerations

Open gowin20 opened this issue 1 year ago • 0 comments

Describe the problem

The new Basemap Styles Service v2 uses different basemap enumerations than version 1, and it is confusing. I think that users who are acustomed to v1 enumerations (e.g. ArcGIS:Imagery:Base) will be confused when their enumeration does not work with the new service (which expects arcgis/imagery/base to load the equivalent layer).

Describe the proposed solution

I would like to include a suggestion in the error message that displays when a v2 basemap is created using a v1 enumeration, and vice versa. The error message would read like the following:

Error: 'ArcGIS:Streets' is a v1 basemap style enumeration. Did you mean 'arcgis/streets'?

I have already written code that generates suggestions for the v2 service:

    const firstBreak = sourceAndStyle.indexOf(':');
    let secondBreak = sourceAndStyle.indexOf(':', firstBreak + 1);

    const source = sourceAndStyle.substring(0, firstBreak);
    const layer = (secondBreak !== -1) ? sourceAndStyle.substring(secondBreak + 1, sourceAndStyle.length) : null;

    if (secondBreak === -1) secondBreak = sourceAndStyle.length;
    const style = sourceAndStyle.substring(firstBreak + 1, secondBreak);

    const suggestion = source.toLowerCase() + '/' + style.toLowerCase() + (layer !== null ? '/' + layer.toLowerCase() : '');

However, providing a suggestion like this only makes sense if the original enumeration was valid. To check this, we would need to keep a static list of all valid basemap enumerations. This would obviously come with some overhead, so I'd like some feedback on whether or not this is reasonable

Alternatives considered

A self-describing endpoint is in the works for the v2 service that should return a json list of every supported basemap enumeration. It will not release for a while, but once it does we could deprecate our static list of enums in favor of this new endpoint. Luke Smallwood knows more.

Additional Information

No response

gowin20 avatar May 22 '23 20:05 gowin20