取纬度经度通过使用Javascript传递后codeS到maps.google.com [英] Fetch Latitude Longitude by passing postcodes to maps.google.com using Javascript

查看:259
本文介绍了取纬度经度通过使用Javascript传递后codeS到maps.google.com的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有帖子code我的大型数据库,其中包含像值 SL5 9JH,LU1 3TQ 等。

I have Postcode in my large database, which contains values like SL5 9JH, LU1 3TQ etc.

现在,当我上面粘贴后code到maps.google.com它指向一个完美的位置..

Now when I am pasting above postcode to maps.google.com it's pointing to a perfect location..

我的要求是像我想交codeS传递到maps.google.com,它应该返回尖位置的相关经度和纬度,我想在我的数据库来存储。

My requirement is like I want to pass post codes to maps.google.com and it should return a related latitude and longitude of that pointed location, that I want to store in my database.

因此​​,最有可能应该有一些JavaScript为...如果任何人有关于该请提供它..另一个想法

So, most probably there should be some javascript for that... If anybody have another idea regarding that please provide it..

在此先感谢...

推荐答案

该过程的技术术语你描述被称为反向地理编码。谷歌提供的的谷歌地理编码网路服务,在那里你可以做逆转客户端地理编码,而不是在JavaScript中的服务器端。

The technical term for the process you describe is called reverse geocoding. Google offers the The Google Geocoding Web Service, where you can do reverse geocoding on the server side, instead of in JavaScript on the client-side.

例如,如果你尝试在浏览器下面的网址,你会得到的帖子code在参数传递的纬度和经度,以CSV格式:

For example, if you try the following URLs in your browser, you would get back the latitude and longitude of the postcode passed in the q parameter, in CSV format:

http://maps.google.com/maps/geo?q=SL59JH,+UK&output=csv&sensor=false

http://maps.google.com/maps/geo?q=LU13TQ,+UK&output=csv&sensor=false

这是你将如何能够扭转地理code你的帖子codeS在PHP中,例如:

This is how you would be able to reverse geocode your postcodes in php, for example:

$url = 'http://maps.google.com/maps/geo?q=SL59JH,+UK&output=csv&sensor=false';

$data = @file_get_contents($url);

$result = explode(",", $data);

echo $result[0]; // status code
echo $result[1]; // accuracy
echo $result[2]; // latitude
echo $result[3]; // longitude

请注意,作为<一个href=\"http://stackoverflow.com/questions/2621844/fetch-latitude-longitude-by-passing-post$c$cs-to-maps-google-com-using-javascript/2621855#2621855\">Pekka在另一个答案建议的,谷歌地图API使用条款似乎< A HREF =HTTP://$c$c.google.com/apis/maps/terms.html#section_10_12>禁止的结果的的存储,除非存储充当数据将缓存在谷歌地图中使用。你可能想取得联系与谷歌,并询问在谷歌地图API premier 有使用更灵活的条款为您的地理编码要求。

Note that as Pekka suggested in another answer, the Google Maps API Terms of Use seem to prohibit the storage of the results, unless the store acts as a cache for data that will used in Google Maps. You may want to get in touch with Google and enquire on the Google Maps API Premier to have more flexible terms of use for your geocoding requirements.

这篇关于取纬度经度通过使用Javascript传递后codeS到maps.google.com的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