English 中文(简体)
• 如何在 go角地图上添加标记组群,用于同一排段/整个段,而不影响另一个元素?
原标题:how to add marker cluster in google maps v3 for the same lat/long without influenting another element?

I made traceroute map. And I have problem with some markers that should be in the same lat/long but only one marker show on the map. I read that there s a way to do. It is marker cluster. but I don t know how to add in javascript. Also I m afraid if that would be influent another element of markers which I ve add like custom marker with label, infowindow and polyline. here is my code :

<script type="text/javascript">
    var pinImage = new google.maps.MarkerImage ("http://chart.apis.google.com/chart?chst=d_map_xpin_letter_withshadow&chld=pin_star|%E2%80%A2|CC3300|000000|FF9900",
        new google.maps.Size (70, 83),
        new google.maps.Point (0,0),
        new google.maps.Point (10,34));
    var pinShadow = new google.maps.MarkerImage ("http://chart.apis.google.com/chart?chst=d_map_pin_shadow",
        new google.maps.Size (89, 85),
        new google.maps.Point (0, 0),
        new google.maps.Point (12, 35));

    function initialize() {
    var myLatlng = new google.maps.LatLng(38.822591, 150.46875);
    var myOptions = {
    zoom: 2,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    }
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    <?php
    $posisi = array();
    $keterangan = array();
    foreach ($integer as $lokasi) {
    $query = "SELECT cl.locId, cl.country as country, cl.region as region, cl.city as city, cl.postalCode as postalCode, cl.latitude as latitude, cl.longitude as longitude, cl.metroCode as metroCode, cl.areaCode as areaCode
    FROM (SELECT locId as idcihuy FROM cityblocks WHERE $lokasi BETWEEN startIpNum AND endIpNum) cb, citylocation cl WHERE cb.idcihuy = cl.locId";
    $result = mysql_query($query);
    while ($location = @mysql_fetch_assoc($result)){
    $posisi[]=  new google.maps.LatLng(  . $location[ latitude ] .  ,   . $location[ longitude ] .  ) ;
    $keterangan[]=  "(  . $location[ country ] .  ,    . $location[ region ] .  ,    . $location[ city ] .  )" ;
    }
    }
    ?>
     var infoWindow = new google.maps.InfoWindow({});
     var point = [<?php echo implode( , , $posisi) ?>];
     var lokasi = [<?php echo implode( , , $keterangan) ?>];
     var icon = pinImage;
     for (var i = 0; i < point.length; i++) {
     var html = "<b>" + lokasi[i] + "</b> <br/>" + point[i];
     var marker = new MarkerWithLabel({
        map: map,
        position: point[i],
        icon: pinImage,
        shadow: pinShadow,
        labelContent: i,
        labelAnchor: new google.maps.Point(12, -5),
        labelClass: "labels"
        });
        bindInfoWindow(marker, map, infoWindow, html);
    var jalur = new google.maps.Polyline({
    path: point,
    strokeColor: "#000000",
    strokeOpacity: 0.8,
    strokeWeight: 2.25
    });
    jalur.setMap(map);
        }
        }
    function bindInfoWindow(marker, map, infoWindow, html) {
      google.maps.event.addListener(marker,  click , function() {
        infoWindow.setContent(html);
        infoWindow.open(map, marker);
      });
    }
    </script>

Also I give you the sample of positions which have the same lat/long :

[
 new google.maps.LatLng(1.3667, 103.8000),
 new google.maps.LatLng(1.3667, 103.8000), 
 new google.maps.LatLng(1.3667, 103.8000),
 new google.maps.LatLng(1.3667, 103.8000),
 new google.maps.LatLng(51.0000, 9.0000),
 new google.maps.LatLng(51.0000, 9.0000),
 new google.maps.LatLng(51.5142, -0.0931),
 new google.maps.LatLng(51.5142, -0.0931),
 new google.maps.LatLng(54.0000, -2.0000),
 new google.maps.LatLng(51.6000, -1.2500),
 new google.maps.LatLng(51.7500, -1.2500)
];

我需要帮助使标识组成为同一排/长的标记组群,但这不会影响另一个特征,如贴标签、印花和多线的标识。 请帮助。 谢谢。

问题回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签