1

我用这段代码制作地图

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 厘米才能单击标记...

这是为什么??有没有其他人发生过这种情况??

4

1 回答 1

1

问题是身体......在我的CSS中我放了

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

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

对不起我的英语不好!埃杰杰

于 2012-07-03T06:04:14.357 回答