2013-09-05 3 views
0

위도 및 경도 값을 Java 스크립트의 주소로 변환하는 방법은 무엇입니까? 내가 geolocation을 시도했지만 그 표시가 10 주소 만. 그것은 10 개 이상의 주소를 표시하지 않습니다. 제발 도와주세요, 미리 감사드립니다. 내 코드 :주소로 변환 위도 및 경도 값

     if (result.Status.code == G_GEO_SUCCESS) { 

          for (var i = 0; i < result.Placemark.length; i++) { 

           var addres = result.Placemark[i].address; 
           // var t1=setTimeout(function(){x.value="2 seconds"},2000); 
           if (addres == "") { 
            // alert('blank'); 
            document.getElementById("msg" + noofid).innerHTML = "Unable to find location"; 
           } else { 
            document.getElementById("msg" + noofid).innerHTML = result.Placemark[i].address; 

           } 
           //alert("address"); 
          } 

         } 
         // ====== Decode the error status ====== 
         else { 
          var reason = "Code " + result.Status.code; 
          if (reasons[result.Status.code]) { 
           reason = reasons[result.Status.code]; 
          } 
          alert('Could not find "' + search + '" ' 
            + reason); 
         } 
        }); 

} 
+0

Google지도 API를 사용할 수 있습니다. – Depado

+0

아침에 직접 양식을 작성하려고합니다. – Dhandabani

답변

0

안녕하세요이 API에 대한 특정 문제를 갖고 있기 때문에, 나는 귀하의 질문에 나는 비슷한 요구를 가지고 내 이전 프로젝트에서 당신과 함께 몇 가지 소스를 공유 할을 가로 질러왔다.

// get nearest coords based on given tracking 
tb.prototype.getNearestStreetCoords = function(lat, lng, callback) { 

    var parentClass = this; 

    var nearestStreet = { 
     latitude: lat, 
     longitude: lng 
    }; 

    if (parentClass.useNearest != true) callback(nearest); 

    var request = { 
     origin: new google.maps.LatLng(lat, lng), 
     destination: new google.maps.LatLng(lat, lng), 
     travelMode: google.maps.DirectionsTravelMode.DRIVING 
    }; 

    directionsService = new google.maps.DirectionsService(); 

    directionsService.route(request, function(response, status) { 

     if (status == google.maps.DirectionsStatus.OK) {  
      callback(response); 
     } else { 
      callback(false); 
     } 

    });  
} 


// get nearest address based on lat & lng 
tb.prototype.getAddress = function(lat, lng, callback) { 

    geocoder = new google.maps.Geocoder(); 
    geocoder.geocode({'latLng': new google.maps.LatLng(lat, lng)}, function(results, status) { 

     var streetAddress = null; 

     if (status == google.maps.GeocoderStatus.OK) { 
      streetAddress = results[0].formatted_address; 
     } 

     callback(streetAddress); 
    }); 
} 
+0

Panagiotis에 감사드립니다. 주소로 변환하는 동안 50 개의 latlong 값이 있지만 주소가 10 개만 표시됩니다. 모든 값을 표시하지 않습니다 ... 감사합니다. 당신의 소중한 시간을 보냅니다. – Dhandabani

+0

서비스에서 회신을 받거나 특정 위도와 경도로 해결할 수 없습니까? 비슷한 문제가있어서 getNearestSteetCoords 함수를 사용하여 내가 제공 한 lat & lng에 가장 가까운 거리 좌표를 제공했습니다. 내가 올바르게 기억하면 이것은 등록 된 주소가있는 유효한 포인트를 가지고 있음을 보장합니다. – Syd

+0

예. 나는 server.but에서 답장을받습니다.하지만 제한된 주소 만 대답했습니다.이 방법을 시도 할 것입니다 .Thanku so much. – Dhandabani