Link to home
Start Free TrialLog in
Avatar of erzoolander
erzoolander

asked on

Google Maps Image Overlay Radius?

I've got a script I'm writing where the user can pick arbitrary points - and once the point is selected an overlay showing a 30, 60, 90 mile radius map will be set.

Only question I have is - from what I've been reading - it looks like you need to set an image rect (based upon lat/long points) to define that area.  

Since the points are arbitrary - I won't know ahead of time what the rect points will be.  Is there an efficient means to compute either the lat/long points on the fly - or can I set the image rect boundaries to a simple radius instead of defined lat/long points?

Any suggestions?
Avatar of Tom Beck
Tom Beck
Flag of United States of America image

You don't need an image. Google Maps v3 allows you to draw a circle on a map of a given radius in meters that will scale with the map. It's center can be bound to a marker. You can use getBounds() to retrieve the northwest and southeast corners of the circle's bounding rectangle then use fitBounds() to set the zoom level of the map to the size of the rectangle. Need a sample?
Avatar of erzoolander
erzoolander

ASKER

Thanks for the offer!  We're actually using an image because we want to add extra labeling and not just have it be a colored circle.  Is there a way to (in a nice cosmetic way) add some labels to the circle lines?

For example - say we had two lines - 250mi and 500mi - and I wanted to put "250" somewhere next to the circles to denote the distance.  I know how to add a circle via the API - but not put an API generated label next to it.  Is that even possible - or would I need to stick with an image the way I was originally intending?

I'll give you the points due to the lack of clarity - and the fact you answered correctly anyhow!  :)
ASKER CERTIFIED SOLUTION
Avatar of Tom Beck
Tom Beck
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial