2011-08-23 2 views
0

안녕을 처리하는 방법을 내가 꽤 많은 스크립트를 가지고,하지만 난 정말 ... 더 무엇을 해야할지하지 않습니다 도움이 필요Google지도 API v2를 - 내가 여기에 모두 게시 실 거예요 그래서 200 ~ 300 백 개 마커

나는지도에서 ~ 300 마커가 있고 그들은 모두 동시에로드하고, Google은 처리 할 수 ​​없거나 스크립트가 처리 할 수 ​​없지만 그 중 절반은 "더 이상 찾을 수 없습니다"라는 메시지를 얻고 있습니다 (다른 사용자 정확하게로드). 그러나 내가 모든 것을 하나씩 모두 지우면 모든 것이 제대로 작동한다!

어떻게해야합니까? 단계별로 몇 가지를로드 할 수있는 방법이 있습니까? 아니면 많은 마커 처리기가 있습니까? (markersManager가 아님, 모든 확대/축소 수준에서 모두 볼 수 있어야 함)

시간 초과로 인해 시도가 도움이되지 않았습니다!

코드의 일부 :

function initHeadAddress(searchString) { 
if(searchString == 'undefined') { 
    map.clearOverlays(); 
    var t = setTimeout("showAddress('Himmelev Bygade 78 B, 4000 Roskilde, Denmark',1,'3T Bygningsentreprise A/S','4000','Roskilde','46328328','null','www.3t.dk',null,null)",1000); 
    var t = setTimeout("showAddress('Nørre Allé 51, 7760 Hurup, Denmark',4,'Idealcombi','7760','Hurup','96882500','null','http://www.idealcombi.dk/',null,null)",1000); 
    ..... A LOT OF THESE HERE MORE !!!! 

    // default one 
    showAddress('Denmark', 0, null, null,null,null,null,null,null,searchString); 
    } else { 
    // if used search function 
    showAddress(searchString, 0, null, null,null,null,null,null,null,searchString); 
    } 
} 

ShowAddress 기능 :

function showAddress(address, markerType, companyname,postnr, by, phone, fax, web, email, searchString) { 
     if (geocoder) { 
     geocoder.getLatLng(
      address, 
      function(point) { 
      if (!point) { 
       //alert("Adresse " +address+ " blev ikke fundet"); 
       console.log("Adresse " +address+ " blev ikke fundet"); 
      } else {    
       var myIcon = new GIcon(G_DEFAULT_ICON); 
       myIcon.shadow = null; 
       myIcon.infoWindowAnchor = new GPoint(9, 2) 

       if (markerType == '0') { 
        myIcon.image = '/files/billeder/../Templates/Designs/Ideal2011/images/Map/googleempty.png'; 
        myIcon.iconSize = new GSize(18, 18);  
       } 
       if (markerType == '1') { 
        myIcon.image = '/files/billeder/../Templates/Designs/Ideal2011/images/Map/googlered.png'; 
        myIcon.iconSize = new GSize(18, 18); 


        $('#dotRedCheckbox').click(
         function(){ 
          if(!$(this).hasClass('activeMarker')){ 
           marker.hide(); 
          } else { 
           marker.show(); 
          } 
         } 
        ); 
       } 
       else if (markerType == '2') { 
        myIcon.image = '/files/billeder/../Templates/Designs/Ideal2011/images/Map/googlelblue.png'; 
        myIcon.iconSize = new GSize(18, 18); 

        $('#dotlBlueCheckbox').click(
         function(){ 
          if(!$(this).hasClass('activeMarker')){ 
           marker.hide(); 
          } else { 
           marker.show(); 
          } 
         } 
        ); 
       } 
       else if (markerType == '3') { 
        myIcon.image = '/files/billeder/../Templates/Designs/Ideal2011/images/Map/googledblue.png'; 
        myIcon.iconSize = new GSize(18 , 18); 

        $('#dotdBlueCheckbox').click(
         function(){ 
          if(!$(this).hasClass('activeMarker')){ 
           marker.hide(); 
          } else { 
           marker.show(); 
          } 
         } 
        ); 
       } 
       else if (markerType == '4') { 
        myIcon.image = '/files/billeder/../Templates/Designs/Ideal2011/images/Map/googlegreen.png'; 
        myIcon.iconSize = new GSize(18, 18); 

        $('#dotGreenCheckbox').click(
         function(){ 
          if(!$(this).hasClass('activeMarker')){ 
           marker.hide(); 
          } else { 
           marker.show(); 
          } 
         } 
        ); 
       } 
       var markerOptions = { icon: myIcon }; 
       var marker = new GMarker(point, markerOptions); 

       marker.getPoint(); 

       if(markerType != 0){   
        points.push(point); 
        markers.push(marker);  
       } 

       if (markerType == 0) { 
        if(searchString == 'undefined'){ 
         map.setCenter(point, 6); 
        } else { 
         map.setCenter(point, 13); 

         LatD = point.lat().toFixed(5); 
         LngD = point.lng().toFixed(5); 

         find_closest_marker(LatD, LngD); 
         find_closest_marker2(LatD, LngD); 
         find_closest_marker3(LatD, LngD); 
        } 
       } 

       Lat = point.lat().toFixed(5); 
       Lng = point.lng().toFixed(5); 


       var image = '<img src="http://cbk0.google.com/cbk?output=thumbnail&w=85&h=70&ll='+Lat+','+Lng+'" />'; // alt="'+address+'" 

       map.addOverlay(marker); 

       if(markerType != 0) { 

        if(fax != "" && fax != null && fax != 'null'){ 
         var newfax = "Mob.: "+fax+"<br/>"; 
        } else { 
         var newfax = "";  
        }; 
        if(web != "" && web != null && web != 'null'){ 
         var newweb = "<a href='"+web+"'>"+web+"</a><br/>"; 
        } else { 
         var newweb = "";  
        }; 
        if(postnr != "" && postnr != null && postnr != 'null'){ 
         var newpostnr = postnr; 
        } else { 
         var newpostnr = ""; 
        }; 
        if(phone != "" && phone != null && phone != 'null'){ 
         var newphone = phone; 
        } else { 
         var newphone = ""; 
        }; 

        //address = address.replace("Denmark, ",""); 
        //address = address.replace(", Denmark",""); 
        //address = address.replace(", 2650 Hvidovre",""); 
        //address = address.replace(", Hurup",""); 
        //address = address.replace("UK, ",""); 
        address2 = address.split(','); 
        address = address2[0]; 

        var infoboxInfo = '<div class="infoboxall"><div class="infoboxinfo"><div class="infoboxAddress">'+companyname +"</div>"+ address + '<br/>' + newpostnr + " " + by+ "<br/>" + "Tlf.: " + newphone + "<br/>" + newfax + newweb+"<a href='mailto:"+email+"'>"+email+"</a>"+'</div>' + image+'</div>'; 
        //marker.openInfoWindowHtml(address); 
        //GEvent.addListener(marker, 'click',marker.openInfoWindowHtml(address)); 
        GEvent.addListener(marker, "click", function() 
        {marker.openInfoWindowHtml(infoboxInfo);}); 

        marker.markerType = markerType; 
        marker.title = companyname; 
        marker.address = address; 
        marker.postby = newpostnr+ " " + by; 
        marker.phone = newphone; 
        marker.fax = newfax; 
        marker.web = newweb; 
        marker.email = email; 

       } 

      } 
      } 
     ); 
     } 
    } 

