我想在谷歌地图上添加一个标记,我有这个代码
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=myKey&sensor=true">
</script>
<script type="text/javascript">
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(56.33481154165235, 11.107177734375),
zoom: 7,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
setMarker();
}
// Function for adding a marker to the page.
function addMarker(location) {
marker = new google.maps.Marker({
position: location,
map: map
});
}
// Testing the addMarker function
function setMarker() {
CentralPark = new google.maps.LatLng(55.671389288295465, 12.5601196289062);
addMarker(CentralPark);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
这显示了地图,但不显示标记。
在此先感谢您的帮助!