Переглянути джерело

Merge branch 'master' of http://gogs.jrhost.cn:4000/zmcoding/czapp

merge
git 5 роки тому
батько
коміт
e071dde987

+ 10 - 0
pages/amap/navigation_test/navigation.css

@@ -0,0 +1,10 @@
+ul{padding: 0;}
+.mapList{width:250px;overflow:hidden;text-align:center;list-style: none;margin: 20px auto;color: #000000;}
+.mapLi{
+	width:100%;background-color:#e2e2e2;font-size:18px;color:#000000;text-align: center;margin-bottom: 10px;display: none;padding:10px 0;
+}
+.map{
+   font-size:18px;color:#000000;padding:5px;list-style: none;display: inline;
+}
+.isValidate{padding: 10px 15px;background-color: #0bb59b;border-radius: 5px;border:0;box-shadow: none;outline: none;text-align: center;color:#ffffff;}
+.place{margin: 10px;}

+ 22 - 0
pages/amap/navigation_test/navigation.html

@@ -0,0 +1,22 @@
+<div class="navigation-layout" >
+    <h3>设定当前位置及目的地位置的经纬度及中文名称</h3>
+	<div class='place'>起始地:当前位置(北四环东路 望和路 纬度:39.98871 经度:116.43234)</div>
+	<div class='place'>目的地:故宫博物馆(纬度:39.9168 经度:116.3908)</div>
+	<div><button class="isValidate" >检测你当前已安装的地图APP</button></div>
+	<h3>通过手机地图APP导航:</h3>
+	<ul class="mapList">
+		<li  class="mapLi baidu">百度地图导航</li>
+		<li  class="mapLi gaode">高德地图导航</li><!-- 直接通过APP导航 -->
+		<li  class="mapLi tengxun">腾讯地图导航</li>
+		<li  class="mapLi google">谷歌地图导航</li>
+		<!-- <li onclick="checkGuge1()" class="mapLi">URL谷歌地图导航</li> -->
+	</ul>
+
+	<h3>通过浏览器导航:</h3>
+	<ul>
+		<li class="map baidu_browser">百度导航</li>
+		<li class="map gaode_browser">高德导航</li><!-- 直接通过url导航 -->
+		<li class="map tengxun_browser">腾讯导航</li>
+		<li class="map google_browser">谷歌导航</li>
+	</ul>
+</div>

+ 189 - 0
pages/amap/navigation_test/navigation.js

@@ -0,0 +1,189 @@
+(function () {
+    var map_load = "0";
+	var location_now = 'setting';
+	var vistor_page = 'profile';
+	var page = {
+        init: function ($page, param) {
+            
+            var originName='我的当前位置';//北四环东路 望和路
+			var origin = new Array(39.98871,116.43234);//origin[0]为纬度,origin[1]为经度
+			var destinationName = '故宫博物馆';
+			var destination=new Array(39.9168,116.3908);//目的地纬度、经度。先纬度后经度
+			function haveInstalledApp(){//通过包名判断app是否安装
+				var mapList = document.getElementsByClassName('mapLi');
+				var baiduPackageName = "com.baidu.BaiduMap";
+				var gaodePackageName = "com.autonavi.minimap";
+				var tengxunPackageName = "com.tencent.map";
+				var gugePackageName = "com.google.android.apps.maps";
+				appAvailability.check(baiduPackageName,function () {//success callback
+					mapList.item(0).style.display = 'block';
+				},function () {//
+					mapList.item(0).style.display = 'none';
+				});
+				appAvailability.check(gaodePackageName,function () {//success callback
+					mapList.item(1).style.display = 'block';
+				},function () {//
+					mapList.item(1).style.display = 'none';
+				});
+				appAvailability.check(tengxunPackageName,function () {//success callback
+					mapList.item(2).style.display = 'block';
+				},function () {//
+					mapList.item(2).style.display = 'none';
+
+				});
+				appAvailability.check(gugePackageName,function () {//success callback
+					mapList.item(3).style.display = 'block';
+					// mapList.item(4).style.display = 'block';
+				},function () {
+					mapList.item(3).style.display = 'none';
+					// mapList.item(4).style.display = 'none';
+				});
+			}
+			//已安装应用检测
+			haveInstalledApp();
+			
+			$page.find('.isValidate').on('tap', function () {
+				haveInstalledApp();
+			});
+			
+			//APP导航
+			$page.find('.baidu').on('tap', function () {
+				checkBaidu();
+			});
+			$page.find('.gaode').on('tap', function () {
+				checkGaode();
+			});
+			$page.find('.tengxun').on('tap', function () {
+				checkTengxun();
+			});
+			$page.find('.google').on('tap', function () {
+				checkGuge();
+			});
+			
+			//浏览器导航
+			$page.find('.baidu_browser').on('tap', function () {
+				goBaiduBrowser();
+			});
+			$page.find('.gaode_browser').on('tap', function () {
+				goGaodeBrowser();
+			});
+			$page.find('.tengxun_browser').on('tap', function () {
+				goTengxunBrowser();
+			});
+			$page.find('.google_browser').on('tap', function () {
+				goGugeBrowser();
+			});
+			
+			function checkBaidu(){ 
+				var sApp = startApp.set({ /* params */
+					"action":"ACTION_VIEW",
+					"category":"CATEGORY_DEFAULT",
+					"type":"text/css",
+					"package":"com.baidu.BaiduMap",
+					"uri":"baidumap://map/direction?origin=name:"+originName+"|latlng:"+origin[0]+","+origin[1]+"&destination=name:"+destinationName+"|latlng:"+destination[0]+","+destination[1]+"&mode=driving",
+					"flags":["FLAG_ACTIVITY_CLEAR_TOP","FLAG_ACTIVITY_CLEAR_TASK"],
+					"intentstart":"startActivity"
+				});
+				sApp.start(function() { /* success */
+					//alert("OK");
+				}, function(error) { /* fail */
+					alert(error);
+				});
+			}
+
+			function goBaiduBrowser(){
+				window.location.href="http://api.map.baidu.com/direction?origin=name:"+originName+"|latlng:"+origin[0]+","+origin[1]+"&destination=name:"+destinationName+"|latlng:"+destination[0]+","+destination[1]+"&mode=driving&region=北京&output=html&src=webapp.baidu.openAPIdemo";
+			}
+
+			function checkGaode(){
+				var sApp = startApp.set({ /* params */
+					"action":"ACTION_VIEW",
+					"category":"CATEGORY_DEFAULT",
+					"type":"text/css",
+					"package":"com.autonavi.minimap",
+					"uri":"amapuri://route/plan/?slat="+origin[0]+"&slon="+origin[1]+"&sname="+originName+"&dlat="+destination[0]+"&dlon="+destination[1]+"&dname="+destinationName+"&dev=0&t=0",
+					"flags":["FLAG_ACTIVITY_CLEAR_TOP","FLAG_ACTIVITY_CLEAR_TASK"],
+					"intentstart":"startActivity"
+				});
+				sApp.start(function() { /* success */
+					//alert("OK");
+				}, function(error) { /* fail */
+					alert(error);
+				});
+			}
+			function goGaodeBrowser(){
+				window.location.href="http://uri.amap.com/navigation?from="+origin[1]+","+origin[0]+","+originName+"&to="+destination[1]+","+destination[0]+","+destinationName+"&mode=car&src=mypage&coordinate=gaode&callnative=1";
+
+			}
+			function checkTengxun(){
+				var sApp = startApp.set({ /* params */
+					"action":"ACTION_VIEW",
+					"category":"CATEGORY_DEFAULT",
+					"type":"text/css",
+					"package":"com.tencent.map",
+					"uri":"qqmap://map/routeplan?type=drive&from="+originName+"&fromcoord="+origin[0]+","+origin[1]+"&to="+destinationName+"&tocoord="+destination[0]+","+destination[1]+"&coord_type=1&policy=0",
+					"flags":["FLAG_ACTIVITY_CLEAR_TOP","FLAG_ACTIVITY_CLEAR_TASK"],
+					"intentstart":"startActivity"
+				});
+				sApp.start(function() { /* success */
+					//alert("OK");
+				}, function(error) { /* fail */
+					alert(error);
+				});
+			}
+
+			function goTengxunBrowser(){
+				window.location.href="http://apis.map.qq.com/uri/v1/routeplan?type=drive&from="+originName+"&fromcoord="+origin[0]+","+origin[1]+"&to="+destinationName+"&tocoord="+destination[0]+","+destination[1]+"&policy=1&referer=mapAPP";
+			}
+			function checkGuge(){//指定终点经纬度,默认当前位置
+				var sApp = startApp.set({ /* params */
+					"action":"ACTION_VIEW",
+					"category":"CATEGORY_DEFAULT",
+					"type":"text/css",
+					"package":"com.google.android.apps.maps",
+					"uri":"google.navigation:q="+destination[0]+","+destination[1],
+					"flags":["FLAG_ACTIVITY_CLEAR_TOP","FLAG_ACTIVITY_CLEAR_TASK"],
+					"intentstart":"startActivity"
+				});
+				sApp.start(function() { /* success */
+					//alert("OK");
+				}, function(error) { /* fail */
+					alert(error);
+				});
+			}
+
+			function checkGuge1(){//指定起点、终点经纬度
+				var sApp = startApp.set({
+					"action":"ACTION_VIEW",
+					"category":"CATEGORY_DEFAULT",
+					"type":"text/css",
+					"package":"com.google.android.apps.maps",
+					"uri":"https://www.google.com/maps/dir/?api=1&destination="+destination[0]+","+destination[1]+"&travelmode=driving",
+					"flags":["FLAG_ACTIVITY_CLEAR_TOP","FLAG_ACTIVITY_CLEAR_TASK"],
+					"intentstart":"startActivity"
+				});
+				sApp.start(function() {
+
+				}, function(error) { /* fail */
+					alert(error);
+				});
+			}
+
+			function goGugeBrowser(){//指定起点、终点经纬度
+				//window.location.href="https://www.google.com/maps/dir/?api=1&origin=Space+Needle+Seattle+WA&destination=Pike+Place+Market+Seattle+WA&travelmode=bicycling";
+
+			   // window.location.href="https://www.google.com/maps/dir/?api=1&destination=39.9761,116.3282&travelmode=driving";
+
+				window.location.href="https://www.google.com/maps/dir/?api=1&origin="+origin[0]+","+origin[1]+"&destination="+destination[0]+","+destination[1]+"&travelmode=driving";
+
+			}
+            
+        },
+
+        reload:function(pageinfo){
+            console.log('testsfadfasd')
+        }
+    };
+
+    return page;
+})();