0

出于某种原因,每当我尝试为我的地图使用自定义标记图像时,它只会显示默认值。这是我的代码:

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Google Maps JavaScript API v3 Example: Marker Simple</title>
        <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false" type=
        "text/javascript"></script>
        <script type="text/javascript">        
            function initialize() {
                var mapOptions = {
                        zoom: 3,
                        center: new google.maps.LatLng(-25.363882,131.044922),
                        mapTypeId: google.maps.MapTypeId.ROADMAP
                    };
                map = new google.maps.Map(document.getElementById('map'), mapOptions);
                var marker = new google.maps.Marker({
                        position: new google.maps.LatLng(-25.363882,131.044922),
                        map: map,
                        title: 5,
                        icon: new google.maps.MarkerImage('http://www.gettyicons.com/free-icons/108/gis-gps/png/24/needle_left_yellow_2_24.png',
                                new google.maps.Size(24, 24),
                                new google.maps.Point(0,0),
                                new google.maps.Point(0, 24))
                    });
            }
        </script>
    </head>
    <body onload="initialize()">
        <div id="map" style="width: 780px; height: 480px"></div>
    </body>
</html>
4

1 回答 1

2

问题出在您的标题选项中,它必须是一个字符串。所以替换它"5",它会工作!

见演示:http: //jsbin.com/uwudab/1/edit

于 2013-01-02T15:54:07.853 回答