2014-03-24 2 views
-1

도시, 성, 우편 번호가 약 10,000 개 있습니다. 나는 그들을 위해 위도/위도가 필요합니다. 몇 가지 추가 기능을 시도했지만 모두 Google을 사용합니다. 나는 야후가 조금 더 관대 한 제한을 가지고 있다고 들었지만 나는 구글처럼 잘 쓰여진 것을 찾을 수 없다. 높은 한계 (하루에 최소 10K 요청)가있는 Excel 용 무료 배치 지오 코더가 있습니까? 아니면 방금 방황하고 있니?한계가없는 무료 Excel Addin Geocoder가 있습니까?

답변

1

이 코드를 사용하면 저에게 효과적입니다. 동일한 문제가있을 때 온라인으로 찾았습니다. 주소 배열을 Excel에서 공급하는 것과 마찬가지로 특정 요구 사항에 맞춰야합니다.

// delay between geocode requests - at the time of writing, 100 miliseconds seems to work well 
var delay = 40; 


    // ====== Create map objects ====== 
    var infowindow = new google.maps.InfoWindow(); 
    var latlng = new google.maps.LatLng(-34.397, 150.644); 
    var mapOptions = { 
    zoom: 8, 
    center: latlng, 
    mapTypeId: google.maps.MapTypeId.ROADMAP 
    } 
    var geo = new google.maps.Geocoder(); 
    var map = new google.maps.Map(document.getElementById("map"), mapOptions); 
    var bounds = new google.maps.LatLngBounds(); 

    // ====== Geocoding ====== 
    function getAddress(search, next) { 
    geo.geocode({address:search}, function (results,status) 
     { 
     // If that was successful 
     if (status == google.maps.GeocoderStatus.OK) { 
      // Lets assume that the first marker is the one we want 
      var p = results[0].geometry.location; 
      var lat=p.lat(); 
      var lng=p.lng(); 
      // Output the data 
      var msg = 'address="' + search + '" lat=' +lat+ ' lng=' +lng+ '(delay='+delay+'ms)<br>'; 
      document.getElementById("messages").innerHTML += msg; 
      // Create a marker 
      createMarker(search,lat,lng); 
     } 
     // ====== Decode the error status ====== 
     else { 
      // === if we were sending the requests to fast, try this one again and increase the delay 
      if (status == google.maps.GeocoderStatus.OVER_QUERY_LIMIT) { 
      nextAddress--; 
      delay++; 
      } else { 
      var reason="Code "+status; 
      var msg = 'address="' + search + '" error=' +reason+ '(delay='+delay+'ms)<br>'; 
      document.getElementById("messages").innerHTML += msg; 
      } 
     } 
     next(); 
     } 
    ); 
    } 

// ======= Function to create a marker 
function createMarker(add,lat,lng) { 
    var contentString = add; 
    var marker = new google.maps.Marker({ 
    position: new google.maps.LatLng(lat,lng), 
    map: map, 
    zIndex: Math.round(latlng.lat()*-100000)<<5 
    }); 

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

    bounds.extend(marker.position); 

} 

    // ======= An array of locations that we want to Geocode ======== 
    var addresses = [ 
      'General Roberto Fierro Airport Zona Hangares hangar 12 CHIHUAHUA MEXICO ', 
'DURANGO MEXICO ', 'ENSENADA MEXICO ', 'GUADALAJARA MEXICO ', 'GUAYMAS MEXICO ',  'HERMOSILLO MEXICO ', 'HUATULCO MEXICO ', 'LA PAZ MEXICO ', 'LORETO MEXICO ','LOS MOCHIS  MEXICO ', 
'MANZANILLO MEXICO ', 'MATAMOROS MEXICO ', 'MAZATLAN MEXICO ', 'MERIDA MEXICO ', 
'MEXICALI MEXICO ', 'MINATITLAN MEXICO ', 'MONCLOVA MEXICO '  ]; 

    // ======= Global variable to remind us what to do next 
    var nextAddress = 0; 

    // ======= Function to call the next Geocode operation when the reply comes back 

    function theNext() { 
    if (nextAddress < addresses.length) { 
     setTimeout('getAddress("'+addresses[nextAddress]+'",theNext)', delay); 
     nextAddress++; 
    } else { 
     // We're done. Show map bounds 
     map.fitBounds(bounds); 
    } 
    } 

    // ======= Call that function for the first time ======= 
    theNext(); 
}