2012-07-26 66 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

回答

相关问题