angularjs-googleMap googleMap api地址解析与反解析
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地址解析与反解析的更多相关文章
- 【百度地图API】如何进行地址解析与反地址解析?——模糊地址能搜索到精确地理信息!
原文:[百度地图API]如何进行地址解析与反地址解析?--模糊地址能搜索到精确地理信息! 摘要: 什么是地址解析? 什么是反地址解析? 如何运用地址解析,和反地址解析? 可以同时运用地址解析,和反地址 ...
- 谷歌地图地理解析和反解析geocode.geocoder详解
地址解析就是将地址(如:贵州省贵阳市)转换为地理坐标(如经度:106.71,纬度:26.57)的过程. 地理反解析和上面的过程相反是将地理坐标(如纬度:26.57,经度:106.71)转换为地址(中国 ...
- 谷歌地图地理解析和反解析geocode.geocoder详解(转)
谷歌地图地理解析和反解析geocode.geocoder详解 谷歌Geocoder服务 实例代码 地址解析就是将地址(如:贵州省贵阳市)转换为地理坐标(如经度:106.71,纬度:26.57)的过程. ...
- DNS正、反解析查询指令host、dig、nslookup
一.host指令格式:host [-a] FQDN [server] host -l domain [server]选项:-a :代表列出该主机所有的相关信息,包括 IP.TTL 与除错讯息等等-l ...
- java枚举变量反解析用法
最近常常有一些项目需要给枚举设值一个int值,以及对int值进行反解析出枚举类型,代码如下: public enum MatchResultEnum { /** * 赢 */ WIN(0), /** ...
- 【001】JS解析,反解析XML的一些问题
JS解析,反解析 XML 的一些问题 2016-03-25 15:38:28 星期五 文章底部下面有提供把 字符串 变成 XML 对象的方法. 该方法,在 Chrome48 ,FireFox ,IE1 ...
- MySQL binlog反解析
反解析delete语句 背景:delete table忘了加条件导致整张表被删除 恢复方式:直接从binlog里反解析delete语句为insert进行恢复 导出删指定表的DELETE语句: # my ...
- Python调用百度地图API实现批量经纬度转换为实际省市地点(api调用,json解析,excel读取与写入)
1.获取秘钥 调用百度地图API实现得申请百度账号或者登陆百度账号,然后申请自己的ak秘钥.链接如下:http://lbsyun.baidu.com/apiconsole/key?applicatio ...
- Spring中AOP相关的API及源码解析
Spring中AOP相关的API及源码解析 本系列文章: 读源码,我们可以从第一行读起 你知道Spring是怎么解析配置类的吗? 配置类为什么要添加@Configuration注解? 谈谈Spring ...
随机推荐
- 【CF】244C Checkposts
题目需要求啥很明确了.主要思想是先计算机联通块,然后每个块内找到一个最小值(以及该值的次数).最小值和结果1,次数乘积为结果2.联通块tarjan可解. /* 427C */ #include < ...
- 笔记-人老了-github
其实GITHUB是很不错的,虽然之前的JD泄露那件事情,后果很严重. 但是作为个人使用很不错的. github使用入门: 1:申请一个帐号 2:github使用ssh推送的.(ssh走的是加密) 所以 ...
- jdk+tomcat+mysql搭建网站无法打开
我们webwall的测试网站凌云论坛,是我之前用jdk-6u5-windows-i586-p.exe+apachetomcat6+mysql-essential-5.1.40-win32.msi搭建的 ...
- Selenium API(C#)
1 Fetching a Page driver.Url = "http://www.google.com"; 2 Locating UI Elements (WebElement ...
- VS 2010不显示头文件源文件和所有以前分类的文件夹,*.h 和*.cpp都显示在同一个文件
打开VS后不显示头文件源文件和所有以前分类的文件夹,*.h 和*.cpp都显示在同一个文件 点击右图红色指示显示所有文件夹按钮,就能恢复.
- MyEclipse中web服务器的三种配置方式
初学Javaweb开发的人们都会遇到一个问题,就是服务器环境的搭建配置问题.下面介绍三种服务器的搭建方式. 直接修改server.xml文件 当你写了一个web应用程序(jsp/servlet),想通 ...
- 2015/11/06 社保查询系统持续 挂机ing
- The Doors - POJ 1556 (线段相交)
题目大意:有一个房间(左上角(0,10),右下角(10,0)),然后房间里有N面墙,每面墙上都有两个门,求出来从初始点(0,5),到达终点(10,5)的最短距离. 分析:很明显根据两点之间直线最短 ...
- Redis学习记录之Java中的初步使用
1.关于Redis redis下载地址:<span style="font-family: Arial, Helvetica, sans-serif;">http:// ...
- jquery 的小角落
最近换了工作,在这家公司里,使用了大量的jQuery,闲来无事看看锋利的jQuery,发现好多边边角角的选择器,却能省去一大堆逻辑上的的代码,废话不多说直接上代码. #### jquery 对象与do ...