Google Map API v3 polygon shape creator
05 Sep 2011 Add Comments Intermediate LevelFuture code updates and FAQ will be announced on this page, please bookmark this page if you want to stay in touch.
- Part 1: Google Map API v3 polygon shape creator
- Part 2: PHP + Google Map polygon shape creator
Table Of Content
Content
1. About
Polygon Creator is a javascript class which can be used to draw a ploygon shape on Google Map, and it currently has two public functions to return the polygon paths and its color.
It is useful if you are looking for a ready to use Javascript tool to create polygon for your Google Map application.
Polygon Creator is built with Jquery and written in a OOP coding style. It is written in Goolge Map API v3.
And of course, it is completely free, so please make use of it.
2. How to use
-
Include scripts
Include Google Map API:
Include JQuery:
Include Polygon Creator class:
-
Create a map object
If you have already constructed a map object, then you can skip this step. And just keep in mind, you will use the same map object to create Polygon Creator. First make sure you have a Div with id=”main-map” in your page body,then construct a map object as below:
-
Construct Polygon Creator object
The parameter of PolygonCreator is the map which we have created above.
-
Test and Run
Now you should be able to draw polygon shape on your google map. And there are two class functions you can call to retrieve polygon information:
- Other functions
Destroy the polygon on the map
3.Demo
You can view the demo page from here.
4.Download
You can download this script from my github account.
5.The End
Thank you for reading this article, and if you have any encountered anything different, have a different solution or think our solution is wrong, do let us know in the comment section.
We will be very happy to hear that.
If you like our tutorial, please follow us on Twitter and help spread the word. We need your support to continue.



14 Comments
Hi, very useful utility. But how do I retrieve the coordinates for the polygon to store them and rebuild it at a later date?
Hi
You will have to store them into database using a backend language.
Regards
XD
Awsome...i hope use it soon on a website. Tks!
Do let us know if you make use of it.
Regards
XD
Could you tell about the ways for storing the drawn polygon ?
Does google map v3 provided any methods for saving it ?
Thanks in advance . Great post
You should use the get API to get the lang/lng and store them into
the database, using a server side language.
Google Map is a client side map. I will try to write a tutorial on how to save it using PHP soon.
Stay tuned!
Regards
XD
Have you completed the tutorial? I need it
Hi
We have not yet completed the tutorial.
Thanks for checking in.
Regards
XD
Hi Xu DIng,
It is really helpful tutorial.
I am new to google maps api and I downloaded your script put it in my eclipse and tried to run it but I can't see any Maps getting rendered in my page. In fact if i double click on html page then every thing works fine. what is the problem when I run with Tomcat. have i need to do anything?
problem solved, It was an issue with my tomcat and path problem.
very usefull, thank you !
Thanks a bundle! This + the Google maps documentation got my page up & running in under half an hour. Great!
Glad to here that.
Cheers
XD
Hello,It's very useful utility.
Thank you so much!!!