Is it possible to create a semicircle on a map or a sector (not in the form of a triangle, but so that there is an arc at the end) using the API, 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 question of drawing sectors on the map is of interest.

    2 answers 2

    You can simply draw a polygon of the desired shape.

    The simplest solution looks like this: http://jsfiddle.net/tLs0d51u/
    But it turned out not quite a circle, because 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 translate them into spherical.
    This 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); 

    Sector of the normal range: http://jsfiddle.net/tLs0d51u/1/

      I rendered the sector through the solution of the direct geodesic task, while in the initial data it had a radius, angle, and coordinates of the starting point.

        function getAreaCoord(point, azimut, corner, length) {// ΠΏΠΎΠ»ΡƒΡ‡Π΅Π½ΠΈΠ΅ ΠΊΠΎΠΎΡ€Π΄ΠΈΠ½Π°Ρ‚ сСктора var sector = []; var firstSide = Math.PI * ((360 - azimut) + 90) / 180, // Π°Π·ΠΈΠΌΡƒΡ‚ Π² Ρ€Π°Π΄ΠΈΠ°Π½Π°Ρ… secondSide = firstSide - (Math.PI * corner / 180), dir2 = [Math.sin(firstSide), Math.cos(firstSide)]; // Π½Π°ΠΏΡ€Π°Π²Π»Π΅Π½ΠΈΠ΅ ΠΏΠΎ Π°Π·ΠΈΠΌΡƒΡ‚Ρƒ sector[0] = ymaps.coordSystem.geo.solveDirectProblem(point, dir2, length).endPoint; var i = 1; for(var sectopPoint = 5; sectopPoint <= corner; sectopPoint += 5) { var middlePoint = sectopPoint; var side = firstSide - (Math.PI * middlePoint / 180); var dir4 = [Math.sin(side), Math.cos(side)]; sector[i] = ymaps.coordSystem.geo.solveDirectProblem(point, dir4, length).endPoint; i++ } return sector; }