简体   繁体   中英

MarkClusterer map issue: find nearest latitude/longitude

I am using Markclusterer extension with Google Map API v3 and i ran into certain trouble, The map shows perfectly and also the cluster works but my problem is that certain address share the same Longitude and latitude hence groups the address and show the number of address as a group but i cannot zoom any further into the group. I have tried to increase the zoom but that did not help. Any ideals or solution would be appreciated thanks.

     var map;
     var markers = new Array();
     var locations = new Array();
     var infowindow = new google.maps.InfoWindow();
     function initialize() {
        var center = new google.maps.LatLng(<%= GetCenterLatLng() %>);
        // var center = new google.maps.LatLng(52.6500, 1.2800); 
        var infowindow = new google.maps.InfoWindow();

         map = new google.maps.Map(document.getElementById('map'), {
             zoom: 13,
             center: center,
             mapTypeId: google.maps.MapTypeId.ROADMAP
         });

         initialiseMarkers();
         var mcOptions = { gridSize: 50, maxZoom: 15 };
         var markerCluster = new MarkerClusterer(map, markers, mcOptions);

     }


     function addMarker(marker, content) {
         google.maps.event.addListener(marker, 'click', function () {
             infowindow.setContent(content); // this is the trick: html attribute on markerOptions :), I used a array here
             infowindow.open(map, this);
         });
     }

<script type="text/javascript">
    var script = '<script type="text/javascript" src="../Scripts/markerclusterer';
    if (document.location.search.indexOf('compiled') !== -1) {
        script += '_compiled';
    }
    script += '.js"><' + '/script>';
    document.write(script);
</script>

if you have any question please contact me thanks

After days of cranking my brain and maybe some sleepless night. The solution was to group address that contain the same longitude and latitude as one marker and on click it shows all the address within the same vicinity on the popup window(infoWindow)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM