maps - 标记未显示在正确位置
问题描述
我只是想在地图上显示多个标记。它可以工作,但标记不在正确的位置。为了在正确的位置显示标记,我必须指定什么。下面是我的代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
padding:0px;
margin:0px;
}
#map {
display: table;
width: 100%;
height: 600px;
}
</style>
<script src="https://maps.google.com/maps/api/js"></script>
</head>
<body>
<div id="map"></div>
<script>
var locations = [
['Elite Tuning', 53.214032, -2.551536, 3],
['North Wales Carbon', 53.294184, -3.579918, 2],
['os-Carz', 52.6629864, 1.1101281, 1]
];
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 8,
center: new google.maps.LatLng(52.7646718, -1.2562978),
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, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
}
</script>
</body>
</html>
任何帮助表示赞赏。:)
提前致谢。
解决方案
推荐阅读
- android - 如何列出 Xamarin.Android 上所有打开的活动?
- javascript - Chart.js 使用数据库数组和数据结构
- javascript - 如何在按键时停止计时器?
- mongodb - 在 MongoDB 中删除有条件的项目?
- html - VS2019 WinForm 应用,带浏览器控件
- android - 如何在 Flutter 项目中使用 Android 谷歌地图
- excel - 如何为 SUMIFS 函数创建“ALL”变量
- html - Div 不在 Div 内部居中
- php - MediaWiki 1.36 内部错误:需要 intl
- html - 为什么我与引导代码一起链接的自定义 css 文件没有改变页面外观或不起作用?