我正在尝试在我们的地方建立一个谷歌地图。要获得Lat和Long位置,我右键点击标准Google地图,选择"这里有什么?" (蓝色X)并使用给定的坐标。但是,当我打开地图时,我创建的标记位于其他位置(粉红色方块)。这是我正在使用的代码;
<script>
function initMap() {
var map;
var iconBase = 'icons/';
// Display a map on the web page
map = new google.maps.Map(document.getElementById('mapCanvas'), {
zoom: 16,
center: {lat: 51.4571407, lng: -0.1940732 },
styles: [
{
featureType: 'poi.business',
stylers: [{visibility: 'off'}]
},
]
});
// Multiple markers location, latitude, and longitude
var markers = [
['Wandsworth Town Library', 51.4562217,-0.1932119,'library.png'],,
];
// Info window content
var infoWindowContent = [
['<div class="info_content">' +
'<h3>Wandsworth Town Library</h3>' +
'<p>Free blue badge holder parking during the day and first come first service parking after 4:30pm</p>' + '</div>'],
];
// Add multiple markers to map
var infoWindow = new google.maps.InfoWindow(), marker, i;
// Place each marker on the map
for( i = 0; i < markers.length; i++ ) {
var position = new google.maps.LatLng(markers[i][1], markers[i][2]);
marker = new google.maps.Marker({
position: position,
map: map,
title: markers[i][0],
});
// Add info window to marker
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infoWindow.setContent(infoWindowContent[i][0]);
infoWindow.open(map, marker);
}
})(marker, i));
}
}
// Load initialize function
google.maps.event.addDomListener(window, 'load', initMap);
</script>
如何将标记放在正确的位置,即蓝色X?
答案 0 :(得分:0)
您需要一直放大,然后右键点击“这里有什么?”并使用那些坐标。