Trying to bind multiple InfoWindows to multiple Markers on a Google Map and failing

前端 未结 3 425
暗喜
暗喜 2020-12-03 00:14

My project uses a JSON feed to grab info about earthquakes within a specified latitude and longitude boundary, essentially making a box. I take this info and turn all the r

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-03 00:39

    YOu can also do this:

    // so marker is associated with the closure created for the listenMarker function call
    google.maps.event.addListener(marker, 'click', function() {
                        tooltip.open(map, this);
                    });
    

    Where "marker" is replace with "this" in the add listener call. Thus you can place the addListerner code at the same point you create the marker, and not have to create a new function.

    http://you.arenot.me/2010/06/29/google-maps-api-v3-0-multiple-markers-multiple-infowindows/

    Check out the full solution and a demo :D

提交回复
热议问题