Select to view content in your preferred language

Vector Tile basemaps in MapLibre

436
3
06-13-2024 01:12 AM
Labels (1)
DiegoDíazDoce
Emerging Contributor

Hello,

I'm trying to add a vector tile basemap other than the basemap styles service, which works fine.

I'd like to replace the basemap styles service with other vector tile basemap like OpenStreetMap (WGS84) or GB Cartographic .

To do this, I've tried getting the styles url by going to the tile service item in agol and clicking "View style". Then I paste that url in the CodePen snippet from the 'Display a map' tutorial, but get some errors in my console:

DiegoDazDoce_0-1718265824914.pngDiegoDazDoce_1-1718265858979.png

Can anybody advice how to add vector tile basemaps in MapLibre?

Many thanks in advance,

Diego

0 Kudos
3 Replies
John-Foster
Esri Contributor

Try starting with this code sample https://developers.arcgis.com/maplibre-gl-js/styles-and-data-visualization/display-a-custom-basemap-...

The ID for the OpenStreetMap (WGS84) is cabd61a6cfc44843b2ccd6969bb88cf0

--jf
0 Kudos
DiegoDíazDoce
Emerging Contributor

Hi John,

Thank you for taking the time to look into my question. I have some follow up questions if you don't mind:

Will the url from the code sample you pointed at (https://basemapstyles-api.arcgis.com/arcgis/rest/services/styles/v2/styles/items/${agolItemID}?token... work with any vector tile as long as it's hosted in agol?

Is there a reason why it wouldn't work with my other example GB Cartographic  with id a599af89dc6d4960ba558d54337df2ee?

I'm getting the error below:

DiegoDazDoce_0-1718386469236.png

Someone pointed out that this could be due to a malformed url in the service

DiegoDazDoce_1-1718386630790.png

If that's the case, do you know where that url is configured? I'm hoping that I can ask the owner of the item to fix it.

Thanks again,

Diego

 

0 Kudos
John-Foster
Esri Contributor

I was not able to get the GB Cartographic map to load in MapLibre, it appears the tile URL is incorrect and I can't figure out how to fix it. I suggest contacting the email that is provided on the item maybe you can work with them to resolve this issue? https://www.arcgis.com/home/item.html?id=a599af89dc6d4960ba558d54337df2ee

 

The URL is configured in the style JSON in the sources key - https://www.arcgis.com/sharing/rest/content/items/a599af89dc6d4960ba558d54337df2ee/resources/styles/...

--jf
0 Kudos