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. Greg and Array

    Codeforces Round #179 (Div. 2) C:http://codeforces.com/problemset/problem/296/C 题意:给你一个序列,然后有两种操作,第一 ...

  2. ServletContextListener作用(转)

    ServletContext 被 Servlet 程序用来与 Web 容器通信.例如写日志,转发请求.每一个 Web 应用程序含有一个Context,被Web应用内的各个程序共享.因为Context可 ...

  3. 使用HttpServletRequestWrapper在filter修改request参数

    javax.servlet.ServletRequest中的 Map<String, String[]> parameterMap = request.getParameterMap(); ...

  4. 【HDOJ】2888 Check Corners

    二维RMQ. /* 2888 */ #include <iostream> #include <algorithm> #include <cstdio> #incl ...

  5. BZOJ3715: [PA2014]Lustra

    3715: [PA2014]Lustra Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 237  Solved: 149[Submit][Status ...

  6. Selenium API(C#)

    1 Fetching a Page driver.Url = "http://www.google.com"; 2 Locating UI Elements (WebElement ...

  7. JavaScript高级程序设计4.pdf

    虽然执行环境的类型总共只有两种——全局和局部(函数),但还有其他方法延长作用域链,有些语句可以在作用域链的前端临时增加一个变量对象,执行后会被移除try-catch语句的catch块和with语句 w ...

  8. UVa 10029 hash + dp

    题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  9. EXCEL VBA运行不显示系统提示

    Sub XXX() Application.DisplayAlerts = False '代码段 Application.DisplayAlerts = True End Sub 以下是MICROSO ...

  10. C# 应用正则表达式

    1.检测该字符串是否 带有字符“8”(类似sql语句:select * from tableName where name like '%8%') string pattern = @"\w ...