1.js:根据地址得到经纬度
var myplace=$scope.place;//获取输入的地址
var geocoder = new google.maps.Geocoder();//创建geocoder服务
//调用geocoder服务完成转换
geocoder.geocode( { 'address': myplace}, function(results, status) {
if (status==google.maps.GeocoderStatus.OK) {
lat=results[0].geometry.location.lat();
lng=results[0].geometry.location.lng();
address=results[0].formatted_address;
placeId = results[0].place_id;
//cacheAddress(placeId, lat, lng, address);
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
}); 2.js:反解析,根据经纬度得到地址
fn.callBack=function(data){
if(data.status=="OK"){
var lat=data.results[0].geometry.location.lat;
var lng=data.results[0].geometry.location.lng;
var address=data.results[0].formatted_address;
var placeId=data.results[0].place_id;
if(vm.radius == null || vm.radius.length == 0){
alert("Please enter a radius.");
return;
}
if(vm.radius<=0){
alert("Radius must be greater than 0.");
return;
}
cacheAddress(placeId, lat, lng, address,vm.radius);
}
} $scope.showPosition = function (position) {
$scope.lat = position.coords.latitude;
$scope.lng = position.coords.longitude;
$scope.accuracy = position.coords.accuracy;
$scope.$apply();
$.ajax({
url: 'http://maps.google.com/maps/api/geocode/json?latlng='+$scope.lat+','+$scope.lng+'&language=en&sensor=false',
data: {},
dataType:'JSON',
success:function(data){
fn.callBack(data);
}
}); } $scope.showError = function (error) {
switch (error.code) {
case error.PERMISSION_DENIED:
$scope.error = "User denied the request for Geolocation."
break;
case error.POSITION_UNAVAILABLE:
$scope.error = "Location information is unavailable."
break;
case error.TIMEOUT:
$scope.error = "The request to get user location timed out."
break;
case error.UNKNOWN_ERROR:
$scope.error = "An unknown error occurred."
break;
}
$scope.$apply();
} $scope.getLocation = function () {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition($scope.showPosition, $scope.showError);
}
else {
$scope.error = "Geolocation is not supported by this browser.";
}
}
fn.locationMe=function(){
/*$scope.coords = geolocation.getLocation().then(function(data){
return {lat:data.coords.latitude, lng:data.coords.longitude};
});*/
/*console.log($scope.coords);31.2989513,121.5150925*/
$scope.getLocation();
} 3.总结:原文参考:http://blog.csdn.net/x1135768777/article/details/8156048 根据地址解析
https://maps.google.com/maps/api/geocode/json?address=chaoyango&sensor=true

根据经纬度解析

https://maps.googleapis.com/maps/api/geocode/json?latlng=39.988350,116.417152&sensor=true

传入起始经纬度得到路线

http://maps.google.com/maps/api/directions/json?origin=39.988350,116.417152&destination=39.999350,116.417152&sensor=true

or

https://maps.google.com/maps/api/directions/json?origin=罗马花园&destination=中关村&mode=driving&sensor=true

在线路中使用路标(从立水桥到朝阳罗马花园但是要经过知春路和鸟巢)

https://maps.googleapis.com/maps/api/directions/json?origin=立水桥&destination=朝阳罗马花园&waypoints=知春路|鸟巢&sensor=true

api:https://developers.google.com/maps/documentation/directions/?hl=zh-cn#Waypoints

google地图多地点线路查询

http://ditu.google.cn/maps?f=d&source=s_d&saddr=昌平&daddr=立水桥+to:知春路+to:天安门+to:西单+to:中关村&hl=zh-CN&geocode=china

根据placeId得到相关信息

https://maps.googleapis.com/maps/api/geocode/json?key=AIzaSyBVovr-ihWlP9N7rCCVDuNABKeCVR7xX8Y&place_id=ChIJByP4k1NYwokR7WYV3pZo1fc&sensor=true

java google map : http://blog.csdn.net/qiuzhping/article/details/39697111

