谷歌地图标记显示在IE中,但不显示在chrome或firefox中

google map markers displays in IE but not in chrome or firefox

本文关键字:显示 chrome firefox IE 地图 图标 谷歌      更新时间:2023-09-26

我有一个谷歌地图,它从文档中提取地址值并绘制它们。它在IE中运行良好,即地图显示良好,标记显示良好。然而,在Chrome和Firefox中,只有地图显示,但没有标记。。我不明白。信息窗口也不起作用,因为标记没有显示。不过我没有在这里包含infowindow代码!

var geocoder;
var map;
function initializeMap() {
    geocoder = new google.maps.Geocoder();
    var latlng = new google.maps.LatLng(39.88445,-86.11084);
    var myOptions = {
      zoom: 9,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);
}
function codeAddress() {
    var infowindow = new google.maps.InfoWindow({}); 
    $('span.LocationAddress').each(function(index) {
        var addy = $(this).text();          
        geocoder.geocode( { 'address': addy}, function(results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                    map.setCenter(results[0].geometry.location);
                    var marker = new google.maps.Marker({
                    map: map, 
                    position: results[0].geometry.location,
                    title:addy          
                });     
            } 
        });
    });
}

如果你在firefox中添加firebug插件,安装后按12,如果有任何代码问题,它会显示一个错误。此外,添加:

if (status == google.maps.GeocoderStatus.OK) {
                map.setCenter(results[0].geometry.location);
                var marker = new google.maps.Marker({
                map: map, 
                position: results[0].geometry.location,
                title:addy          
            });     
        } else{ console.log(google.maps.GeocoderStatus);}

这应该显示返回的状态。