我想将三个点放在 lat long 的 google地图中,但我希望每个点都有不同的颜色。
这是我的代码,此代码目前为所有点设置一种颜色
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 11,
center: {lat: 39.585938, lng: 47.909219}
});
heatmap = new google.maps.visualization.HeatmapLayer({
data: getPoints(),
map: map
});
var gradient = [
'rgba(255, 0, 0, 0)',
'rgba(255, 0, 0, 1)'
]
heatmap.set('gradient', gradient);
}
function getPoints() {
return [
new google.maps.LatLng(39.585938, 47.909219,20),
new google.maps.LatLng(39.585938, 47.909220,20),
new google.maps.LatLng(39.585938, 47.909221,20),
new google.maps.LatLng(39.585938, 47.909222,20),
];
}
答案 0 :(得分:0)
您可以使用strokeColor
属性定义自定义标记:
示例:
strokeColor: "red",
参考:https://developers.google.com/maps/documentation/javascript/markers
var marker = new google.maps.Marker({
id: "some-id",
icon: {
path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW,
strokeColor: "red",
scale: 3
},
map: map,
title: "Any-title",
position: myLatlng
});
参考文献: https://developers.google.com/maps/documentation/javascript/symbols