设为首页 加入收藏

TOP

Java如何通过Google map api实现地址解析
2014-11-24 02:38:50 来源: 作者: 【 】 浏览:0
Tags:Java 如何 通过 Google map api 实现 地址 解析

  地址解析就是将地址(如:广东省广州市)转换为地理坐标(如经度:113.26442,纬度:23.129074)的过程。google map api提供两种方法实现地址解析。


  第一种,是通过使用 GClientGeocoder 对象来实现,大家可以参考google map api的相关文档,以下是摘自google的相关代码


  var map = new GMap2(document.getElementById("map_canvas"));


  var geocoder = new GClientGeocoder();


  function showAddress(address) {


  geocoder.getLatLng(


  address,


  function(point) {


  if (!point) {


  alert("无法解析:" + address);


  } else {


  map.setCenter(point, 13);


  var marker = new GMarker(point);


  map.addOverlay(marker);


  marker.openInfoWindowHtml(address);


  }


  }


  );


  }


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇使用Java播放声音文件 下一篇Java字符串与字符集的基本概念

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: