我尝试了很多方法,仍然无法将标记添加到谷歌地图。
要理解,请查看以下代码:
var marker;
var myCenter = new google.maps.LatLng(55.1231231,-1.123131);
function initialize()
{
var mapOption = {
center: myCenter,
zoom:15,
mapTypeId:google.maps.MapTypeId.ROADMAP,
panControl: true,
panControlOptions: {
position: google.maps.ControlPosition.RIGHT_TOP
},
};
var map = new google.maps.Map(document.getElementById("googleMap"),mapOption);
var customControlDiv = document.createElement('div');
customControlDiv.id="customControlDiv";
AddCustomControl(customControlDiv, map);
map.controls[google.maps.ControlPosition.TOP_CENTER].push(customControlDiv);
}
function placeMarker(location) {
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title:"You are Here!"
});
}
// to add the marker to the map
marker.setMap(map);
google.maps.event.addDomListener(window, 'load', initialize);
,HTML就在这里
<div id="googleMap"></div>
我没有忘记从谷歌apis打电话。它在这里
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script>
所以,我已按照谷歌地图Here的说明进行操作。但它仍然无效。任何的想法?感谢。
答案 0 :(得分:1)
的问题:
var marker;
var myCenter = new google.maps.LatLng(55.1231231,-1.123131);
function initialize()
{
var mapOption = {
center: myCenter,
zoom:15,
mapTypeId:google.maps.MapTypeId.ROADMAP,
panControl: true,
panControlOptions: {
position: google.maps.ControlPosition.RIGHT_TOP
},
};
var map = new google.maps.Map(document.getElementById("googleMap"),mapOption);
// to add the marker to the map
var marker = new google.maps.Marker({
position: myCenter,
map: map,
title:"You are Here!"
});
}
google.maps.event.addDomListener(window, 'load', initialize);