So I’m trying to get the maps api working with Leaflet.
I call the url to retrieve the pbf-version of the vector data - but somehow I can’t get the styling working. I’m currently trying to get it to work with the VectorGrid-plugin (https://github.com/Leaflet/Leaflet.VectorGrid)
In my understanding the Map Web SDK also is based on Mapbox / Leaflet, so I was wondering how that’s implemented. I looked into the (minified) code of the SDK, but can’t figure out how they do it.
Can someone give some pointers how to make this working?
const map = new Map(
L.vectorGrid
.protobuf(
`https://api.tomtom.com/map/1/tile/basic/main/{z}/{x}/{y}.pbf?key=${TOMTOM_API_KEY}`,
)
.addTo(map);
};
The code above looks like this:
And I tried multiple ways of rendering and styling, but can’t seem to get it to work.
const vectorTileOptions = {
vectorTileLayerStyles: {
// A plain set of L.Path options.
landuse: {
weight: 2,
fillColor: '#9bc2c4',
fillOpacity: 1,
fill: true
},
water: {
weight: 2,
fillColor: '#00ff00',
fillOpacity: 1,
fill: true
},
['International road']: {
country_code: {
weight: 2,
fillColor: '#c41024',
fillOpacity: 1,
fill: true
}
},
country_code: {
weight: 2,
fillColor: '#3372c4',
fillOpacity: 1,
fill: true
},
Motorway: {
country_code: {
weight: 2,
fillColor: '#c48017',
fillOpacity: 1,
fill: true
}
}
},
};
I hope someone can point me in the right direction ^^