views:

573

answers:

3

Is there any way to have a map's placemark call a javascript method on the page that contains the map.

For example: Say we have a google map that has pins for our customers. If the sales operator clicks on the pin of CompanyA, could the containing page use javascript to identify that ConpanyA's pin had been clicked. And show a quick report on that companies activities?

EDIT: sorry guys, should have mentioned that we wanted to build and load the placemarks via KML

A: 

I believe you put arbitrary HTML into the pin's popup with the Google Maps AJAX API. I know I can put an anchor tag (a href=blah) in there, so couldn't you just can make a clickable link that has a javascript:blah() url instead of some url on the web?

Jared Updike
+1  A: 

I did something like that here. Feel free to check out the source :)

Robert Grant
That is really great. Thanks for sharing. I really like the mouse over effect!
Jared Updike
+3  A: 

Yes, you can hook up an event to the marker (I use the Marker Manager).

GEvent.addListener(marker,'click',function(){..your code..})

See the api doc here: http://code.google.com/apis/maps/documentation/reference.html#GMarker (scroll down to the "Events" section).

Diodeus
I think this is going to be the way - more reading of the Maps API and experimentation required. BTW there seem to be some relevant articles in the Related col on the right !
Adrian