<html>
<head>
<script src="http://maps.googleapis.com/maps/api/js?key=MYKEY&sensor=false"></script>
<script>
var myCenter = new google.maps.LatLng(parseFloat(my_lat_echoed_from_php), parseFloat(my_lng_echoed_from_php));
function initialize() {
var mapOptions = {
center:myCenter,
zoom:6,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("googleMap"),mapOptions);
var marker = new google.maps.Marker({
position: myCenter,
map: map,
title: 'Hello World!'
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="googleMap" style=" width:50%; height:500px; border:3px solid black; margin: 0 auto;"></div>
</body>
</html>
它从我的数据库中正确获取纬度和经度并将其集中在正确的位置,但没有显示标记。我包括locations_show.php
这个 HTML 页面。除标记外,一切正常。