2012-03-22 14 views
1

Google Map APIを使用してマーカー上の地図を表示していますが、問題は地図上にある人のプロフィールページに移動するためのリンクを表示していますが、 1人以上の人が同じアドレスに存在している場合は、それらのアドレスをGoogleグループにグループ化してリンクを表示しないでください。 あなたは、単一のpointのための複数のマーカーを置く場合はすべてのヘルプはappreciated.ThanksGoogleマップのグループアドレスを一緒にしないようにするにはどうすればいいですか?

<pre> 
<script type="text/javascript"> 
var global =0; 
//<![CDATA[ 
if (GBrowserIsCompatible()) { 
    var side_bar_html = ""; 
    var gmarkers = []; 
    var htmls = []; 
    var i = 0; 

    var allIcon = new GIcon(); 
    allIcon.image = "images/icons/<?php echo $map_category; ?>-all.png"; 
    allIcon.shadow = "http://www.google.com/mapfiles/shadow50.png"; 
    allIcon.iconSize = new GSize(35, 29); 
    allIcon.shadowSize = new GSize(37, 34); 
    allIcon.iconAnchor = new GPoint(9, 34); 
    allIcon.infoWindowAnchor = new GPoint(9, 2); 
    allIcon.infoShadowAnchor = new GPoint(18, 25); 
    allIcon.transparent = "http://www.google.com/intl/en_ALL/mapfiles/markerTransparent.png"; 
    allIcon.printImage = "coldmarkerie.gif"; 
    allIcon.mozPrintImage = "coldmarkerff.gif"; 

    // An array of GIcons, to make the selection easier 
    var icons = []; 
    icons[0] = allIcon; 
    icons[1] = planIcon; 
    icons[2] = specialIcon; 

    var clusterIcon = new GIcon(); 
    clusterIcon.image = 'images/icons/<?php echo $map_category; ?>-all.png'; 
    clusterIcon.iconSize = new GSize(30, 51); 
    clusterIcon.shadowSize = new GSize(56, 51); 
    clusterIcon.iconAnchor = new GPoint(13, 34); 
    clusterIcon.infoWindowAnchor = new GPoint(13, 3); 
    clusterIcon.infoShadowAnchor = new GPoint(27, 37); 


    // A function to create the marker and set up the event window 
    function createMarker(point,name,html,cat,id) { 
    var marker = new GMarker(point,icons[cat]); 
    GEvent.addListener(marker, "click", function() { 
    rating_html = CallRating(<?php echo $page_id; ?>,id); 
    rating_html = decodeURI(rating_html); 
    marker.openInfoWindowHtml(html);   
    document.getElementById("rating_html_"+id+"").innerHTML=rating_html; 
    }); 
    GEvent.addListener(marker, "dragstart", function() { 
     map.closeInfoWindow(); 
    }); 
    // save the info we need to use later for the side_bar 
    gmarkers[i] = marker; 
    htmls[i] = html; 
    // add a line to the side_bar html 
    if(i%2==0) 
    { 
     var sclass="even"; 
    } 
    else 
    { 
     var sclass="odd"; 
    } 
    side_bar_html += '<li class="'+sclass+'"><a href="javascript:myclick(' + i + ',' + id + ')" class="map_data mapdata-list">' + name + '<\/a></li>'; 
    global=i; 
    i++; 
    return marker; 
    } 

    // This function picks up the click and opens the corresponding info window 
    function myclick(i,id) { 
    rating_html = CallRating(<?php echo $page_id; ?>,id); 
    rating_html = decodeURI(rating_html); 
    gmarkers[i].openInfoWindowHtml(htmls[i]);   
    document.getElementById("rating_html_"+id+"").innerHTML=rating_html; 
    } 


    // create the map 
    var map = new GMap(document.getElementById("map")); 
    map.addControl(new GLargeMapControl()); 
    map.addControl(new GMapTypeControl()); 
    //map.setMapType(G_SATELLITE_MAP); 
    map.setCenter(new GLatLng(<?php echo $emp_info['emp_latitude']; ?>, <?php echo $emp_info['emp_longitude']; ?>), 8); 
    // create the clusterer 
    var clusterer = new Clusterer(map); 

    // set the clusterer parameters if you dont like the defaults 
    clusterer.icon = clusterIcon;  
    clusterer.maxVisibleMarkers = 100; 
    clusterer.gridSize = 5; 
    clusterer.minMarkersPerClusterer = 5; 
    clusterer.maxLinesPerInfoBox = 6; 

    var rating_html=""; 
    // Read the data 
    var request = GXmlHttp.create(); 
    request.open("GET", "xml/<?php echo $org_id.'/emp/'.$emp_id.'/'.$map_category; ?>.xml", true); 
    request.onreadystatechange = function() { 
    if (request.readyState == 4) { 
     var xmlDoc = GXml.parse(request.responseText); 
     // obtain the array of markers and loop through it 
     var markers = xmlDoc.documentElement.getElementsByTagName("marker"); 
     var i = 0; 
     for (i = 0; i < markers.length; i++) { 
     // obtain the attribues of each marker 
     var lat = parseFloat(markers[i].getAttribute("lat")); 
     var lng = parseFloat(markers[i].getAttribute("lng")); 
     var point = new GPoint(lng,lat); 
     var town = markers[i].getAttribute("town"); 
     var name = markers[i].getAttribute("name"); 
     var id = markers[i].getAttribute("id"); 
     var cat = markers[i].getAttribute("cat"); 
     var marker = createMarker(point,name,"<a href='<?php echo $url;?>="+id+"' target='_blank' class='map_data'>"+name+"</a><br>"+town+"<div id='rating_html_"+id+"'></div>",cat,id); 
     // create clusterer object 
     clusterer.AddMarker(marker,town); 
     } 
     // put the assembled side_bar_html contents into the side_bar div 
     if(side_bar_html=="") 
     { 
     document.getElementById("list_html").innerHTML = "<li>No data found! Please try again.</li>"; 
     } 
     else 
     { 
      document.getElementById("list_html").innerHTML = side_bar_html; 
      gmarkers[global].openInfoWindowHtml(htmls[global]); 
      map.closeInfoWindow(); 
     } 
     // Clear the "please wait" message 
    } 
    } 
    request.send(null); 
} 

else { 
    alert("Sorry, the Google Maps API is not compatible with this browser"); 
} 

//]]> 
</script> 
</pre> 
+0

あなたはコードを投稿することができます – Devjosh

+0

私はコードを投稿してください助けてください。ありがとう –

答えて

0

Googleが相対アドレスを一緒に表示していれば、マーカは互いに隠れてしまい、1つの場所にいくつのマーカーがあるか見ることはできません。

0

になり、それらは常に重なります。誰かがあなたを助けることができるかどうかを知ることは面白いでしょう。私は、複数の人が同じ場所/マーカーの下に来るときに、その詳細/リンクをinfoWindowに置くことをお勧めします。同じポイントに複数のマーカーを表示しないでください。また、複数のマーカーを表示するのに十分な場合は、マーカーアイコンのサイズを変更して、重複していてもユーザーが見ることができます。

+0

あなたの答えに感謝しますが、問題はマーカーが重複しているということではない、問題は私がcreateMarker関数を呼び出すとき、同じ場所に10人の住所がある場合など、同じ住所を持つすべての人の詳細を表示している場合は、次のようになります。 1人目の名前 第2の人物名 第3の人物名 第4の人物名 5人称 &5 more ...... これは起こっていることであり、リンクではありません問題の原因となっています。 –

関連する問題