【发布时间】:2015-07-02 06:32:31
【问题描述】:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery.getJSON demo</title>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<script>
APIKEY = "xxxxxxxxx";
requestURL = "https://maps.googleapis.com/maps/api/directions/json?origin=Brooklyn&destination=Queens&mode=transit&key=" + APIKEY + "callback=?";
$.ajax({
url: requestURL,
type: "GET",
dataType: 'jsonp',
cache: false,
success: function(response){
alert(response);
}
});
</script>
</body>
</html>
现在返回一个错误:
https://maps.googleapis.com/maps/api/directions/json?origin=Brooklyn&destin…=Queens&mode=driving&key=[APIKEYHERE]&callback=?
maps.googleapis.com/maps/api/directions/json?origin=Brooklyn&destination=Qu…l7pA&callback=jQuery1102013888467964716256_1429822392524&_=1429822392525:2 Uncaught SyntaxError: Unexpected token :
我不知道如何让它工作。 API 密钥当前是浏览器 API 密钥。
【问题讨论】:
标签: google-maps google-maps-api-3 directions