Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you draw a circle on a mapbox static map?

Tags:

mapbox

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?

like image 789
Justin Dearing Avatar asked Jun 07 '15 15:06

Justin Dearing


People also ask

How do you add a marker in Mapbox?

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.

What is a static map?

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.

What is API Mapbox com?

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.


1 Answers

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"
            }
        });
like image 138
rodrigomd Avatar answered Sep 30 '22 17:09

rodrigomd