2016-03-22 13 views
0

Frage zum spiderfier Cluster schaffte ich es mit markerClusterer machen zu arbeiten, aber ist es eine Möglichkeit, Auto spiderfied es, wenn Sie Zoomin so wird es nicht nur 1 Marker zeigen, wenn Karte gezoomt wird?google map spiderfier Cluster

Sagen Sie, wenn Sie maxZoom Niveau von 11 drücken Sie dann soll es automatisch den Marker spiderfied.

Hier ist meine spiderfier Optionen:

var oms = new OverlappingMarkerSpiderfier(map, {keepSpiderfied : true, markersWontMove : false, circleSpiralSwitchover: 5}); 

Danke,

Antwort

0

(function() {

var gm = google.maps; 

var config = { 
    el: 'map', 
    lat: 37.4419, 
    lon: -122.1419, 
    zoom: 15, 
    minZoom: 15, 
    type: google.maps.MapTypeId.ROADMAP 
}; 

var spiderConfig = { 
    keepSpiderfied: true, 
    event: 'mouseover' 
}; 

// A list of Markers with the same location 
var data = [ 
    {lat: 37.4419, lon: -122.1419, title: 'location 1'}, 
    {lat: 37.4419, lon: -122.1419, title: 'location 2'}, 
    {lat: 37.4419, lon: -122.1419, title: 'Marker same location 3'}, 
    {lat: 37.4419, lon: -122.1419, title: 'Marker same location 4'}, 
    {lat: 37.4419, lon: -122.1419, title: 'Marker same location 5'}, 
    {lat: 37.4419, lon: -122.1419, title: 'Marker same location 6'}, 
    {lat: 37.4419, lon: -122.1419, title: 'Marker same location 7'}, 
    {lat: 37.4419, lon: -122.1419, title: 'Marker same location 8'}, 
    {lat: 37.4419, lon: -122.1419, title: 'Marker same location 9'} 
]; 


function initialize() { 

    var map = new gm.Map(document.getElementById(config.el), { 
     zoom: config.zoom, 
     center: new gm.LatLng(config.lat, config.lon), 
     mapTypeId: config.type 
    }); 


    var markerSpiderfier = new OverlappingMarkerSpiderfier(map, spiderConfig); 

    var markers = []; 


    for (var x in data) { 

     var loc = new gm.LatLng(data[x].lat, data[x].lon); 

     var marker = new gm.Marker({ 
      position: loc, 
      title: data[x].title, 
      map: map 
     }); 

     marker.desc = data[x].title; 

     markers.push(marker); // Saving Markers 

     markerSpiderfier.addMarker(marker); // Adds the Marker to OverlappingMarkerSpiderfier 
    } 


    var iw = new gm.InfoWindow(); 

    markerSpiderfier.addListener('click', function(marker, e) { 
     iw.setContent(marker.title); 
     iw.open(map, marker); 
    }); 

    markerSpiderfier.addListener('spiderfy', function(markers) { 
     iw.close(); 
    }); 


    var markerCluster = new MarkerClusterer(map, markers); 

    markerCluster.setMaxZoom(config.minZoom); 

} 

gm.event.addDomListener(window, 'load', initialize); 

})();