yandex-maps-api – Draw a semicircle / circle sector on the map

Question:

Is it possible to create a semicircle on the map or a sector using the API (not in the form of a triangle, but with an arc at the end), please advise how to do this.

as known data. Radius, Direction, angle φ, starting point. I know that there is a direct and inverse geodetic problem, but I have no end point, only distance and direction. By and large, the issue of drawing sectors on the map is of interest.

Answer:

You can simply draw a polygon of the desired shape.

The simplest solution looks like this: http://jsfiddle.net/tLs0d51u/
But there it turned out not quite a circle, since the circle is formed in spherical coordinates (in latitude and longitude), and not in Cartesian ones.

To draw a normal circle, you need to work with global pixel coordinates and then convert them to spherical.
It can be done like this:

var zoom = map.getZoom();
var projection = map.options.get('projection');

// широта и долгота -> пиксели
projection.toGlobalPixels([55.73, 37.75], zoom);

// пиксели -> широта и долгота
projection.fromGlobalPixels([158560.7111111111, 82211.42703728657], zoom);

Normal circle sector: http://jsfiddle.net/tLs0d51u/1/

Scroll to Top