Detect Click Of State

33 views
Skip to first unread message

matterzmore

unread,
Dec 6, 2011, 1:06:53 PM12/6/11
to google-map...@googlegroups.com
Greetings All!

I could not find an answer to this question in the API documentation, so I will ask here:

Is it possible to detect the click of an individual state from the map? I would like to hook this event to fire a Javascript function, but I'm not sure how to do this.

Any help would be GREATLY appreciated!

Thanks,
Matterezmore

Marcelo

unread,
Dec 6, 2011, 1:48:58 PM12/6/11
to Google Maps JavaScript API v3
There are at least 2 ways to do it:

A. One polygon for each state with a click event handler, and keep
track of which polygon fired the event by passing some ID to the event
handler function.

B. AJAX call to the server and a database lookup.
This is a V2 example with counties instead of states:
http://maps.forum.nu/gm_main.html
Click anywhere in the US.

--
Marcelo - http://maps.forum.nu
--

geoco...@gmail.com

unread,
Dec 6, 2011, 4:02:56 PM12/6/11
to Google Maps JavaScript API v3
On Dec 6, 10:48 am, Marcelo <marcelo...@hotmail.com> wrote:
> There are at least 2 ways to do it:
>
> A. One polygon for each state with a click event handler, and keep
> track of which polygon fired the event by passing some ID to the event
> handler function.
>
> B. AJAX call to the server and a database lookup.
> This is a V2 example with counties instead of states:http://maps.forum.nu/gm_main.html
> Click anywhere in the US.

An example using fusion tables (a world map with clickable countries):
http://www.geocodezip.com/v3_FusionTablesLayer_worldmap_linkto.html

Example using KmlLayer (world map):
http://www.geocodezip.com/v3_GoogleEx_layer-kml_world_countries_simple.html

You could do the same with the US.

-- Larry

>
> --
> Marcelo -http://maps.forum.nu

Reply all
Reply to author
Forward
0 new messages