Google Maps API v3 adding multiple markers w/ info windows w/ custom text

后端 未结 3 937
既然无缘
既然无缘 2020-12-20 21:25

I am making a website over cyclists killed in Norway. For my project I have been using google maps api v3, but I have vague familiarity with javascript. You can see my resul

3条回答
  •  感情败类
    2020-12-20 21:49

    You need to attach the infowindow to the correct markers. Currently they are all associated with "marker", which doesn't exist (and should cause an error message in the javascript console when you click on the markers).

    Inside the click listener change:

    infowindow1.open(map, marker);
    
    infowindow2.open(map, marker);
    
    infowindow3.open(map, marker);
    

    To:

    infowindow1.open(map, marker1);
    
    infowindow2.open(map, marker2);
    
    infowindow3.open(map, marker3);
    

    working example

提交回复
热议问题