在我的项目中,我想在地图上显示位于 5 个不同购物中心内的 5 个比特币 atm 的位置。 我从谷歌地图浏览器得到了他们的纬度和经度,但是当我的地图在现场充电时,位置都不准确(比如距离他们的真实位置一两个街区)知道为什么吗?也许代码有问题?
var locations = [
["Produkti 24", 55.8075921, 37.5804],
["TZ Taganka", 55.7407673, 37.6554212, 17],
["TZ Olympic Plaza", 55.780422, 37.6310605, 18],
["TZ Nautilyus", 55.7591667, 37.6225335, 17],
["TZ Korabl", 55.7101906, 37.6181143, 17],
];
function initMap() {
var myLatLng = { lat: 55.7637079, lng: 37.6236902 };
var map = new google.maps.Map(document.getElementById("map"), {
zoom: 12,
center: myLatLng,
});
var count;
for (count = 0; count < locations.length; count++) {
new google.maps.Marker({
position: new google.maps.LatLng(
locations[count][1],
locations[count][2]
),
map: map,
title: locations[count][0],
});
}
}
#map {
height: 500px;
width: 80%;
margin: 8rem auto 8rem auto;
}
.map-box {
display: flex;
flex-direction: column;
align-items: center;
}
.map-title {
font-size: 3rem;
margin-top: 3.2rem;
}
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<section class="map-box">
<h2 class="map-title">Where we are</h2>
<div id="map">
</div>
</section>
<script async src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBMjHKMIiZiqHCrcIOe-iH9MtiZ-FpdefA&callback=initMap"></script>
</body>
</html>