[英]How to create circle around maker when using Google maps MarkerCluster for api v3
I am using Google maps MarkerCluster for api v3 to create cluster marker. 我正在使用适用于API v3的Google Maps MarkerCluster创建集群标记。 It works well. 它运作良好。 But I want to use the circle around marker and can drag the radius of circle. 但是我想使用标记周围的圆圈,并且可以拖动圆圈的半径。
var markerClusterer = null;
var map = null;
var imageUrl = 'http://chart.apis.google.com/chart?cht=mm&chs=24x32&' +
'chco=FFFFFF,008CFF,000000&ext=.png';
function initialize() {
map = new google.maps.Map(document.getElementById('map_canvas'), {
zoom: 6,
center: new google.maps.LatLng(46.578498, 2.457275),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var markers = [];
var markerImage = new google.maps.MarkerImage(imageUrl, new google.maps.Size(24, 32));
for (var i = 0; i < macDoList.length; i++) {
var latLng = new google.maps.LatLng(macDoList[i].lat,
macDoList[i].lng);
var marker = new google.maps.Marker({
position: latLng,
icon: markerImage
});
markers.push(marker);
}
markerClusterer = new MarkerClusterer(map, markers, {
maxZoom: 16,
gridSize: 100,
styles: clusterStyles
});
}
function clearClusters(e) {
e.preventDefault();
e.stopPropagation();
markerClusterer.clearMarkers();
}
google.maps.event.addDomListener(window, 'load', initialize);
Anyone can help me to resolve this case? 有人可以帮助我解决此案吗?
I create circle successfully. 我成功创建了圈子。 I'd like to share my solution for everyone. 我想与大家分享我的解决方案。 Hope it's useful for another one. 希望对另一个有用。
function initialize() {
map = new google.maps.Map(document.getElementById('map_canvas'), {
zoom: 6,
center: new google.maps.LatLng(46.578498, 2.457275),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var markers = [];
var markerImage = new google.maps.MarkerImage(imageUrl, new google.maps.Size(24, 32));
for (var i = 0; i < macDoList.length; i++) {
var latLng = new google.maps.LatLng(macDoList[i].lat,
macDoList[i].lng);
var marker = new google.maps.Marker({
position: latLng,
icon: markerImage
});
google.maps.event.addListener(marker, 'click', function(a) {
var drawCircle = new google.maps.Circle({
center: new google.maps.LatLng(this.position.lat(), this.position.lng()),
editable:true,
radius: 50, // metres
fillColor: 'yellow'
});
drawCircle.setMap(map);
//circle.bindTo('center', marker, 'position');
});
markers.push(marker);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.