angularjs-googleMap googleMap api地址解析与反解析的更多相关文章

  1. 【百度地图API】如何进行地址解析与反地址解析?——模糊地址能搜索到精确地理信息!

    原文:[百度地图API]如何进行地址解析与反地址解析?--模糊地址能搜索到精确地理信息! 摘要: 什么是地址解析? 什么是反地址解析? 如何运用地址解析,和反地址解析? 可以同时运用地址解析,和反地址 ...

  2. 谷歌地图地理解析和反解析geocode.geocoder详解

    地址解析就是将地址(如:贵州省贵阳市)转换为地理坐标(如经度:106.71,纬度:26.57)的过程. 地理反解析和上面的过程相反是将地理坐标(如纬度:26.57,经度:106.71)转换为地址(中国 ...

  3. 谷歌地图地理解析和反解析geocode.geocoder详解(转)

    谷歌地图地理解析和反解析geocode.geocoder详解 谷歌Geocoder服务 实例代码 地址解析就是将地址(如:贵州省贵阳市)转换为地理坐标(如经度:106.71,纬度:26.57)的过程. ...

  4. DNS正、反解析查询指令host、dig、nslookup

    一.host指令格式:host [-a] FQDN [server] host -l domain [server]选项:-a :代表列出该主机所有的相关信息,包括 IP.TTL 与除错讯息等等-l ...

  5. java枚举变量反解析用法

    最近常常有一些项目需要给枚举设值一个int值,以及对int值进行反解析出枚举类型,代码如下: public enum MatchResultEnum { /** * 赢 */ WIN(0), /** ...

  6. 【001】JS解析,反解析XML的一些问题

    JS解析,反解析 XML 的一些问题 2016-03-25 15:38:28 星期五 文章底部下面有提供把 字符串 变成 XML 对象的方法. 该方法,在 Chrome48 ,FireFox ,IE1 ...

  7. MySQL binlog反解析

    反解析delete语句 背景:delete table忘了加条件导致整张表被删除 恢复方式:直接从binlog里反解析delete语句为insert进行恢复 导出删指定表的DELETE语句: # my ...

  8. Python调用百度地图API实现批量经纬度转换为实际省市地点(api调用,json解析,excel读取与写入)

    1.获取秘钥 调用百度地图API实现得申请百度账号或者登陆百度账号,然后申请自己的ak秘钥.链接如下:http://lbsyun.baidu.com/apiconsole/key?applicatio ...

  9. Spring中AOP相关的API及源码解析

    Spring中AOP相关的API及源码解析 本系列文章: 读源码,我们可以从第一行读起 你知道Spring是怎么解析配置类的吗? 配置类为什么要添加@Configuration注解? 谈谈Spring ...

随机推荐

  1. MYSQL常用命令集合

    1.导出整个数据库 mysqldump -u 用户名 -p --default-character-set=latin1 数据库名 > 导出的文件名(数据库默认编码是latin1) mysqld ...

  2. win7 下与mac虚拟机的共享文件的建立

    1. 确保针对Mac虚拟机的VMware Tools的安装 加载进入系统后,在mac里可看到安装和卸载vmware tools的两个图标(点开vmware tools磁盘),点安装的就可以了. 2. ...

  3. 【HDOJ】前三百留念

    4个月不到的时间,终于刷到了HDOJ前三百.肯定还不够,好多基本的算法还不了解.还得继续学习.以此留念,假期目标是前一百.

  4. inuitcss

    inuitcssa powerful, scalable, Sass-based, BEM, OOCSS framework.

  5. poj 2425 A Chess Game(SG函数)

    A Chess Game Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 3551   Accepted: 1440 Desc ...

  6. DBI接口和DPI接口的区别

    1)DBI接口 A,也就是通常所讲的MCU借口,俗称80 system接口.The lcd interface between host processor and LCM device list a ...

  7. 基础排序算法之并归排序(Merge Sort)

    并归排序是学习分治法 (Merge Sort) 的好例子.而且它相对于选择,插入,冒泡排序来说,算法性能有一定提升.我首先会描述要解决的问题,并给出一个并归排序的例子.之后是算法的思路以及给出伪代码. ...

  8. java 哈希码

    加入新的元素到数组中 /** * Append the given object to the given array, returning a new array * consisting of t ...

  9. 数据分析:Weka,Matlab,R,SPSS,SAS等分析软件的入门

    1 功能角度 weka是机器学习方面的工具(开源).spss是数学工具(商业工具). 具体的说,weka的主要功能是模式分类,或者模式识别或者回归.包括特征的降维(PCA),特征选择,训练模型以及对测 ...

  10. xCode里面设置NSZombieEnabled定位错误

    打开product ->scheme->Edit scheme