In this article I will explain how to get the address location from Latitude and Longitude using the Google Maps Geocoding API.
I will explain two different ways of using the process of Reverse Geocoding using the Google Maps Geocoding API.
Direct Usage
Here I’ll pass the value of Latitude and Longitude directly from TextBoxes to the Google Maps Geocoding API and it will return me the address of the location.
Google Maps V3: 通过经纬度获取地址信息 Get address from Latitude and Longitude
Google Maps V3: 通过经纬度获取地址信息 Get address from Latitude and Longitude
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> Latitude: <input type="text" id="txtLatitude" value="18.92488028662047" /> Latitude: <input type="text" id="txtLongitude" value="72.8232192993164" /> <input type="button" value="Get Address" onclick="GetAddress()" /> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> function GetAddress() { var lat = parseFloat(document.getElementById("txtLatitude").value); var lng = parseFloat(document.getElementById("txtLongitude").value); var latlng = new google.maps.LatLng(lat, lng); var geocoder = geocoder = new google.maps.Geocoder(); geocoder.geocode({ 'latLng': latlng }, function (results, status) { if (status == google.maps.GeocoderStatus.OK) { if (results[1]) { alert("Location: " + results[1].formatted_address); } } }); } </script> </body> </html>
Using Maps
Here I’ll be determining the coordinates of the location when user clicks on the Google Map and then these coordinates will be used to determine the address of the location using the Google Maps Geocoding API.
Note: The above process of determining the Latitude and Longitude when clicked on Map is covered in detail in my article Get Latitude and Longitude (Location Coordinates) using Google Maps OnClick event
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> window.onload = function () { var mapOptions = { center: new google.maps.LatLng(18.9300, 72.8200), zoom: 14, mapTypeId: google.maps.MapTypeId.ROADMAP }; var infoWindow = new google.maps.InfoWindow(); var latlngbounds = new google.maps.LatLngBounds(); var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions); google.maps.event.addListener(map, 'click', function (e) { var latlng = new google.maps.LatLng(e.latLng.lat(), e.latLng.lng()); var geocoder = geocoder = new google.maps.Geocoder(); geocoder.geocode({ 'latLng': latlng }, function (results, status) { if (status == google.maps.GeocoderStatus.OK) { if (results[1]) { alert("Location: " + results[1].formatted_address + "rnLatitude: " + e.latLng.lat() + "rnLongitude: " + e.latLng.lng()); } } }); }); } </script> <div id="dvMap" style="width: 500px; height: 500px"> </div> </body> </html>
相关推荐
and seconds, latitude and longitude of degrees, minutes, seconds field can be fine-tuning button or the keyboard up and down keys to increase or decrease the number,you can use left and right ...
get_addr_longitude_latitude.pyget_addr_longitude_latitude.pyget_addr_longitude_latitude.pyget_addr_longitude_latitude.pyget_addr_longitude_latitude.pyget_addr_longitude_latitude.pyget_addr_longitude_...
In the GIS-related software often have to enter the latitude and longitude values, and MFC Edit control based on the latitude and longitude input controls need to create three Edit edit box to enter ...
我们可以通过地球两点间的经纬度计算对应两点间的求面距离
DEPTH = GETDEPTH(LATITUDE, LONGITUDE) 估计指定坐标处的海底深度 DEPTH。 LATITUDE 和 LONGITUDE 坐标可以是指定十进制度的数值数组,也可以是指定度、分、秒或 GPS 度的字符串元胞数组。 DEPTH 以米为单位返回,...
2019年3月最新权威(www.ip2location.com)全球ip地址库,为.csv格式,类型为[DB5.LITE] IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE Database,即提供按 国家-地区-城市-经纬度 来区分的数据
convert the classical latitude & longitude coordina
经纬度格式转换:度分秒格式之间的转换 编程语言:C++ 包括代码,debug版本与release版本,有可执行exe文件
Querying IP address information, support longitude and latitude. 快速查询IP信息,支持国内和国外IP信息查询,支持查询经纬度。
数据集包含全球每个国家和每个美国州的GPS坐标。包括:国家代码,纬度,经度,国家,美国州代码,美国州纬度,美国州经度,美国州。...world_country_and_usa_states_latitude_and_longitude_values.csv
Lite IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE
get longitude longitude by address. 地址转发经纬度方法。包括 gps84,gcj02,bd09 之间的转换
数据包含人口(非全样本)、经纬度 Country City AccentCity Region Population Latitude Longitude
最近项目需要通过经纬度查询 具体的地址和区域名称,通过查询网络资源,发现提供的大多是得到具体的地址而对区域或城市名称的获取就不是很好把握;在这里自己搞了个: 代码如下://webclient客户端对象 WebClient ...
2019年7月最新权威(www.ip2location.com)全球ip地址库,为.csv格式,类型为[DB5.LITE] IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE Database,即提供按 国家-地区-城市-经纬度 来区分的共5字段数据
从USB串口读取GPS经纬度信息,调用百度地图显示当前位置(Read the GPS latitude and longitude information from the USB serial port, and call the Baidu map to show the current position)
* 根据地理坐标获取国家、省份、城市,及周边数据类(利用百度Geocoding API实现) ... * Public getAddressComponent 根据地址获取国家、省份、城市及周边数据 * Private toCurl 使用curl调用百度Geocoding API
iOS源代码,根据定位得到经纬度,使用经纬度计算出日落日出时间,只需要调用一个方法+(void)sunrisetWithLongitude:(double)longitude andLatitude:(double)latitude andResponse:(void(^)(SunString *sunString))...
geohash简介: geohash是一种地址编码,它能把二维的经纬度编码成一维的字符串。geohash有以下几个特点: 首先,geohash用一个字符串表示经度和纬度两个坐标。某些情况下无法在两列上同时应用索引 (例如MySQL 4...
对GPS协议进行解析,协议采用nema,解析经纬度,时间等信息(The GPS protocol analysis, protocol uses nema, parsing latitude and longitude, time and other information)