如何在谷歌地图上更改标记/图钉颜色

时间:2014-02-13 13:45:24

标签: javascript jquery google-maps google-visualization

我想在谷歌地图上更改标记/针脚的颜色,这就是我的做法。我无法使用自定义图像/颜色显示任何标记。

<script>
        google.load("visualization", "1", {packages:["map"]});
        google.setOnLoadCallback(drawMap);
        function drawMap(dataArray) {
            var pinColor = "FE7569";
            var pinImage = new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|" + pinColor,
            new google.maps.Size(21, 34),
            new google.maps.Point(0,0),
            new google.maps.Point(10, 34));
            var pinShadow = new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_pin_shadow",
            new google.maps.Size(40, 37),
            new google.maps.Point(0, 0),
            new google.maps.Point(12, 35));
            var data = google.visualization.arrayToDataTable(dataArray);
            var map = new google.visualization.Map(document.getElementById('map_div'));
            map.Marker({
                position: new google.maps.LatLng(0,0), 
                map: map,
                icon: pinImage,
                shadow: pinShadow
            });
            var options = {mapType: 'terrain',showTip: true,useMapTypeControl:true};

            map.draw(data,options);
        }
    </script>

1 个答案:

答案 0 :(得分:0)

iconFileErr ='http://maps.google.com/mapfiles/ms/icons/red-dot.png'; marker.setIcon(iconFileErr);