다음 예인 http://jsbin.com/inepo3/7/edit으로 Google Maps API의 lng 및 lat 좌표를 가져 오려고합니다. '성공'팝업이 표시되기를 기대하지만 '오류'팝업이 계속 표시됩니다. google maps-request는 정확한 json 피드백을 제공합니다 (방화 광으로 확인).ajax() 요청으로 Google Maps API의 주소 좌표 가져 오기
<script type="text/javascript">
$().ready(function() {
$.fn.getCoordinates=function(address){
$.ajax(
{
type : "GET",
url: "http://maps.google.com/maps/api/geocode/json",
dataType: "jsonp",
data: {
address: address,
sensor: "true"
},
success: function(data) {
set = data;
alert(set);
},
error : function() {
alert("Error.");
}
});
};
$().getCoordinates("Amsterdam, Netherlands");
});
</script>
누구든지이 문제를 해결하는 방법을 알고 있습니까?
<script type="text/javascript">
$().ready(function() {
var user1Location = "Amsterdam, Netherlands";
var geocoder = new google.maps.Geocoder();
//convert location into longitude and latitude
geocoder.geocode({
address: user1Location
}, function(locResult) {
console.log(locResult);
var lat1 = locResult[0].geometry.location.lat();
var lng1 = locResult[0].geometry.location.lng();
$("#testDiv").html("latitude:" + lat1 + "<p>longitude:" + lng1 + "</p>");
});
});
</script>
구글 맵 API의 버전을 : 우리는 기본적으로 트윗의 주소 (. IE 런던, 마드리드 또는 등 조지아)를 얻을 구글지도의 지오 코더 서비스를 사용하는 LatLng에 실제 주소를 변환하기 위해 트위터를 사용합니까? – kjy112
나는 shure 아니야, 아마 v2 (아마도 사용 된지도 URL을 버전으로 변환 할 수 있겠는가?) –
나는 V3가 지금 다시 그것을보고 있다는 것을 확신한다. – kjy112