Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v12 styles don't work anymore #10

Open
nicolaric-akenza opened this issue Jul 10, 2024 · 4 comments
Open

v12 styles don't work anymore #10

nicolaric-akenza opened this issue Jul 10, 2024 · 4 comments

Comments

@nicolaric-akenza
Copy link

Somehow, v12 styles (e.g. mapbox://styles/mapbox/streets-v12) do not work anymore. the models between mapbox and maplibre seem to be out of sync. can we map the models somehow in this library?

image
@truongvan
Copy link

There is a variation between the style specifications of Mapbox and Maplibre. All you need is a transformStyle function to correct the differences.

@danielkurecka
Copy link

Here is a transformStyle function that fixes it:

map.setStyle('mapbox://styles/mapbox/streets-v12', {
    transformStyle: (previousStyle, nextStyle) => {
        if (nextStyle.projection && nextStyle.projection.name) {
            delete nextStyle.projection.name;
        }
        return nextStyle;
    },
});

The issue is due to projection.name not being a valid property in MapLibre's style specification.

https://maplibre.org/maplibre-style-spec/projection/
https://docs.mapbox.com/style-spec/reference/projection/

@dbauszus-glx
Copy link

How does this work in combination with the transformRequest example?

import { isMapboxURL, transformMapboxUrl } from 'maplibregl-mapbox-request-transformer'

const mapboxKey = 'pk.123'

const transformRequest = (url: string, resourceType: string) => {
  if (isMapboxURL(url)) {
    return transformMapboxUrl(url, resourceType, mapboxKey)
  }
  
  // Do any other transforms you want
  return {url}
}

var map = new maplibregl.Map({
  container: 'map',
  center: [-122.420679, 37.772537],
  zoom: 13,
  style: 'mapbox://styles/mapbox/satellite-streets-v11',
  transformRequest
});

I added the setStyle with the transformStyle method but to no avail.

@axekan
Copy link

axekan commented Feb 6, 2025

How does this work in combination with the transformRequest example?

import { isMapboxURL, transformMapboxUrl } from 'maplibregl-mapbox-request-transformer'

const mapboxKey = 'pk.123'

const transformRequest = (url: string, resourceType: string) => {
if (isMapboxURL(url)) {
return transformMapboxUrl(url, resourceType, mapboxKey)
}

// Do any other transforms you want
return {url}
}

var map = new maplibregl.Map({
container: 'map',
center: [-122.420679, 37.772537],
zoom: 13,
style: 'mapbox://styles/mapbox/satellite-streets-v11',
transformRequest
});
I added the setStyle with the transformStyle method but to no avail.

Try adding validateStyle: false to maplibre options. Example:

const map = new maplibregl.Map({
    container: mapContainer,
    style: 'mapbox://styles/mapbox/satellite-streets-v12?optimize=true',
    validateStyle: false,
    center: [18.0686, 59.3293],
    zoom: 12,
    transformRequest,
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants