git пре 6 година
родитељ
комит
49686f432b
6 измењених фајлова са 54 додато и 41 уклоњено
  1. 2 2
      config/config.js
  2. 0 19
      data/maplist.js
  3. 1 1
      pages/amap/amap.js
  4. 1 1
      pages/amap/navigation/navigation.css
  5. 43 15
      pages/amap/navigation/navigation.js
  6. 7 3
      scripts/index.js

+ 2 - 2
config/config.js

@@ -1,7 +1,7 @@
 var config = {
     //webapi: 'http://localhost:31173/'// 后台地址
 	//webapi: 'http://www.renlian.cn/admsapi/'
-	webapi: 'http://czapp.rltest.cn'
-	// webapi: 'http://czapi.zgjtgs.com'
+	// webapi: 'http://czapp.rltest.cn'
+	webapi: 'http://czapi.zgjtgs.com'
 	//webapi: 'http://hfczapi.renlianiot.com'
 };

+ 0 - 19
data/maplist.js

@@ -1,19 +0,0 @@
-var mapList = [
-    {
-        value: "com.baidu.BaiduMap",
-        text: "百度地图",
-    },
-    {
-        value: "com.autonavi.minimap",
-        text: "高德地图",  
-    },
-    {
-        value: "com.tencent.map",
-        text: "腾讯地图",  
-    },
-    {
-        value: "com.google.android.apps.maps",
-        text: "谷歌地图",  
-    }
-];
-

+ 1 - 1
pages/amap/amap.js

@@ -462,7 +462,7 @@
                             infoWindow.open(mainMap, lnglat);
                             console.log(infoWindow.get$Container());
                             infoWindow.get$Container().on('click', function(){
-                                renlian.nav.go({ path: 'amap/navigation', title: '导航', isBack: true, isHead: true, param: startEnd});
+                                renlian.nav.go({ path: 'amap/navigation', title: '导航', isBack: true, isHead: true, param: {startEnd: startEnd, endAddress: address}});
                                 if(infoWindow){
                                     infoWindow.close( );
                                 }

+ 1 - 1
pages/amap/navigation/navigation.css

@@ -35,7 +35,7 @@
     border-radius: 5px;
     border: solid 1px darkgray;
     display: flex;
-    padding: 2px;
+    padding: 3px 2px 2px 2px;
     justify-content: center;
     align-items: center;
 }

+ 43 - 15
pages/amap/navigation/navigation.js

@@ -2,10 +2,32 @@
     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);//目的地纬度、经度。先纬度后经度
+            console.log('~~~~~~~~~~~~');
+            console.log(param);
+
+            var geocoder = null;
+
+            var originName='';//北四环东路 望和路
+            var origin = new Array();//origin[0]为纬度,origin[1]为经度
+            if(param.startEnd.start){
+                var start = param.startEnd.start;
+                origin = new Array(start.lat, start.lng)
+                if(!geocoder){
+                    geocoder = new AMap.Geocoder({
+                        radius: 50 
+                    });
+                }
+                
+                geocoder.getAddress(start, function(status, result) {
+                    if (status === 'complete' && result.regeocode) {
+                        var address = result.regeocode.formattedAddress;
+                        originName = address;
+                        
+                    }else{console.log(JSON.stringify(result))}
+                });
+            }
+			var destinationName = param.endAddress;
+			var destination=new Array(param.startEnd.end.lat, param.startEnd.end.lng);//目的地纬度、经度。先纬度后经度
             
             renlian.layer.loading(true, "加载数据中");
             //地图初始化
@@ -39,6 +61,10 @@
                 renlian.layer.loading(false);
                 
             });
+
+            if(!param.startEnd.start){
+                renlian.layer.toast('无法获取定位点');
+            }
             var riding = null;
 
             var userMarker = new AMap.Marker({icon: "./images/location.png", offset:new AMap.Pixel(-16, -16)});
@@ -50,9 +76,8 @@
                     autoFitView: true
                 }); 
             } 
-            param.start = [121.13, 30.33];
             //根据起终点坐标规划骑行路线
-            riding.search(param.start, param.end, function(status, result) {
+            riding.search(param.startEnd.start, param.startEnd.end, function(status, result) {
                 // result即是对应的骑行路线数据信息,相关数据结构文档请参考  https://lbs.amap.com/api/javascript-api/reference/route-search#m_RidingResult
                 if (status === 'complete') {
                     // renlian.layer.toast('绘制骑行路线完成:');
@@ -101,7 +126,7 @@
             
 
 
-            var geocoder = null;
+            
             var locationAuto = setInterval(function(){
                 if($('.f-page').length < 2){
                     clearTimeout(locationAuto);
@@ -115,11 +140,11 @@
                             radius: 50 
                         });
                     }
-                    console.log('dd');
-
+                    origin = new Array(lnglat.lat, lnglat.lng);
                     geocoder.getAddress(lnglat, function(status, result) {
                         if (status === 'complete' && result.regeocode) {
-                            address = result.regeocode.formattedAddress;
+                            var address = result.regeocode.formattedAddress;
+                            originName = address;
                             $('#navg-address').text(address);
                         }else{console.log(JSON.stringify(result))}
                     });
@@ -159,14 +184,17 @@
 				});
             }
 
-            // $('#daohang-button').on('tap', function(){
-                
-            // });
-            
             $('#daohang-button').rlpicker({
                 data: mapList
             },function(map){
+                renlian.layer.toast(JSON.stringify(originName));
                 appAvailability.check(map,function () {//success callback
+                    if(!origin){
+                        renlian.layer.toast('无法获取定位点');
+                        return;
+                    }
+                    
+                    
 					if(map == 'com.baidu.BaiduMap'){
                         checkBaidu();
                     }
@@ -180,7 +208,7 @@
                         checkGuge();
                     }
 				},function () {//
-					renlian.layer.msg('未检测到该地图应用');
+					renlian.layer.warning('未检测到安装了该地图应用', function () { }, '提示', '确定');
 				});
             });
 

+ 7 - 3
scripts/index.js

@@ -48,11 +48,15 @@
 	
 	//APP权限申请
 	function requestPermission(){
-		var Permission = window.plugins.Permission;
-		if(!Permission){
-			console.log('window.plugins.Permission not installed!');
+		if(typeof(window.plugins) == 'undefined'){
+			console.log('window.plugins not defined!');
 			return;
 		}
+		if(typeof(window.plugins.Permission) == 'undefined'){
+			console.log('window.plugins.Permission not defined!');
+			return;
+		}
+		var Permission = window.plugins.Permission ;
 		
 		var permissions = [
 			'android.permission.ACCESS_FINE_LOCATION'//获取GPS定位权限