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 ...
随机推荐
- 【 POJ - 1204 Word Puzzles】(Trie+爆搜|AC自动机)
Word Puzzles Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 10782 Accepted: 4076 Special ...
- Bitmap介绍
转自:http://blog.csdn.net/xgdofull/article/details/5424611 简单的说就是用数组存放若有数据就标志为1或true,若不存在标志为0或false.比如 ...
- 14.6.4 Configuring the Memory Allocator for InnoDB 配置InnoDB 内存分配器
14.6.4 Configuring the Memory Allocator for InnoDB 配置InnoDB 内存分配器 当InnoDB 被开发时,内存分配提供了操作系统和 run-time ...
- 【转】iOS开发入门:Xcode常用快捷键
原文网址:http://www.3g-edu.org/ios_free/3G-89.htm Xcode有许多快捷键,这些快捷键在Xcode的工具栏里都有标注,学会使用这些快捷键可以大大的提高你的编程效 ...
- 最大流算法---Edmond-Karp
这个算法是基于FF方法,就是通过不断求残余网络的增广路来增广流量,直到找不到增广路为止.注意:每次找到增广路以后都要更新原网络.EK算法通过BFS寻找源S到汇T的一条最短路径,因此时间复杂度是O(VE ...
- [转]让程序在崩溃时体面的退出之Dump文件
原文地址:http://blog.csdn.net/starlee/article/details/6630816 在我的那篇<让程序在崩溃时体面的退出之CallStack>中提供了一个在 ...
- CSS 属性 - 伪类和伪元素
CSS 伪类用于向某些选择器添加特殊的效果. CSS 伪元素用于将特殊的效果添加到某些选择器. 可以明确两点,第一两者都与选择器相关,第二就是添加一些“特殊”的效果.这里特殊指的是两者描述了其他 cs ...
- Google网页搜索
本博文的主要内容有 .Google网页搜索的介绍 .Google网页搜索的使用偏好设置 .Google网页搜索的普通搜索 .Google网页搜索的高级搜索 .Google高级搜索之一:布尔逻辑搜索 ...
- 如何设置win7系统的文件夹为系统文件,从而隐藏文件夹
1.如图所示,通过去掉勾选“隐藏受保护的操作系统文件(推荐)”和勾选“显示隐藏的文件.文件夹和驱动器”,可以查看系统所有文件
- mysql inner join,full outer join,left join,right jion
https://sites.google.com/site/349624yu/courses/mysql/mysqldbgjzcx inner join,full outer join,left jo ...