0
주소 (여기서는 Google 본사)를 지오 코딩하려고합니다. 예기치 않은 토큰 : :입니다 :Google지도 API에서 JSON을 파싱했습니다.
내가 어디 예상치 못한 알아낼 수 없습니다
내가 JSON을 얻을 수있는 jQuery를 $.ajax()
요청을 만들려고
$.ajax({
url: 'https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=myKey',
dataType: 'jsonp',
jsonp: 'callback',
method: 'GET',
success: function(results){
console.log(results);
queryLat = results['results']['geometry']['location']['lat'];
queryLong = results['results']['geometry']['location']['lng'];
console.log('latitude: '+queryLat);
console.log('longitude: '+queryLong);
function callback(mapsResults, status){
if(status == google.maps.places.PlacesServiceStatus.OK){
for(var i = 0; i < mapResults.length; i++){
var place = mapResultsi];
createMarker(mapResults[i]);
}
}
}
var map;
var service;
map = new google.maps.Map(document.getElementById('map'), {
center: new google.maps.LatLng(queryLat, queryLong),
zoom: 15
});
var request ={
location: new google.maps.LatLng(queryLat, queryLong)
radius:'500',
query:'mechanic'
};
service = new google.maps.places.PlacesService(map);
service.textSearch(request, callback);
});
'var place = mapResults [i];' –
그리고'location : new google.maps.LatLng (queryLat, queryLong)'뒤에 쉼표가 누락되었습니다. –
@PaulRoub Thanks . – wordSmith