React-map-gl: Draw a circle on a marker

Created on 31 Jan 2019  路  7Comments  路  Source: visgl/react-map-gl

Hello , I m new to this library and i couldnt find what i m looking for in the docs.
I have a map with a Marker and i would like to draw a circle with my marker as center with a certain radius.
My marker is a bus stop and the circle should show users a certain radius in meter
If anyone has clue on that
Thanks

Most helpful comment

I just found a simple workaround to do this:

  1. Create a GeoJSON polygon that mimics the shape of the circle, using @turfjs/circle
  2. Add this GeoJSON to a custom layer
  3. Add this layer to your map

All 7 comments

There is Marker example and Custom Overlay example in the repo.

Also you can check Marker, Custom Overlay and other docs.

Ok so to solve this i have to create my own custom component and insert it in my map component right? There is no build in solution for this ?

Yes. Something like the following.

 <MapGL ...>
   <Marker ... />
   <CircleOverlay .../>   
 </MapGL>

For the implementation of the circle, you can draw it on canvas (refer Custom Overlay, Canvas Overlay).

Or alternatively you can use deck.gl (refer DeckGL Overlay, DeckGL Scatterplot Layer).

<MapGL ...>
  <DeckGL>
    {...viewport}
    layers={[
      new ScatterplotLayer({
        data: [...],
        ...,
      })
    ]}
  />
</MapGL>

thanks a lot for your answers !

@dmi3y - might be relevant for you

Also missing this in the standard library. This was all so easy with Leaflet...

I just found a simple workaround to do this:

  1. Create a GeoJSON polygon that mimics the shape of the circle, using @turfjs/circle
  2. Add this GeoJSON to a custom layer
  3. Add this layer to your map
Was this page helpful?
0 / 5 - 0 ratings

Related issues

cjmyles picture cjmyles  路  3Comments

SethHamilton picture SethHamilton  路  3Comments

ckalas picture ckalas  路  5Comments

AriLFrankel picture AriLFrankel  路  3Comments

nip10 picture nip10  路  4Comments