addeventlistener - google maps mousemove and click listener together -
i use mousemove listener on google maps, while want handle click event too.
var path = new google.maps.mvcarray; ... line = new google.maps.polyline({ map: map, path: new google.maps.mvcarray([path]), }); google.maps.event.addlistener(map, 'click', function(event) { path.push(event.latlng); }); google.maps.event.addlistener(map, 'mousemove', function(event) { if (path.getlength() > 1) path.setat(path.getlength()-1,event.latlng); });
i want follow mouse line, if user click on map, push polyline's array. click event doesn't work... idea?
i think there small bug in code:
on line 5 should read
path: path,
instead of
path: new google.maps.mvcarray([path]),
reason: var path mcvarray , property path of polylineoptions expects mvcarray, supply mvcarray inside normal array inside mvcarray.
this prevents code following pushing coordinates correct array.
Comments
Post a Comment