Any way for a Google Maps placemark to trigger a script in the page that contains an embedded map

StackOverflow https://stackoverflow.com/questions/557621

  •  05-09-2019
  •  | 
  •  

Question

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

Was it helpful?

Solution

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).

OTHER TIPS

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

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?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top