그래서지도가 API에 의해 반환 된 JSON에서 값을 검색 할 수 없습니다 알아낼 수 없습니다 :,이 작동하지 않습니다 이유
이$.getJSON('http://www.mapquestapi.com/geocoding/v1/reverse?key=KEY&callback=renderReverse&json&location=' + lat + ',' + longi, function(geo) {
$('#location').html(geo.response.results[0].locations[0].adminArea4);
});
반환 된 JSON은 다음과 같습니다
{
"results": [
{
"locations": [
{
"latLng": {
"lng": -1,
"lat": 51
},
"adminArea4": "Hamp",
"adminArea5Type": "City",
"adminArea4Type": "County",
"adminArea5": "Ba and De",
"street": "Teal Crescent",
"adminArea1": "GB",
"adminArea3": "England",
"type": "s",
"displayLatLng": {
"lng": -1.145731,
"lat": 51.240441
},
"linkId": 0,
"postalCode": "RG3",
"sideOfStreet": "N",
"dragPoint": false,
"adminArea1Type": "Country",
"geocodeQuality": "ADDRESS",
"geocodeQualityCode": "L1AAA",
"mapUrl": "http://www.mapquestapi.com/staticmap/v4/getmap?key=Fmjtd|luubnu0yn5,7g=o5-9072ur&type=map&size=225,160&pois=purple-1,51.2401563,-1.1463337,0,0|¢er=51,-17&zoom=15&rand=-859825484",
"adminArea3Type": "State"
}
],
"providedLocation": {
"latLng": {
"lng": -1.146334,
"lat": 51.240156
}
}
}
],
"options": {
"ignoreLatLngInput": false,
"maxResults": -1,
"thumbMaps": true
},
"info": {
"copyright": {
"text": "© 2013 MapQuest, Inc.",
"imageUrl": "http://api.mqcdn.com/res/mqlogo.gif",
"imageAltText": "© 2013 MapQuest, Inc."
},
"statuscode": 0,
"messages": []
}
}
난 그것은 내가 geo.response.results
비트를 잘못 잡기 때문에 그것이라고 추측한다!
도움을 받으실 수 있습니다.
제목 변경하시기 바랍니다. –
'$ ('# location') .html ('심지어 실행 중입니까? 서비스를 '& callback = renderReverse'를 사용하여 특정 콜백으로 리턴하도록 서비스를 말하고 있기 때문에 실패 할 것입니다. 그것을 무시하고 CORS 헤더를 반환합니다. –
@KevinB : 콜백 = renderReverse를 & callback =으로 변경했습니다. 이제 mapquests의 API 문서에서이 URL을 가져 와서 자바 스크립트를 잊어 버렸습니다. 매우 고마워요! – GeorgeTaylor