我正在努力理解这一点。
我的代码在下面,还有一个指向显示地图的测试页面的链接 标记在错误的地方。
我已将纬度和液化天然气与 https://www.google.co.uk/maps/place/Dakota+Hotel+Eurocentral/@55.8353173,-3.9854019,17z/data=!3m1!4b1!4m5!3m4!1s0x4888441f8bb5be07:0x6444cfc231481afe!8m2!3d55.8353173!4d-3.9832132
从链接中可以看出,它们是 55.8353173 和 -3.9854019
但是,当我将它们包含在下面的代码中时 - 标记出现在错误的位置。 见 http://craigfagan.com/queenslie/testmap.html
我的代码如下。
对此有任何帮助将不胜感激 - 挠头想知道我做错了什么?
提前感谢您的任何建议..
<div id="map"></div>
<script type="text/javascript">
function initMap() {
var mapOptions = {
zoom: 17,
scrollwheel: false,
center: new google.maps.LatLng(55.8353173,-3.9854019),
styles:
[{"featureType":"water","elementType":"geometry.fill","stylers":
[{"color":"#d3d3d3"}]},{"featureType":"transit","stylers":
[{"color":"#808080"},{"visibility":"off"}]},
{"featureType":"road.highway","elementType":"geometry.stroke",
"stylers":
[{"visibility":"on"},{"color":"#b3b3b3"}]},
{"featureType":"road.highway","elementType":"geometry.fill","stylers":
[{"color":"#ffffff"}]},
{"featureType":"road.local","elementType":"geometry.fill","stylers":
[{"visibility":"on"},{"color":"#ffffff"},{"weight":1.8}]},
{"featureType":"road.local","elementType":"geometry.stroke","stylers":
[{"color":"#d7d7d7"}]},
{"featureType":"poi","elementType":"geometry.fill","stylers":
[{"visibility":"on"},{"color":"#ebebeb"}]},
{"featureType":"administrative","elementType":"geometry","stylers":
[{"color":"#a7a7a7"}]},
{"featureType":"road.arterial","elementType":"geometry.fill","stylers":
[{"color":"#ffffff"}]},
{"featureType":"road.arterial","elementType":"geometry.fill","stylers":
[{"color":"#ffffff"}]},
{"featureType":"landscape","elementType":"geometry.fill","stylers":
[{"visibility":"on"},{"color":"#efefef"}]},
{"featureType":"road","elementType":"labels.text.fill","stylers":
[{"color":"#696969"}]},
{"featureType":"administrative","elementType":"labels.text.fill",
"stylers":
[{"visibility":"on"},{"color":"#737373"}]},
{"featureType":"poi","elementType":"labels.icon","stylers":
[{"visibility":"off"}]},
{"featureType":"poi","elementType":"labels","stylers":
[{"visibility":"off"}]},
{"featureType":"road.arterial","elementType":"geometry.stroke",
"stylers":
[{"color":"#d6d6d6"}]},
{"featureType":"road","elementType":"labels.icon","stylers":
[{"visibility":"off"}]},{},
{"featureType":"poi","elementType":"geometry.fill","stylers":
[{"color":"#dadada"}]}]
};
var mapElement = document.getElementById('map');
var map = new google.maps.Map(mapElement, mapOptions);
var marker = new google.maps.Marker({
position: new google.maps.LatLng(55.8353173,-3.9854019),
map: map,
title: 'Dakota'
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?
key=AIzaSyDJRdPso7qlkubRB66DafdHiBClCZoGGsI&callback=initMap" async
defer></script>
@ 符号后面的链接中的坐标是地图的中心,而不是标记。
要在Google地图中获取地图的中心,请右键单击该地点的图标,单击"这里是什么",它将为您提供坐标(该示例为55.835326,-3.983235(。
如果我使用 Places API(用于"Dakota Hotel Eurocentral"(,我会得到 (55.8353173,-3.983213200000023(,这更好。