我想添加一個標記到我的自定義谷歌地圖API v3。地圖顯示正常,但我似乎無法添加標記。這似乎是一件基本的事情,但我一直陷入困境。我試過按照https://developers.google.com/maps/documentation/javascript/overlays#AddingOverlays將基本標記添加到谷歌地圖api v3
的說明。但是,我對JavaScript和API的知識總的來說是相當有限的,所以我覺得在這裏必須缺少一些基本的東西。 Google說明基本上可能不包含它。缺少冒號,括號。也許變量的順序是錯誤的?任何輸入非常感謝!這裏的代碼如下:
<script type="text/javascript">
function initialize() {
var myLatlng = new google.maps.LatLng(51.60505, -0.18989);
var mapOptions = {
center: myLatlng,
zoom: 18,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
//the code for the marker, as copy pasted from google
var marker = new google.maps.Marker({
position: myLatlng,
title:"Hello World!"
});
var styles = [
{featureType: "landscape",
stylers: [
{ color: "#378fb5" }
]
},{
ETC
ETC
ETC
}
];
map.setOptions({styles: styles});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
我的日子很好地改進了!謝謝Alexis! – bestfriendsforever