whimzee - 1 year ago 106
Javascript Question

# Getting LatLong of point on circle based on given angle

Given that you have this circle defined on your map, how would you get the LatLong of the point that intersects at a given angle?

``````var degrees = 90;
var center = {lat: 34.052235, lng: -118.243683};
center: center,
});

var pointOnCircle = ?
``````

You can use the geometry library `computeOffset` method:

``````  var pointOnCircle = google.maps.geometry.spherical.computeOffset(circle.getCenter(), circle.getRadius(), degrees);
``````

proof of concept fiddle

code snippet:

``````function initialize() {
document.getElementById("map_canvas"), {
zoom: 13,
});
var degrees = 90;
var center = {
lat: 34.052235,
lng: -118.243683
};
center: center,
map: map
});
map.fitBounds(circle.getBounds());
map: map,
position: pointOnCircle
});
map: map,
path: [circle.getCenter(), pointOnCircle]
})
}
``````html,
``````<script src="https://maps.googleapis.com/maps/api/js?libraries=geometry"></script>