Openlayers Pmtiles Vector Styling

Discussão em 'Angular' iniciado por john warhammer, Julho 30, 2025.

  1. I have some .pmtiles that i serve using a server, in my angular code i create a new layer using PMTilesVectorSource, i want to style it using the stlye.json i got from the https://maps.protomaps.com/ website, i tried somethings including using applyStyle, but i cant get it to work. Im using ol@9.2.4, ol-mapbox-style@11.0.3, ol-pmtiles@2.0.2

    I tried to use the applyStyle with the PMTilesVectorSource layer and the json, in the json i changed the url to remove the pmtiles:// part as that caused problems, i get 200OK as a response but the console log says it cannot fetch the source

    export class PMTilesManager {
    constructor(
    private http: HttpClient,
    private url: string = EnvironmentManager.get('pmtilesUrl'),
    ) {}

    public async getPMTilesLayer(): Promise<VectorTileLayer<any>> {
    const style = await firstValueFrom(this.http.get<any>('assets/pmtiles-style.json'));

    const source: PMTilesVectorSource = new PMTilesVectorSource({
    url: this.url,
    format: new MVT(),
    });

    const layer: VectorTileLayer<RenderFeature> = new VectorTileLayer<RenderFeature>({
    declutter: true,
    source: source,
    });

    applyStyle(layer, style, 'protomaps');

    return layer;
    }
    }

    Continue reading...

Compartilhe esta Página