calling function in Info window

81 views
Skip to first unread message

Anuj Jain

unread,
Jun 14, 2011, 2:05:54 PM6/14/11
to google-map...@googlegroups.com
I want to give a button on the infowindow of each marked to include that point in the path. But i cannot call function with parameter in the html.

  infowindow.setContent('<input onclick="addPlace(place.geometry.location)" value="Add to route" type="button">');
The function addPlace is not called as it gives the error that place is undefined object, but it works for the following
  infowindow.setContent(place.geometry.location);

how to call addPlace in html content by passing a parameter used in javascript

Rossko

unread,
Jun 14, 2011, 2:58:42 PM6/14/11
to Google Maps JavaScript API v3
> how to call addPlace in html content by passing a parameter used in
> javascript

Make sure that any variables used, like 'place', are in scope at the
time of the click

anuj jain

unread,
Jun 14, 2011, 3:01:35 PM6/14/11
to Google Maps JavaScript API v3
place is in scope, but the problem is that how to use that javascript
variable in html.

Rossko

unread,
Jun 14, 2011, 3:20:24 PM6/14/11
to Google Maps JavaScript API v3
> place is in scope,

That's not what "it gives the error that place is undefined object"
says.

Functions run from onclick run in global scope, standard javascript
stuff.

If only we could see your map in action, ah well.
Reply all
Reply to author
Forward
0 new messages