2
<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 页面。除标记外,一切正常。

4

1 回答 1

4

我按照这个答案的建议添加optimized: false到我的标记选项中。

改变了这个:

 var marker = new google.maps.Marker({
    position: myCenter,
    map: map,
    title: 'Hello World!'
});

var marker = new google.maps.Marker({
    position: myCenter,
    map: map,
    optimized: false,
    title: 'Hello World!'
});
于 2013-08-06T21:53:17.090 回答