1. 地图版:
<!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title> - demo</title> <script type='text/javascript' src='//code.jquery.com/jquery-1.8.3.js'></script> <script src="http://maps.google.com/maps/api/js?libraries=places&sensor=true"></script> <script type='text/javascript'>//<![CDATA[ $(window).load(function() { $(function () { var lat = 44.88623409320778, lng = -87.86480712897173, latlng = new google.maps.LatLng(lat, lng), image = 'http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png'; //zoomControl: true, //zoomControlOptions: google.maps.ZoomControlStyle.LARGE, var mapOptions = { center: new google.maps.LatLng(lat, lng), zoom: 13, mapTypeId: google.maps.MapTypeId.ROADMAP, panControl: true, panControlOptions: { position: google.maps.ControlPosition.TOP_RIGHT }, zoomControl: true, zoomControlOptions: { style: google.maps.ZoomControlStyle.LARGE, position: google.maps.ControlPosition.TOP_left } }, map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions), marker = new google.maps.Marker({ position: latlng, map: map, icon: image }); var input = document.getElementById('searchTextField'); var autocomplete = new google.maps.places.Autocomplete(input, { types: ["geocode"] }); autocomplete.bindTo('bounds', map); var infowindow = new google.maps.InfoWindow(); google.maps.event.addListener(autocomplete, 'place_changed', function (event) { infowindow.close(); var place = autocomplete.getPlace(); if (place.geometry.viewport) { map.fitBounds(place.geometry.viewport); } else { map.setCenter(place.geometry.location); map.setZoom(17); } moveMarker(place.name, place.geometry.location); $('.MapLat').val(place.geometry.location.lat()); $('.MapLon').val(place.geometry.location.lng()); }); google.maps.event.addListener(map, 'click', function (event) { $('.MapLat').val(event.latLng.lat()); $('.MapLon').val(event.latLng.lng()); infowindow.close(); var geocoder = new google.maps.Geocoder(); geocoder.geocode({ "latLng":event.latLng }, function (results, status) { console.log(results, status); if (status == google.maps.GeocoderStatus.OK) { console.log(results); var lat = results[0].geometry.location.lat(), lng = results[0].geometry.location.lng(), placeName = results[0].address_components[0].long_name, latlng = new google.maps.LatLng(lat, lng); moveMarker(placeName, latlng); $("#searchTextField").val(results[0].formatted_address); } }); }); function moveMarker(placeName, latlng) { marker.setIcon(image); marker.setPosition(latlng); infowindow.setContent(placeName); //infowindow.open(map, marker); } }); }); </script> </head> <body> Address: <input id="searchTextField" type="text" size="50" style="text-align: left;width:357px;direction: ltr;"> <br> latitude:<input name="latitude" class="MapLat" value="" type="text" placeholder="Latitude" style="width: 161px;" disabled> longitude:<input name="longitude" class="MapLon" value="" type="text" placeholder="Longitude" style="width: 161px;" disabled> <div id="map_canvas" style="height: 350px;width: 500px;margin: 0.6em;"></div> </body> </html>
参考:http://stackoverflow.com/a/14051235/4484798
2. 简约版
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> <textarea id="txtAddress" rows="3" cols="25"></textarea> <br /> <input type="button" onclick="GetLocation()" value="Get Location" /> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> <!-- function GetLocation() { var geocoder = new google.maps.Geocoder(); var address = document.getElementById("txtAddress").value; geocoder.geocode({ 'address': address }, function (results, status) { if (status == google.maps.GeocoderStatus.OK) { var latitude = results[0].geometry.location.lat(); var longitude = results[0].geometry.location.lng(); alert("Latitude: " + latitude + "\nLongitude: " + longitude); } else { alert("Request failed.") } }); }; //--> </script> </body> </html>
2.1 通过经纬度获取地址
<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>
3. 或者直接使用 https://maps.googleapis.com/maps/api/geocode/json?address=changzhi
参考 https://developers.google.com/maps/documentation/geocoding/#ReverseGeocoding
demo:http://sources.ikeepstudying.com/google-distance/latng.php
相关推荐
百度地图地址选择插件(获得详细地址和经纬度) ..."地址:" + address + "\r\n WGS84坐标:经度:" + wgs.lng + ",纬度:" + wgs.lat + "\r\n 百度坐标:" + "经度:"+baidu.lng+",纬度:"+baidu.lat); } });
本文实例讲述了Android简单获取经纬度的方法。分享给大家供大家参考,具体如下: public void getLoc() { // 位置 LocationManager locationManager; LocationListener locationListener; Location location; ...
这个库包含与google位置相关的所有实用程序。例如,获取lat或long,地址和位置设置对话框,还有更多…
基于影子坐标,计算该地点的经纬度。最后利用最小二乘法拟合得到结果。由于建立模型时把问题简单化,因此最后结果会有一定误差
一个计算经纬度的程序,给出了详细的计算结果。
使用 lat-lon 获取分水岭地址 使用经纬度确定形状交点 社交媒体分享结果 发布链接到“我的流域地址!” 在脸书上 发布链接到“我的流域地址!” 在推特上 演示/部署 动态瓷砖源 学校服务器? 里奇? 购买...
geopy-lat-long 获取公司地址,经度和纬度的脚本
高德地图坐标(地图分级坐标)与经纬度之间转换关系
中国所有省市的经纬度,,从GOOGLE获取的,可以用于基于电子地图的开发 insert into GEO_CN(P_INDEX, P_NAMES, LAT, LNG) values('110000', '北京市', '39.904214', '116.407413'); insert into GEO_CN(P_INDEX, P_...
latlon2pix 一个简单的经纬度 (WGS 84) 到像素。 这只是从 PHP 到 JS 的转换:
复制代码 代码如下:/** * 计算两点之间距离 * @param _lat1 – start纬度 * @param _lon1 – start经度 * @param _lat2 – end纬度 * @param _lon2 – end经度 * @return km(四舍五入) */public static ...
1. Lat1 Lung1 表示A点经纬度,Lat2 Lung2 表示B点经纬度; 2. a=Lat1 – Lat2 为两点纬度之差 b=Lung1 -Lung2 为两点经度之差; 3. 6378.137为地球半径,单位为千米; 计算出来的结果单位为千米。 从google ...
自己整合的中国各省市县区的经纬度信息,示例: {"code":"620105","lat":"36.10975375497273","level":"区县","lng":"103.72553503682038","name":"安宁区"} 说明: code 为行政区划代码, lat 纬度 lng 经度 name 区县...
经典算法介绍判断一个点是否在一个区域里面。
全国所地市经纬度JSON格式{"name":"北京市", "log":"116.46", "lat":"39.92", "children":[ {"name":"北京", "log":"116.46", "lat":"39.92"}, {"name":"平谷", "log":"117.1", "lat":"40.13"}, {"name":"密云", ...
lat, long: Approx coordinates of the cell tower range: Approximate area within which the cell could be. (radius in meters) samples: No of measures processed to get this data changeble: ●1 =The ...
中国城市经纬度-精确到二级市.sql,SQL语句,城市表: CREATE TABLE city ( PKID BIGINT (20) PRIMARY KEY NOT NULL, Province VARCHAR (50), CityName VARCHAR (50), Lat DECIMAL (10, 7), Lng DECIMAL (10, ...
经纬度坐标系与直角坐标系转换,可用于测绘、定位计算
[1/3317] 当前: 北京市 {"lng":116.39564503787867,"lat":39.92998577808024} [2/3317] 当前: 天津市 {"lng":117.21081309155257,"lat":39.143929903310077} [3/3317] 当前: 河北省 {"lng":115.66143362422224,...
中国所有城市经纬度坐标json以及对应的省市县3级联动json 用于ECharts地图制作 {"name":"北京市", "log":"116.46", "lat":"39.92", "children":[ {"name":"北京", "log":"116.46", "lat":"39.92"}, {"name":...