如何删除标记InfoWindow中的“x”关闭按钮?

时间:2016-06-18 14:52:52

标签: javascript jquery html google-maps-api-3 google-maps-markers

如何删除标记InfoWindow中的“X”按钮?

[             “Amerrica the Mermaid(nee:Aubry Alexis)”,             36.8618,-76.203,             5,             “Myke Irving / Georgia Mason”,             “USAVE汽车租赁”,             “Virginia Beach Blvd上的弗吉尼亚汽车租赁”,             “资产/图像/ 1.JPG”             “发现”         ]     ]

var map = new google.maps.Map(document.getElementById('map'), {
    zoom: 12,
    // center: new google.maps.LatLng(-33.92, 151.25),
    center: new google.maps.LatLng(36.8857, -76.2599),
    mapTypeId: google.maps.MapTypeId.ROADMAP
});

var infowindow = new google.maps.InfoWindow();
var marker, i;

for (i = 0; i < locations.length; i++) {
    marker = new google.maps.Marker({
        position: new google.maps.LatLng(locations[i][1], locations[i][2]),
        map: map
    });
    google.maps.event.addListener(marker, 'mouseover', (function(marker, i) {
        return function() {
            infowindow.setContent(locations[i][0]);
            infowindow.open(map, marker, this);
            marker.addListener('click', function() {
                map.setCenter(marker.getPosition());
                document.getElementById("map").style.width = "50%";
                google.maps.event.trigger(map, 'resize')
                map.setCenter(marker.getPosition());
                document.getElementById("data").style.display = "inline";
                document.getElementById("data").innerHTML = locations[i][0] + "<br />" + locations[i][4] + "<br />" + locations[i][5] + "<br />" + locations[i][6] + "<br />" + '<div class="row"><div class="col-md-4"><img class="img-responsive" src="' + locations[i][7] + '" /></div></div>';
                document.getElementById("button").style.display = "block";
            });
        }
    })(marker, i, infowindow));
    google.maps.event.addListener(marker, 'mouseout', function() {
        infowindow.close();
    });
}

1 个答案:

答案 0 :(得分:2)

这是一个可以完成工作的CSS黑客攻击,但如果URL在将来发生变化可能不会那么好......

    <style>
img[src="http://maps.gstatic.com/mapfiles/api-3/images/mapcnt3.png"] {
    display: none;
}
</style>

尝试检查页面以获取正确的图像资源......因为它可能......

https://maps.gstatic.com/mapfiles/api-3/images/mapcnt6.png

而不是我引用的那个。