据说,它有可能获得这种由谷歌地图或诸如此类服务。(我们的地址,只是不够的。)

有帮助吗?

解决方案

术语你要找的是地理编码和是谷歌提供这种服务。

其他提示

除上述 Google地理编码网络服务外,还有一个竞争的雅虎提供的服务。在最近通过用户交互完成地理编码的项目中,我包括对两者的支持。原因是我发现,特别是在美国之外,他们对更加模糊的地点的处理差异很大。有时谷歌会得到最好的答案,有时是雅虎。

有一点需要注意:如果谷歌真的认为他们不知道你的位置在哪里,他们会返回602错误,表示失败。另一方面,雅虎如果可以从你的不良地址剥离一个城市/省/州/等,将返回该镇中心的位置。因此,您必须注意结果,看看它们是否真的是您想要的。某些结果中有辅助字段可以告诉您:雅虎将此字段称为“精确”字段。谷歌称之为“准确性”。

您也可以尝试 OpenStreetMap NameFinder ,它包含(可能)整个世界的开源,类似wiki的街道数据。 NameFinder将在8月底停止存在,但 Nominatim 将取代它。

Google要求您显示包含其数据的Google地图,每天最多2.5k(25k)HTTP请求。有用,但你必须注意使用。

他们确实有

http://groups.google.com/group/Google-Maps-API/web/resources-non-google-geocoders

(谷歌已经删除了这个。如果你看到重复或缓存,我会链接到那个。)

...我在其中找到了 GeoNames ,其中包含可下载的数据库,免费网络服务和商业网络服务。

如果您的网站免费供消费者使用,Google的服务条款将允许您免费使用其地理编码API。如果没有,您将需要获得企业地图的许可。

用于Drupal和PHP(并且易于修改):

function get_lat_long($address) {
  $res = drupal_http_request('http://maps.googleapis.com/maps/api/geocode/json?address=' . $address .'&sensor=false');
  return json_decode($res->data)->results[0]->geometry->location;
}

您可以在此处查看Google Maps API文档,了解这一点:

http://code.google.com/apis/maps /documentation/services.html#Geocoding

您也可以使用动态地图为国际地址做些事情:

http://virtualearth.spaces.live.com/blog /cns!2BBC66E99FDCDB98!1588.entry

您也可以使用Microsoft的MapPoint Web服务执行此操作。

这是一篇博文,解释了如何: http://www.codestrider.com/BlogRead。 ASPX?b = b5e8e275-cd18-4c24-b321-0da26e01bec5

R代码获取街道地址的纬度和经度

# CODE TO GET THE LATITUDE AND LONGITUDE OF A STREET ADDRESS WITH GOOGLE API
addr <- '6th Main Rd, New Thippasandra, Bengaluru, Karnataka'  # set your address here
url = paste('http://maps.google.com/maps/api/geocode/xml?address=', addr,'&sensor=false',sep='')  # construct the URL
doc = xmlTreeParse(url) 
root = xmlRoot(doc) 
lat = xmlValue(root[['result']][['geometry']][['location']][['lat']]) 
long = xmlValue(root[['result']][['geometry']][['location']][['lng']]) 
lat
[1] "12.9725020"
long
[1] "77.6510688"

如果你想要做到这一点,在蟒蛇:

import json, urllib, urllib2

address = "Your address, New York, NY"

encodedAddress = urllib.quote_plus(address)
data = urllib2.urlopen("http://maps.googleapis.com/maps/api/geocode/json?address=" + encodedAddress + '&sensor=false').read()
location = json.loads(data)['results'][0]['geometry']['location']
lat = location['lat']
lng = location['lng']
print lat, lng

注意,谷歌似乎门的请求,如果它认为超过一定金额,所以你想使用一个API关键在HTTP请求。

我有一批100,000条记录需要进行地理编码并且遇到了Google API的限制(因为它是针对内部企业应用程序的,我们必须升级到他们的高级服务,这是10美元以上)

所以,我使用了它: http://geoservices.tamu.edu/Services/ Geocode / BatchProcess / - 他们也有一个API。 (总费用约为200美元)

您可以在JavaScript中尝试使用 kohat

等城市
var geocoder = new google.maps.Geocoder();
var address = "kohat";
geocoder.geocode( { 'address': address}, function(results, status) {
var latitude = results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
alert(latitude+" and "+longitude);
  } 
});

在使用 geopy PyPI 的python中,用于获取晶格,langitude,zipcode等。 这是工作示例代码..

from geopy.geocoders import Nominatim

geolocator = Nominatim(user_agent="your-app-id")

location = geolocator.geocode("Your required address ")

if location:
    print('\n Nominatim ADDRESS :',location.address)
    print('\n Nominatim LATLANG :',(location.latitude, location.longitude))
    print('\n Nominatim FULL RESPONSE :',location.raw)
else:
   print('Cannot Find')

Nominatim - 有些地址无法正常工作,所以我只是尝试了 MapQuest的 。结果 它正确返回。 Mapquest每月提供15000个免费计划交易。这对我来说已经足够了。

示例代码:

import geocoder
g = geocoder.mapquest("Your required address ",key='your-api-key')

for result in g:
   # print(result.address, result.latlng)
   print('\n mapquest ADDRESS :',result.address,result.city,result.state,result.country)
   print('\n mapquest LATLANG :', result.latlng)
   print('\n mapquest FULL RESPONSE :',result.raw)

希望它有所帮助。

我知道这是一个古老的问题,但谷歌正在改变方式,以获得经常性的经纬度。

HTML代码

<form>
    <input type="text" name="address" id="address" style="width:100%;">
    <input type="button" onclick="return getLatLong()" value="Get Lat Long" />
</form>
<div id="latlong">
    <p>Latitude: <input size="20" type="text" id="latbox" name="lat" ></p>
    <p>Longitude: <input size="20" type="text" id="lngbox" name="lng" ></p>
</div>

JavaScript代码

<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap" async defer></script>

    <script>
    function getLatLong()
    {
        var address = document.getElementById("address").value;
        var geocoder = new google.maps.Geocoder();
        geocoder.geocode( { 'address': address}, function(results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                var latitude = results[0].geometry.location.lat();
                document.getElementById("latbox").value=latitude;
                var longitude = results[0].geometry.location.lng();
                document.getElementById("lngbox").value=longitude;
            } 
        });
    }
    </script>

有关详细信息,请参阅此链接 https://www.phpkida.com/java-script /获得纬度 - 经度从 - 地址/

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top