我想用自定义图像更改谷歌地图聚类。但是,它不会改变我提供的任何东西。这个 initMap 函数是
https://developers.google.com/maps/documentation/javascript/marker-clustering
我试图用谷歌的一些随机图像来改变集群图像。但是,它不渲染任何东西。
集群不支持自定义集群镜像??
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 3,
center: {lat: -28.024, lng: 140.887}
});
// Create an array of alphabetical characters used to label the markers.
var labels = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
// Add some markers to the map.
// Note: The code uses the JavaScript Array.prototype.map() method to
// create an array of markers based on a given "locations" array.
// The map() method here has nothing to do with the Google Maps API.
var markers = locations.map(function(location, i) {
return new google.maps.Marker({
position: location,
label: labels[i % labels.length]
});
});
// Add a marker clusterer to manage the markers.
var markerCluster = new MarkerClusterer(map, markers,
{imagePath: 'http://www.empowervate.org/wp-content/uploads/2015/11/circle.jpg'});
}
感谢您的帮助@henrisycip
我可以通过提供样式选项来更改集群图像,如下所示。我不确定为什么 imagePath 不做任何事情..
styles={[
{
url: "/static/images/cluster/m1.png",
height: 53,
width: 53
},
{
url: "/static/images/cluster/m2.png",
height: 53,
width: 53
},
{
url: "/static/images/cluster/m3.png",
height: 53,
width: 53
},
{
url: "/static/images/cluster/m4.png",
height: 53,
width: 53
},
{
url: "/static/images/cluster/m5.png",
height: 53,
width: 53
}
]}