Polyline Events in in Google Maps API v3

2,680 views
Skip to first unread message

jlove

unread,
Feb 15, 2010, 2:54:55 AM2/15/10
to Google Maps JavaScript API v3
Is there an example of how to add an event listener for Polylines? I
have been able to add all of the event listeners for markers, but none
for Polylines... I assume there is something wrong with:

google.maps.event.addListener(polyline, 'click', function ()
{ alert('click');});

where polyline is a polyline that is displayed. is there a
polyline.setClickable(); that needs to be set?

Marcelo

unread,
Feb 15, 2010, 9:47:22 AM2/15/10
to Google Maps JavaScript API v3
On Feb 15, 8:54 am, jlove <drli...@gmail.com> wrote:
> Is there an example of how to add an event listener for Polylines? I
> have been able to add all of the event listeners for markers, but none
> for Polylines... I assume there is something wrong with:
>
>    google.maps.event.addListener(polyline, 'click', function ()
> { alert('click');});
>

Maybe the variable polyline is actually a potato. We can't know that.
Your syntax is the same as shown in the documentation, but unless you
follow the posting guidelines and demonstrate the problem not many
people can help. (I will not bother to set up an example to test
someone else's problem)

Posting Guidelines
http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/2b3f101fd509919e#
http://groups.google.com/group/Google-Maps-API/web/why-including-a-link-is-critical


> where polyline is a polyline that is displayed. is there a
> polyline.setClickable(); that needs to be set?


Is there a polyline.setClickable() in the documentation?

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

jbogdani

unread,
Feb 16, 2010, 2:18:44 AM2/16/10
to Google Maps JavaScript API v3
>    google.maps.event.addListener(polyline, 'click', function ()
> { alert('click');});

google.maps.event.addListener(MyPolyline, 'click', function(event){
some js functions
});
works fine for me in v3!

event is optional, but there is a bug actually with event handler
http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/3ee0bd59a57eae79/0942215a432e046a?lnk=gst&q=event.latLng#0942215a432e046a

try changing the name of the variable "polyline", maybe there is some
compatibly problem with that name

Reply all
Reply to author
Forward
0 new messages