N
N
Nikita Melikhov2018-08-03 14:41:55
JavaScript
Nikita Melikhov, 2018-08-03 14:41:55

How to display a circle in Mapbox GS JS that changes radius according to zoom?

I have a custom map (with image overlay) with GeoJSON data:
5b643e52702ca998372240.png
I need to add a click handler to the circle of an object (a checkpoint on my map). For polygonal areas, everything is fine, each point has its own geo-coordinate, but for a circle there are only center coordinates and a radius in pixels. You need to somehow make the dependence of the radius on the scale of the map, otherwise when you change the scale, you get this:
5b643f1035d3f439246301.png
5b643f170f575810023054.png
How can I implement this? Everything is OK with the event handler, the problem is only with the size of the circle.
PS Mapbox GL JS supports expressions/functions in values, there is no need to process the zoom event and change the size in it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2018-08-03
@VeroLom

Here is an example where the size of the circle is tied to the zoom of the map.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question