gpt4 book ai didi

node.js - 为什么 Google map 标记和信息窗口不居中?

转载 作者:太空宇宙 更新时间:2023-11-04 01:14:54 24 4
gpt4 key购买 nike

我用这段代码制作了一张 map

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);
});
}

当我尝试单击标记时,它们会被取消校准,因此当我单击标记的中心时什么也不会发生。但向下几厘米处,会出现一个光标,就像标记位于该点一样。

所以 map 没有居中,标记出现在真实坐标处,但我必须单击距标记向下 2 厘米的位置才能单击标记...

这是为什么?有其他人遇到过这种情况吗?

最佳答案

问题是主体......我把它放在我的CSS中

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

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

抱歉我的英语不好!埃杰杰杰

关于node.js - 为什么 Google map 标记和信息窗口不居中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11301077/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com