给定纬度/经度,使用 JSONP 检索城市和州的最简单方法是啥? [关闭]

Posted

技术标签:

【中文标题】给定纬度/经度,使用 JSONP 检索城市和州的最简单方法是啥? [关闭]【英文标题】:Given a lat/long, what's the simplest way to retrieve the city and state using JSONP? [closed]给定纬度/经度,使用 JSONP 检索城市和州的最简单方法是什么? [关闭] 【发布时间】:2013-03-29 10:06:57 【问题描述】:

我正在寻找 API。最好是 JSONP API(客户端)

【问题讨论】:

【参考方案1】:

不是 JSONP,但您可以根据需要对其进行操作。我正在使用 Google Map API 客户端。

var lat = 'some value';
   var lng = 'some value'; 
   geomap.geocode('latLng':new google.map.latLng(lat,lng),function(res)
            var tmp = [];
            $.each(res,function(i,e)
                    if(e.address_components.length>=4)
                            tmp.push(e);
                    
            );
            if(tmp.length>=1)      
                    tmp.sort();
                    $.each(tmp[0].address_components,function(i,e)
                            if(e.types=='postal_code')  console.log(e.short_name);
                            if(e.types[0]=='administrative_area_level_1') console.log(e.short_name);
                            if(e.types[0]=='locality') console.log(e.short_name);
                    );
            
    );   

【讨论】:

以上是关于给定纬度/经度,使用 JSONP 检索城市和州的最简单方法是啥? [关闭]的主要内容,如果未能解决你的问题,请参考以下文章