Angle inside a Google ray maps

Asked

Viewed 487 times

0

I have a project using google maps, where I receive the latlng information (which will create a marker in this location), as well as radius and azimuth, knowing that the angle will always be 60°. How can I form an angle with the azimuth, within a radius that was created with google.maps.Circle around the marker?

I hope I have managed to express my doubt, to better exemplify I am leaving an image below.

inserir a descrição da imagem aqui

1 answer

0


My problem was solved through this mathematical calculation:

var latConv = google.maps.geometry.spherical.computeDistanceBetween(latlng, latlng1) / 1000;
var lngConv = google.maps.geometry.spherical.computeDistanceBetween(latlng, latlng2) / 1000;

var calcRaio = raio / 1000;

        for (var i = (azimute - angulo / 2) ; i <= (azimute + angulo / 2) ; i += 2) {
            var pint = new google.maps.LatLng(latlng.lat() + (calcRaio / latConv * Math.cos(i * Math.PI / 180)), latlng.lng() + (calcRaio / lngConv * Math.sin(i * Math.PI / 180)));
            points.push(pint);
        }
            map.addPolygon('black', '#0000FF', points, 99999); //Cria o setor

Browser other questions tagged

You are not signed in. Login or sign up in order to post.