我发现这个很棒的教程效果很好。http://lab.abhinayrathore.com/ipmapper/
下面是从IP地址返回lat&lon值的javascript代码:http://pastebin.com/1gE91nuh
所以在同一个地方有很多标记,我想把它们分组成这样:http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.9/examples/simple_example.html
的例子:http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.9/docs/examples.html
但是有人能告诉我如何在原始代码中创建组吗?(原代码:http://pastebin.com/1gE91nuh)
谢谢!
这是创建标记集群的代码。当创建标记时,它们被压入数组。该数组被传递给一个新的MarkerClusterer对象。
function initialize() {
var center = new google.maps.LatLng(37.4419, -122.1419);
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 3,
center: center,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var markers = [];
for (var i = 0; i < 100; i++) {
var dataPhoto = data.photos[i];
var latLng = new google.maps.LatLng(dataPhoto.latitude,
dataPhoto.longitude);
var marker = new google.maps.Marker({
position: latLng
});
markers.push(marker);
}
var markerCluster = new MarkerClusterer(map, markers);
}
google.maps.event.addDomListener(window, 'load', initialize);