누구나 어떤 아이디어? 마커가 5 개 정도 있다면 스크립트가 어떻게 작동하는지 ...하지만 모두 삽입되면 일부만 보여줍니다. 아이디어?

+0

구글이 API 것이 좋습니다 것은, 버전 2보다 쉽고 청소기 생각 버전 3이 사용됩니다. 아직 시도해 봤어? – Sparky

+0

실제로 v3에 익숙하지 않은데 v2를 v3으로 변환하는 것이 어렵습니까? :) 자습서의 대부분은 여전히 ​​v2를 위해 v3를 가지고 있습니까? :) – Vilius

+0

[Google의 모든 기능은 버전 3입니다] (http://code.google.com/apis/maps/documentation/javascript/tutorial.html). 아래 내 대답을 참조하십시오. – Sparky

답변

0

예, 데이터베이스에서 마커가로드되는 previous project에서이 작업을 수행 할 수 있습니다 (이 프로젝트에서는 API v3을 사용하지만 개념은 동일합니다). API는 동일한 IP에서 동시에 5 개의 요청을 받아들이므로 "마커 큐"를 작성했습니다. API에서 오류를 반환하여 마커를 배치 할 수없는 경우 대기열에 넣고 매초마다 대기열이 비어있을 때까지 대기열에서 다음 마커를 추가하려고합니다.

이전 링크의 "gmaps3.js"소스를 확인하여 내가 어떻게했는지 확인하십시오. 더 궁금한 점이 있으면 알려주세요.

+0

감사합니다 그것을 밖으로 검사합니다! 내 v3 지식이별로 좋지 않기 때문에 더 많은 예제가 더 좋을 것입니다. v3 또는 마커가 포함 된 자습서 – Vilius

0

According to Google, API 버전 2는 더 이상 사용되지 않으며 버전 3을 사용해야합니다. 큰 장점 중 하나는 더 이상 도메인 별 "API 키"가 필요 없다는 것입니다. 사실 API 키가 필요하지 않습니다. 모든 버전 3

에 대한 당신이 jQuery를하고 jQuery를 플러그인에 대해 잘 알고 있다면 당신이 정말로지도 API 버전을 사용하는 것처럼 3.

관련 문제