首页
留言
关于
友链
更多
足迹
Search
1
SpringMVC+Spring+MyBatis整合完整版Web实例(附数据)
2,914 阅读
2
关于在Flutter实现Google地图的方法
1,888 阅读
3
druid报异常 “sql injection violation, part alway true condition not allow”的解决方案
1,381 阅读
4
git删除remote
1,347 阅读
5
MyBatis的TooManyResultsException异常的解决办法
1,151 阅读
发现
技术
生活
户外
登录
Search
标签搜索
Git
JavaScript
Flutter
Oracle
Git学习
Java
MySQL
SQL Server
秦岭户外
IntelliJ IDEA
Spring Boot
Flutter 2.0
对称加密算法
Google地图
Maven
ES6
linux
Tomcat
Redis
Spring
Bai Keyang
累计撰写
288
篇文章
累计收到
277
条评论
首页
栏目
发现
技术
生活
户外
页面
留言
关于
友链
足迹
搜索到
4
篇与
Google地图
的结果
2017-05-19
Google地图实现路线规划(JavaScript)
关于谷歌地图实现地图路线规划的功能,具体实现代码如下:Html代码:<body onload="initMap()"> <div id="map_canvas" style="height:90%;top:30px"></div> </body>JS代码:<script language="javascript" type="text/javascript"> function initMap() { var initAddr = {lat: 31.230416, lng: 121.473701}; var destAddr = {lat: 32.230416, lng: 120.47370}; var map = new google.maps.Map(document.getElementById('map_canvas'), { center: initAddr, scrollwheel: false, zoom: 7 }); var directionsDisplay = new google.maps.DirectionsRenderer({ map: map }); // Set destination, origin and travel mode. var request = { origin: initAddr, destination: destAddr, travelMode: google.maps.TravelMode.DRIVING }; // Pass the directions request to the directions service. var directionsService = new google.maps.DirectionsService(); directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { // Display the route on the map. directionsDisplay.setDirections(response); } }); } </script>根据自己项目的需要,根据上面代码的具体实现,封装上面代码。
2017年05月19日
253 阅读
0 评论
0 点赞
2017-05-17
Google地图经纬度纠偏
Google地图经纬度纠偏:通常在项目中,GPS经纬度不会直接使用,需要进行一些经纬度的纠偏才可以在对应的地图上使用。/** * gps纠偏算法,适用于google,高德体系的地图 * @author Administrator */ public class GpsCorrect { final static double pi = 3.14159265358979324; final static double a = 6378245.0; final static double ee = 0.00669342162296594323; public static void transform(double wgLat, double wgLon, double[] latlng) { if (outOfChina(wgLat, wgLon)) { latlng[0] = wgLat; latlng[1] = wgLon; return; } double dLat = transformLat(wgLon - 105.0, wgLat - 35.0); double dLon = transformLon(wgLon - 105.0, wgLat - 35.0); double radLat = wgLat / 180.0 * pi; double magic = Math.sin(radLat); magic = 1 - ee * magic * magic; double sqrtMagic = Math.sqrt(magic); dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi); dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi); latlng[0] = wgLat + dLat; latlng[1] = wgLon + dLon; } private static boolean outOfChina(double lat, double lon) { if (lon < 72.004 || lon > 137.8347) return true; if (lat < 0.8293 || lat > 55.8271) return true; return false; } private static double transformLat(double x, double y) { double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x)); ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0; ret += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y / 3.0 * pi)) * 2.0 / 3.0; ret += (160.0 * Math.sin(y / 12.0 * pi) + 320 * Math.sin(y * pi / 30.0)) * 2.0 / 3.0; return ret; } private static double transformLon(double x, double y) { double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x)); ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0; ret += (20.0 * Math.sin(x * pi) + 40.0 * Math.sin(x / 3.0 * pi)) * 2.0 / 3.0; ret += (150.0 * Math.sin(x / 12.0 * pi) + 300.0 * Math.sin(x / 30.0 * pi)) * 2.0 / 3.0; return ret; } }以上针对Google地图经纬度的纠偏,仅供参考。
2017年05月17日
283 阅读
0 评论
0 点赞
2017-03-20
Google地图地理编码互转实现
谷歌地图利用JS实现经纬度和地理位置之间相互转换的实现google.maps.Geocoder地理编码是将地址(如“1600 Amphitheatre Parkway, Mountain View, CA”)转换为地理坐标(如纬度 37.423021 和经度 -122.083739)的过程。 核心代码:/** * 经纬度转地理位置 */ $('#map_latlng_to_address').click(function () { var myLatlng = new google.maps.LatLng(34.2435947296974, 108.95278930664062); var geocoder = new google.maps.Geocoder(); geocoder.geocode( { 'location': myLatlng}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { notificationGo("消息提示", "经纬度转地理位置:" + results[0].formatted_address); } else { alert('Geocode was not successful for the following reason: ' + status); } }); }); 效果: 反向地理编码是将地理坐标转换为可人工读取的地址的过程。Google Maps Geocoding API 的反向地理编码服务还可让您找到对应于给定的地点 ID 的地址。 核心代码:/** * 地理位置转经纬度 */ $('#map_address_to_latlng').click(function () { var address = "中国陕西省西安市碑林区二环路沿线商业经济带南郭路31号"; var geocoder = new google.maps.Geocoder(); geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { notificationGo("消息提示", "地理位置转经纬度:" + results[0].geometry.location.lat()+' , '+results[0].geometry.location.lng()); } else { alert('Geocode was not successful for the following reason: ' + status); } }); }); 效果: 注:以上代码中,notificationShow() 是一个自己封装的输出方法,功能 类似与 alert()WebService的调用URL:请求 http://maps.google.cn/maps/api/geocode/json 或 http://maps.google.cn/maps/api/geocode/xml 并附带响应的参数。下面这两个地址,可以直接在浏览器的地址栏中输入出现结果:http://maps.google.cn/maps/api/geocode/json?latlng=34.2435947296974, 108.95278930664062&language=zh-CN&sensor=false这个就是 经纬度转地址http://maps.google.cn/maps/api/geocode/json?address=西安市丈八一路绿地SOHO A座&language=zh-CN&sensor=false这个就是 地址转经纬度更多关于谷歌地图地理编码的资料,可以查阅官方的API:https://developers.google.cn/maps/documentation/geocoding/intro
2017年03月20日
253 阅读
0 评论
0 点赞
2017-02-24
Google地图实现FitView自适应显示多个覆盖物
在高德地图中自适应显示多个覆盖物可使用setFitView(overlayList:Array) 。根据地图上添加的覆盖物分布情况,自动缩放地图到合适的视野级别,参数overlayList默认为当前地图上添加的所有覆盖物图层。而在Google地图中没有提供 自适应显示多个覆盖物 方法的实现。如果想要达到该效果,那么就需要手动去实现。var overlays = getOverlay();// 获取地图上的所有覆盖物对象(前提是,覆盖物都已经在地图上定义完成) var bounds = new google.maps.LatLngBounds(); for(var i=0;i<overlays.length;i++){ bounds.extend(overlays[i].getPosition()); } map.fitBounds(bounds);在 google.maps.LatLngBounds 类中,extend(point:LatLng | LatLngLiteral) :Extends this bounds to contain the given point.在 google.maps.Map 类中:fitBounds(bounds:LatLngBounds | LatLngBoundsLiteral):Sets the viewport to contain the given bounds.
2017年02月24日
476 阅读
0 评论
0 点赞