Google maps Google places api我想获得JSON输出

Google maps Google places api我想获得JSON输出,google-maps,google-places-api,Google Maps,Google Places Api,我想在GooglePlacesAPI上搜索特定位置的位置,并在JSOn输出上显示它们。我该如何编码。请给出示例代码。试试 这里你需要根据你的距离给出半径。类型可能是自动取款机,餐馆,加油站,你需要的方式 您需要提供金奈、班加罗尔等地,或者提供纬度/经度。简要描述一下。您可以在android/iphone中尝试此工作代码。它使用jquery mobile。它可以找到当前lat&lon周围的位置 map.html <!DOCTYPE html> <html> <

我想在GooglePlacesAPI上搜索特定位置的位置,并在JSOn输出上显示它们。我该如何编码。请给出示例代码。

试试

这里你需要根据你的距离给出半径。类型可能是自动取款机,餐馆,加油站,你需要的方式


您需要提供金奈、班加罗尔等地,或者提供纬度/经度。简要描述一下。您可以在android/iphone中尝试此工作代码。它使用jquery mobile。它可以找到当前lat&lon周围的位置

map.html

<!DOCTYPE html> 
<html> 
  <head> 
  <meta charset="utf-8">



  <link rel="stylesheet" href="css/jquery.mobile-1.0.min.css" />


  <script src="js/jquery.js"></script>   
  <script src="js/jquery.mobile-1.0.js"></script>   
  <script src="js/map.js"></script>

 <script type="text/javascript" src="//maps.googleapis.com/maps/api/js?sensor=true&libraries=places"></script>

</head> 

<body> 
<div data-role="page" data-theme="none" class="page-map" id="page-map">
  <script src="js/canvas.js"></script>
    <div id="map-canvas">
                        <!-- map loads here... -->
    </div>
 </div>
</body>
</html>

map.js

var map;
var infowindow;
var lat;
var lng;
var lng;
var service;
var reference;
var initialLocation;

$( '.page-map' ).live( 'pagecreate',function(event){        
    checkLocation();
});


function checkLocation() {
    if (navigator.geolocation) {

        navigator.geolocation.getCurrentPosition(function(position) {

            initialLocation = new google.maps.LatLng(position.coords.latitude,
                    position.coords.longitude);
            lat = position.coords.latitude;
            lng = position.coords.longitude;

            callPlaceService(lat, lng);
        }, gpsFail, {
            enableHighAccuracy : true,
            maximumAge : 300000
        });
    }
}

function callPlaceService(lat, lng) {

    var pyrmont = new google.maps.LatLng(lat, lng);

    var myOptions = {
        zoom : 15,
        center : pyrmont,
        mapTypeId : google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById("map-canvas"), myOptions);

    var request = {
        location : pyrmont,
        radius : 5000,
        //types: ['atm','bank'],
        keyword : 'Bank'
    };

    service = new google.maps.places.PlacesService(map);    
    service.search(request, callback);
}

function callback(results, status) {

    if (status == google.maps.places.PlacesServiceStatus.OK) {

        for ( var i = 0; i < results.length; i++) {

            var requestDetails = {reference : results[i].reference};

            service.getDetails(requestDetails, checkDetailedStatus);
        }
    }
}

function checkDetailedStatus(details, detailStatus) {
    if (detailStatus == google.maps.places.PlacesServiceStatus.OK) {

        var name = '{"name":"'+  details.name +'"}';
        var address = '{"address":"' + details.formatted_address + '"}'; 
        var phone = '{"phone":"' + details.formatted_phone_number+ '"}';        
        var website = '{"website":"' + details.website + '"}';
        var full_address = name + "," + address + "," + phone + "," + website;  
        console.log(full_address);
        var jsonTxt = JSON.stringify(full_address);

    } 
}

function gpsFail() {
    //Geo-location is supported, but we failed to get your coordinates. 
}
var映射;
var信息窗口;
var lat;
乏液化天然气;
乏液化天然气;
var服务;
var参考;
var初始位置;
$('.page map').live('pagecreate',函数(事件){
checkLocation();
});
函数checkLocation(){
if(导航器.地理位置){
navigator.geolocation.getCurrentPosition(函数(位置){
initialLocation=new google.maps.LatLng(position.coords.latitude,
位置坐标经度);
纬度=位置坐标纬度;
lng=位置坐标经度;
callPlaceService(lat、lng);
},gpsFail{
EnableHighAccurance:正确,
最高限额:300000
});
}
}
功能调用位置服务(lat、lng){
var pyrmont=新的google.maps.LatLng(lat,lng);
变量myOptions={
缩放:15,
中心:皮尔蒙特,
mapTypeId:google.maps.mapTypeId.ROADMAP
};
map=new google.maps.map(document.getElementById(“地图画布”),myOptions);
var请求={
地点:皮尔蒙特,
半径:5000,
//类型:[“atm”、“银行”],
关键词:“银行”
};
服务=新的google.maps.places.PlacesService(地图);
服务搜索(请求、回调);
}
函数回调(结果、状态){
if(status==google.maps.places.PlacesServiceStatus.OK){
对于(var i=0;i
请阅读Google Places API文档:感谢您提供代码。我正在使用android平板电脑。我需要使用phonegap为Google地图应用java脚本。