为什么Google Maps Marker和InfoWindow不居中?

时间:2012-07-02 20:57:50

标签: node.js google-maps-api-3 express pug

我使用此代码制作地图

var map;
var myOptions = {
    center: new google.maps.LatLng(-31.403759,-64.174232),
    zoom: 12,
    panControl: true,
    zoomControl: true,
    mapTypeControl: true,
    scaleControl: true,
    streetViewControl: true,
    overviewMapControl: true,
    mapTypeId: google.maps.MapTypeId.ROADMAP 
};

function iniciar() {
    map = new google.maps.Map(document.getElementById("map"),myOptions);
}

function marcar(lat, lng) {
    var contentString = '<div id="content">'+
        '<div id="siteNotice">'+
        '</div>'+
        '<h1 id="firstHeading" class="firstHeading">Uluru</h1>'+
        '<div id="bodyContent">'+
        '<p><b>Uluru</b>, also referred to as <b>Ayers Rock</b>, is a large ' +
        'sandstone rock formation in the southern part of the '+
        'Northern Territory, central Australia. It lies 335 km (208 mi) '+
        'south west of the nearest large town, Alice Springs; 450 km '+
        '(280 mi) by road. Kata Tjuta and Uluru are the two major '+
        'features of the Uluru - Kata Tjuta National Park. Uluru is '+
        'sacred to the Pitjantjatjara and Yankunytjatjara, the '+
        'Aboriginal people of the area. It has many springs, waterholes, '+
        'rock caves and ancient paintings. Uluru is listed as a World '+
        'Heritage Site.</p>'+
        '<p>Attribution: Uluru, <a href="http://en.wikipedia.org/w/index.php?title=Uluru&oldid=297882194">'+
        'http://en.wikipedia.org/w/index.php?title=Uluru</a> (last visited June 22, 2009).</p>'+
        '</div>'+
        '</div>';
    var infowindow = new google.maps.InfoWindow({
        content: contentString
    });
    var location=new google.maps.LatLng(lat,lng);
    var marker = new google.maps.Marker({
        position: location, 
        map: maps
    });
    google.maps.event.addListener(marker, 'click', function() {
        infowindow.open(map,marker);
    });
}

当我尝试点击标记时,它们会被重新校准,以便当我点击标记的中心时没有任何反应。但是在几厘米的距离下,光标会出现,就像标记就在那一点。

因此地图不居中,标记出现在真实坐标处,但我必须向标记点击2厘米才能点击标记......

为什么?还有其他人发生过这种情况吗?

1 个答案:

答案 0 :(得分:1)

问题是身体...在我的css中我把

body{
zoom:0.9;
margin:0;
padding:0;
width:100%;
}

缩放影响谷歌地图删除缩放校准标记....谢谢大家!我希望这个问题可以解决任何其他类似的问题

并为我糟糕的英语而烦恼! ejejej