google map地址解析

<!DOCTYPE html> 
<html> 
<head> 
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/> 
<meta http-equiv="content-type" content="text/html;"/> 
<title>Google Maps JavaScript API v3 Example: Geocoding Simple</title> 
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" /> 
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
<script type="text/javascript"> 
  var geocoder; 
  var map; 
  function initialize() { 
    geocoder = new google.maps.Geocoder(); 
    var latlng = new google.maps.LatLng(31.23, 121.47); 
    var myOptions = { 
      zoom: 12, 
      center: latlng, 
      mapTypeId: google.maps.MapTypeId.ROADMAP 
    } 
    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); 
  } 
 
  function codeAddress() { 
    var address = document.getElementById("address").value; 
    geocoder.geocode( { 'address': address}, function(results, status) { 
   
      if (status == google.maps.GeocoderStatus.OK) {
     
        console.log(results[0].geometry.location); 
        //alert(results[0].geometry.location.jb);
        map.setCenter(results[0].geometry.location); 
        
        this.marker = new google.maps.Marker({ 
                title:address, 
            map: map,  
            position: results[0].geometry.location 
        }); 
                var infowindow = new google.maps.InfoWindow({ 
                    content: '<strong>'+address+'</strong><br/>'+'纬度: '+results[0].geometry.location.jb+'<br/>经度: '+results[0].geometry.location.kb
                }); 
                infowindow.open(map,marker); 
      } else { 
        alert("Geocode was not successful for the following reason: " + status); 
      } 
    }); 
  } 
</script> 
</head> 
<body οnlοad="initialize()"> 
  <div> 
    <input id="address" type="textbox" value="上海市"> 
    <input type="button" value="地址解析" οnclick="codeAddress()"> 
  </div> 
<div id="map_canvas" style="height:90%;top:30px"></div> 
</body> 
</html
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Google Map根据经纬度解析地址的原理是通过地理编码技术实现的。当我们输入一对经纬度坐标时,Google Map会使用地理编码算法将该坐标转换为具体的地址。 地理编码技术是将地球上的经纬度坐标转换为描述地理位置的具体地址的过程。Google Map通过使用自身的庞大地理数据库和先进的算法,将用户提供的经纬度与数据库中的地址进行匹配。 具体而言,Google Map的经纬度解析过程包含以下几个主要步骤: 1. 获取经纬度:用户在Google Map上标记或输入经纬度坐标,或通过其他途径获取经纬度信息。 2. 发送请求:Google Map接收到用户提交的经纬度坐标后,会向服务器发送请求,请求解析该坐标对应的地址。 3. 数据匹配:服务器接收到请求后,会在庞大的地理数据库中进行搜索,寻找与用户提供的经纬度坐标最匹配的地址数据。 4. 地址解析:一旦找到了匹配的地址数据,服务器会对该数据进行解析和处理,提取出具体的地址信息,例如街道名称、城市、国家等。 5. 返回结果:最后,服务器将解析后的地址信息返回给Google Map,并展示在用户界面上,使用户能够直观地了解该经纬度所对应的具体地址。 通过以上步骤,Google Map实现了根据经纬度解析地址的功能。这使得用户可以方便地使用经纬度坐标来查找和定位目标地址,提供了丰富的地理信息服务。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值