views:

794

answers:

2

Hi,

I have 4 days of experience with Google Maps Javascript API and i find their documentation and information sharing confusing at best.

Does anyone have experience or knowledge on how to draw polygons/polylines on a google map (using Javascript API V3) similar to this example? (which i found on this blogPost from 2008)

So far as my research can tell me the example uses the Javascript API V2 directly or uses the GeometryControl utility library from V2 (which can be found here for reference). I cannot seem to find if the Javascript API V3 has any way of allowing such interface.

I will be continuing my research but would appreciate any helpful comment or link or suggestion. Even if you point me in the correct direction for further research. :)

Thanks,

+1  A: 

Take a look at this example, from the Maps API v3 examples page:

http://code.google.com/apis/maps/documentation/javascript/examples/polyline-complex.html

The code listens to clicks on the map, and on each click adds an extra lat/lng pair into the array of a polyline. This results in a polyline which joins each clicked point.

Extending this to polygon should be relatively simple. At some point you will need to close the polygon. You could do this by listening to a click on the polygon or a marker (indicating an intersection) or by having a button the user can click, and setting the polygon to autoclose.

plexer
thanks for the info plexer. I found two things of interest, one which i will mark as an 'answer' to the question. But FYI look at http://www.shanetomlinson.com/2010/enabledrawing-enableediting-for-gmap-v3/ and his example. Its still a bit unstable so not the best solution but he seems to be heading in the right direction.
logansama
A: 

After much research i came across this example. Which, after discovering it and googling it, seems the general answer to questions like mine. This is very basic but correct according to the V3 API.

Using the code in this example i am successfully building a prototype that i need. The code is basic but i have found that it can be extended to better fit my specifications, which is good.

The link provided in my comment to plexer's answer would be the best solution but the person developing it states that it is still under development and thus not stable enough for use in release applications.

logansama