I have some geojson shapes I'm passing to the Mapbox static maps API. Some of the shapes are polylines, others are circles represented as points with a radius property e.g:
{
"type": "Feature",
"properties": {
"radius": 500
},
"geometry": {
"type": "Point",
"coordinates": [
30.5,
50.5
]
}
}
These get rendered as points with a marker. Is there any way I can get a point to render as a circle of a certain radius centered around that point?
The Mapbox Maps SDK does not come with a default marker image built-in. You can download a classic teardrop marker in the Android and iOS annotations guides. If you are adding markers for custom data in Mapbox Studio, we recommend that you add a custom icon to your style.
Static maps are standalone images in PNG format that can be displayed on web and mobile devices without the aid of a mapping library or API. They look like an embedded map without interactivity or controls.
The Mapbox web services APIs allow you to programmatically access Mapbox tools and services. You can use these APIs to retrieve information about your account, upload and change resources, use core Mapbox tools, and more. Mapbox APIs are divided into four distinct services: Maps, Navigation, Search, and Accounts.
You can use layer type : circle to display the points as circles. You can then use expressions to get the radius from your geojson properties: Check the JS Fiddle
map.addLayer({
'id': 'demo',
'type': 'circle',
'source': 'points',
'paint': {
// use get expression to get the radius property. Divided by 10 to be able to display it
'circle-radius': ['/',['get', 'radius'],10],
'circle-color': "blue"
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With