How to set infowindow for all markers in google map using JavaScript? -
i created stop point markers truck stopped.but need open infowindow when clicked stop point.
my js codes :
var imagestop = '/images/stoppoint.gif'; var infowindowtrcukstop = new google.maps.infowindow(); var json = result.d; obj = json.parse(json); (var = 0; < obj.length - 1; i++) { if(parseint(obj[i].speed)==0) { var latlngstop = new google.maps.latlng(obj[i].lat, obj[i].lng); markerstoptruck = new google.maps.marker({ position: latlngstop, draggable: true, animation: google.maps.animation.drop, map: map, title: 'stopped here', icon: imagestop, }); google.maps.event.addlistener(markerstoptruck, 'click', function (e) { infowindowtruckstop.setcontent(this.title); infowindowtruckstop.open(map, markerstoptruck); }); markerstoptruck.setmap(map); } }
i solved.
(var = 0; < obj.length - 1; i++) { if(parseint(obj[i].hiz)==0) { var latlngstop = new google.maps.latlng(obj[i].lat, obj[i].lng); markerstoptruck= new google.maps.marker({ position: latlngstop, draggable: true, animation: google.maps.animation.drop, map: map, title: '', icon: imagestop, }); var content = 'stop here'; google.maps.event.addlistener(markerstoptruck, 'click', (function (markerstoptruck, content, infowindowtruckstop) { return function () { infowindowtruckstop.setcontent(content); infowindowtruckstop.open(map, markerstoptruck); }; })(markerstoptruck, content, infowindowtruckstop)); markerstoptruck.setmap(map); } }
Comments
Post a Comment