2012-07-26 85 views
1

我知道有很多關於此問題的主題,但我已嘗試過所有方法,但仍無法解決問題。並非所有標記都顯示在Google Maps API中

我試圖根據他們的位置在谷歌地圖上顯示我的成員。問題是,雖然有34個成員註冊,但只顯示15-22(每刷新一次隨機選擇)標記。

地址是正確的地理編碼,因爲如果我輸入成員頁面,它的標記顯示在地圖correclty上。我認爲這是數據加載的問題,但我不知道如何解決它。

我在Joomla網站上使用swmap插件。 JQuery代碼如下所示。

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true&language='.$locale.'"></script> 
    <script type="text/javascript"> 
    window.addEvent("load",function(){initialize();}); 
    var beaches = '.json_encode($res).'; 
    function initialize() { 
     var myLatlng = new google.maps.LatLng('.$lat_center.', '.$long_center.'); 
     var myOptions = { 
     zoom: 10, 
     center: myLatlng, 
     mapTypeControl: true, 
     mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}, 
     navigationControl: true, 
     mapTypeId: google.maps.MapTypeId.'.$cattype.' 
     } 

     var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions); 
     google.maps.event.addListener(map, \'click\', function() { 
     infowindow.close(); 
     }); 
     setMarkers(map, beaches); 
    } 

     var icons = new Array(); 
     icons["red"] = new google.maps.MarkerImage("'. JURI::root() .'plugins/k2/swmap/'.$color.'/landmark.png", 
     new google.maps.Size(32, 32), 
     new google.maps.Point(0,0), 
     new google.maps.Point(0, 32)); 

    function getMarkerImage(iconColor) { 
    if ((typeof(iconColor)=="undefined") || (iconColor==null)) { 
    iconColor = "red"; 
    } 

    if (!icons[iconColor]) { 
    icons[iconColor] = new google.maps.MarkerImage("'. JURI::root() .'plugins/k2/swmap/'.$color.'/"+ iconColor +"", 
    new google.maps.Size(32, 32), 
    new google.maps.Point(0,0), 
    new google.maps.Point(0, 32)); 
    } 

    return icons[iconColor]; 
    } 

    var iconImage = new google.maps.MarkerImage(\''. JURI::root() .'plugins/k2/swmap/'.$color.'/landmark.png\', 
    new google.maps.Size(32, 32), 
    new google.maps.Point(0,0), 
    new google.maps.Point(0, 32)); 

    var infowindow = new google.maps.InfoWindow(
    { 
    size: new google.maps.Size(150,50) 
    }); 

    function createMarker(map, latlng, label,link, html, color) { 

     var contentString = \'<b>\'+link+\'</b><br>\'+html; 
     var marker = new google.maps.Marker({ 
     position: latlng, 
     map: map, 
     icon: getMarkerImage(color), 
     title: label, 
     zIndex: Math.round(latlng.lat()*-100000)<<5 
    }); 

    google.maps.event.addListener(marker, \'click\', function() { 
    infowindow.setContent(contentString); 
    infowindow.open(map,marker); 
    }); 
} 



function setMarkers(map, locations) { 
    var bounds = new google.maps.LatLngBounds(); 
    for (var i = 0; i < locations.length; i++) { 
    var beach = locations[i]; 
    var myLatLng = new google.maps.LatLng(beach[1], beach[2]); 
    var marker = createMarker(map,myLatLng,beach[0],beach[5],beach[4],beach[3]); 
    bounds.extend(myLatLng); 
    map.fitBounds(bounds); 
} 
} 
+0

由於配額或速率限制,聲音就像是即時地理編碼失敗的問題。你如何填充你的數據?每次頁面加載時,您是否都在對其進行地理編碼? – geocodezip 2012-07-26 15:04:36

+0

是的,我做到了。似乎這個問題確實是谷歌對地理編碼的限制。我嘗試從數據集中傳遞經緯度值,以便不再需要地理編碼。似乎現在工作:) – Ata3ias 2012-07-26 20:55:50

回答

相關問題