Lance Pollard
Lance Pollard

Reputation: 79268

Given 1 Latitude/Longitude Coordinate and a distance of 5 miles - What's the distance in Pixels in Google Maps?

I can do this to convert a lat/lng to pixel coordinates in Google maps:

var xy = map.getProjection().fromLatLngToDivPixel(new google.maps.LatLng(lat, lng));

Now I'm wondering, how do I get a distance in pixels from that point? Say I want to draw a circle with a radius of 5 miles around that. How do I do that?

Upvotes: 2

Views: 780

Answers (2)

Argiropoulos Stavros
Argiropoulos Stavros

Reputation: 9533

In v3 there is the circle object

Upvotes: 2

RedBlueThing
RedBlueThing

Reputation: 42522

The best way to draw a circle around a given point is to draw a GPolygon with many points, simulating a circle.

You can find a good example of this here. Look for the drawCircle function in the source (you will need to download the attached circle.html to check it out.

Upvotes: 0

Related Questions