本文介绍了获取交code的经度和纬度谷歌API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只需要知道如何去从经度和纬度得到一个职位code。

使用IM的谷歌地图API来获取长期LAT基于搜索,如'曼彻斯特'然后我需要获得那个职位code从这个查询我的数据库。

我的code迄今

 函数getLatLng()
{
    VAR本地搜索=新google.maps.Geo codeR();
    变种后code = $(#地址)VAL()。
    localSearch.geo code({地址:交code},
                    功能(结果,状态){
                        如果(results.length == 1){
                            VAR的结果=结果[0];
                            VAR位置= result.geometry.location;
                        }
                        其他
                        {
                            $(#错误)HTML(找不到地址)。
                        }
                    });
}
 

解决方案

什么,你正在试图做的是(示例)反向地理编码

请参阅:<一href="http://stackoverflow.com/questions/9689692/google-reverse-geocoding-how-to-snap-to-nearest-full-post$c$c">Google反向地理编码 - 如何捕捉到最近的全交code

具体的链接:

https://google-developers.appspot.com/maps/documentation/javascript/examples/geocoding-reverse

I just need to know how to go about getting a postcode from the longitude and latitude.

Im using the google maps api to get the long and lat based on a search such as 'manchester' i then need a to get the postcode from this to query my database.

My code so far is

function getLatLng()
{
    var localSearch = new google.maps.Geocoder();
    var postcode = $("#address").val();
    localSearch.geocode({ 'address': postcode },
                    function(results, status) {
                        if (results.length == 1) {
                            var result = results[0];
                            var location = result.geometry.location;
                        }
                        else
                        {
                            $("#error").html("Address not found");
                        }
                    });
}
解决方案

What you're trying to do is (an example of) 'Reverse Geocoding'

See:Google reverse geocoding - how to snap to nearest full postcode

Specifically a link to:

https://google-developers.appspot.com/maps/documentation/javascript/examples/geocoding-reverse

这篇关于获取交code的经度和纬度谷歌API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 16:38