Google Places APIを使用して、半径 1000 メートル以内のロンドン中心部のすべての場所をリクエストしようとしています。必要な出力タイプは XML です。
これはJQueryを使用した私のコードです:
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
</head>
<body>
<script>
jQuery(document).ready(function(){
jQuery.ajax({
url: 'https://maps.googleapis.com/maps/api/place/search/xml',
dataType: 'xml',
type: 'GET',
data: {
key: 'MY KEY',
location: '51.526688,-0.123825',
radius: 1000,
sensor: 'false',
types: 'food'
},
success: function(data){
alert("success");
},
error: function(data){
alert("error");
}
});
});
</script>
</body>
</html>
残念ながら、私はerror
メッセージしか受け取りません。Firebug コンソールに表示されますXML Parsing Error: no element found Location: moz-nullprincipal:{7577ff8b-21cb-40c5-824b-de812540f29e} Line Number 1, Column 1:
。
独自の API キーを取得し、オンにしPlaces API
ました。(XAMPPを使用してローカルでコーディングしているため、WebサイトのURLは「http://localhost/」です。)