(function () { var page = { init: function ($page, param) { renlian.layer.loading(true, "加载数据中"); //地图初始化 var map = new AMap.Map("navigation-map", { resizeEnable: true, center: [113.955439, 22.542956],//地图中心点 zoom: 12 //地图显示的缩放级别 }); map.on('complete', function(){ renlian.layer.loading(false); }); var riding = null; var userMarker = new AMap.Marker({icon: "./images/location.png", offset:new AMap.Pixel(-16, -16)}); //骑行导航 if(!riding){ var riding = new AMap.Riding({ map: map, autoFitView: true }); } //根据起终点坐标规划骑行路线 riding.search(param.start, param.end, function(status, result) { // result即是对应的骑行路线数据信息,相关数据结构文档请参考 https://lbs.amap.com/api/javascript-api/reference/route-search#m_RidingResult if (status === 'complete') { // renlian.layer.toast('绘制骑行路线完成:'); } else { renlian.layer.toast('骑行路线数据查询失败:' + result); } }); var presentLnglat = null; function get_mobile_gps_location(onSuccess,onError){ var onSuccess = function(position) { // alert('Latitude: ' + position.coords.latitude + '\n' + // 'Longitude: ' + position.coords.longitude + '\n' + // 'Altitude: ' + position.coords.altitude + '\n' + // 'Accuracy: ' + position.coords.accuracy + '\n' + // 'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' + // 'Heading: ' + position.coords.heading + '\n' + // 'Speed: ' + position.coords.speed + '\n' + // 'Timestamp: ' + position.timestamp + '\n'); presentLnglat = new AMap.LngLat(position.coords.longitude, position.coords.latitude); userMarker.setPosition(presentLnglat); userMarker.setMap(map); }; // onError Callback receives a PositionError object // function onError(error) { console.log('code: ' + error.code + '\n' + 'message: ' + error.message + '\n'); } navigator.geolocation.getCurrentPosition(onSuccess, onError); } var geocoder = null; var locationAuto = setInterval(function(){ if($('.f-page').length < 2){ clearTimeout(locationAuto); } if(!window.lrmui.isreal){ get_mobile_gps_location(); var lnglat = presentLnglat; // var lnglat = [113.951104,22.542902]; if(!geocoder){ geocoder = new AMap.Geocoder({ radius: 50 }); } console.log('dd'); geocoder.getAddress(lnglat, function(status, result) { if (status === 'complete' && result.regeocode) { address = result.regeocode.formattedAddress; $('#navg-address').text(address); }else{console.log(JSON.stringify(result))} }); } }, 10000); }, reload:function(pageinfo){ console.log('testsfadfasd') } }; return page; })();