Multiple “InfoWindow” for array of “markers” on Google Maps?

久未见 提交于 2019-11-29 18:51:46
MrUpsidown
var infowindow = new google.maps.InfoWindow();

function set_markers(array) {

    var mapOptions = {
        zoom: 13
    };

    for (var i = 0; i < array.length; i++) {

        var single_location = array[i];
        var myLatLng = new google.maps.LatLng(single_location[1], single_location[2]);
        var marker = new google.maps.Marker({
            position: myLatLng,
            map: map,
            title: single_location[0]
        });

        google.maps.event.addListener(marker, 'click', function () {
            infowindow.setContent('<h3>' + this.title + '</h3>');
            infowindow.open(map, this);
        });
    }
}

This is untested since you didn't post a MCVE.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!