├── .gitignore ├── README.md ├── app.js ├── app.json ├── app.wxss ├── img ├── mapicon_navi.png ├── mapicon_navi_e.png ├── mapicon_navi_s.png ├── marker.png ├── marker_checked.png └── markers.png ├── libs ├── amap-wx.js └── config.js └── pages ├── index ├── index.js ├── index.json ├── index.wxml └── index.wxss ├── inputtips ├── input.js ├── input.wxml └── input.wxss ├── navigation_bus ├── navigation.js ├── navigation.wxml └── navigation.wxss ├── navigation_car ├── navigation.js ├── navigation.wxml └── navigation.wxss ├── navigation_car_detail ├── navigation.js ├── navigation.wxml └── navigation.wxss ├── navigation_ride ├── navigation.js ├── navigation.wxml └── navigation.wxss ├── navigation_ride_detail ├── navigation.js ├── navigation.wxml └── navigation.wxss ├── navigation_walk ├── navigation.js ├── navigation.wxml └── navigation.wxss ├── navigation_walk_detail ├── navigation.js ├── navigation.wxml └── navigation.wxss ├── poi ├── poi.js ├── poi.json ├── poi.wxml └── poi.wxss ├── regeo ├── regeo.js ├── regeo.json ├── regeo.wxml └── regeo.wxss ├── staticmap ├── staticmap.js ├── staticmap.json ├── staticmap.wxml └── staticmap.wxss └── weather ├── weather.js ├── weather.json ├── weather.wxml └── weather.wxss /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | libs/amap-wechat.js -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ##微信小程序SDK DEMO 2 | 3 | ###微信小程序使用方法详见 http://lbs.amap.com/api/wx/summary -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | App({ 2 | onLaunch: function () { 3 | //调用API从本地缓存中获取数据 4 | var logs = wx.getStorageSync('logs') || [] 5 | logs.unshift(Date.now()) 6 | wx.setStorageSync('logs', logs) 7 | }, 8 | getUserInfo:function(cb){ 9 | var that = this; 10 | if(this.globalData.userInfo){ 11 | typeof cb == "function" && cb(this.globalData.userInfo) 12 | }else{ 13 | //调用登录接口 14 | wx.login({ 15 | success: function () { 16 | wx.getUserInfo({ 17 | success: function (res) { 18 | that.globalData.userInfo = res.userInfo; 19 | typeof cb == "function" && cb(that.globalData.userInfo) 20 | } 21 | }) 22 | } 23 | }); 24 | } 25 | }, 26 | globalData:{ 27 | userInfo:null 28 | } 29 | }) -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages":[ 3 | "pages/index/index", 4 | "pages/regeo/regeo", 5 | "pages/weather/weather", 6 | "pages/poi/poi", 7 | "pages/staticmap/staticmap", 8 | "pages/navigation_car/navigation", 9 | "pages/navigation_bus/navigation", 10 | "pages/navigation_walk/navigation", 11 | "pages/navigation_ride/navigation", 12 | "pages/navigation_car_detail/navigation", 13 | "pages/navigation_walk_detail/navigation", 14 | "pages/navigation_ride_detail/navigation", 15 | "pages/inputtips/input" 16 | 17 | ], 18 | "window":{ 19 | "backgroundTextStyle":"light", 20 | "navigationBarTitleText": "高德开放平台", 21 | "navigationBarTextStyle": "white" 22 | }, 23 | "networkTimeout":{ 24 | "request": 6000 25 | } 26 | } -------------------------------------------------------------------------------- /app.wxss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/wx-regeo-poiaround-weather/cfd11f8b01876988c9b1cbd679d14107cc3013aa/app.wxss -------------------------------------------------------------------------------- /img/mapicon_navi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/wx-regeo-poiaround-weather/cfd11f8b01876988c9b1cbd679d14107cc3013aa/img/mapicon_navi.png -------------------------------------------------------------------------------- /img/mapicon_navi_e.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/wx-regeo-poiaround-weather/cfd11f8b01876988c9b1cbd679d14107cc3013aa/img/mapicon_navi_e.png -------------------------------------------------------------------------------- /img/mapicon_navi_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/wx-regeo-poiaround-weather/cfd11f8b01876988c9b1cbd679d14107cc3013aa/img/mapicon_navi_s.png -------------------------------------------------------------------------------- /img/marker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/wx-regeo-poiaround-weather/cfd11f8b01876988c9b1cbd679d14107cc3013aa/img/marker.png -------------------------------------------------------------------------------- /img/marker_checked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/wx-regeo-poiaround-weather/cfd11f8b01876988c9b1cbd679d14107cc3013aa/img/marker_checked.png -------------------------------------------------------------------------------- /img/markers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amap-demo/wx-regeo-poiaround-weather/cfd11f8b01876988c9b1cbd679d14107cc3013aa/img/markers.png -------------------------------------------------------------------------------- /libs/amap-wx.js: -------------------------------------------------------------------------------- 1 | function AMapWX(a){this.key=a.key,this.requestConfig={key:a.key,s:"rsx",platform:"WXJS",appname:a.key,sdkversion:"1.2.0",logversion:"2.0"}}AMapWX.prototype.getWxLocation=function(a,b){wx.getLocation({type:"gcj02",success:function(a){var c=a.longitude+","+a.latitude;wx.setStorage({key:"userLocation",data:c}),b(c)},fail:function(c){wx.getStorage({key:"userLocation",success:function(a){a.data&&b(a.data)}}),a.fail({errCode:"0",errMsg:c.errMsg||""})}})},AMapWX.prototype.getRegeo=function(a){function c(c){var d=b.requestConfig;wx.request({url:"https://restapi.amap.com/v3/geocode/regeo",data:{key:b.key,location:c,extensions:"all",s:d.s,platform:d.platform,appname:b.key,sdkversion:d.sdkversion,logversion:d.logversion},method:"GET",header:{"content-type":"application/json"},success:function(b){var d,e,f,g,h,i,j,k,l;b.data.status&&"1"==b.data.status?(d=b.data.regeocode,e=d.addressComponent,f=[],g="",d&&d.roads[0]&&d.roads[0].name&&(g=d.roads[0].name+"附近"),h=c.split(",")[0],i=c.split(",")[1],d.pois&&d.pois[0]&&(g=d.pois[0].name+"附近",j=d.pois[0].location,j&&(h=parseFloat(j.split(",")[0]),i=parseFloat(j.split(",")[1]))),e.provice&&f.push(e.provice),e.city&&f.push(e.city),e.district&&f.push(e.district),e.streetNumber&&e.streetNumber.street&&e.streetNumber.number?(f.push(e.streetNumber.street),f.push(e.streetNumber.number)):(k="",d&&d.roads[0]&&d.roads[0].name&&(k=d.roads[0].name),f.push(k)),f=f.join(""),l=[{iconPath:a.iconPath,width:a.iconWidth,height:a.iconHeight,name:f,desc:g,longitude:h,latitude:i,id:0,regeocodeData:d}],a.success(l)):a.fail({errCode:b.data.infocode,errMsg:b.data.info})},fail:function(b){a.fail({errCode:"0",errMsg:b.errMsg||""})}})}var b=this;a.location?c(a.location):b.getWxLocation(a,function(a){c(a)})},AMapWX.prototype.getWeather=function(a){function d(d){var e="base";a.type&&"forecast"==a.type&&(e="all"),wx.request({url:"https://restapi.amap.com/v3/weather/weatherInfo",data:{key:b.key,city:d,extensions:e,s:c.s,platform:c.platform,appname:b.key,sdkversion:c.sdkversion,logversion:c.logversion},method:"GET",header:{"content-type":"application/json"},success:function(b){function c(a){var b={city:{text:"城市",data:a.city},weather:{text:"天气",data:a.weather},temperature:{text:"温度",data:a.temperature},winddirection:{text:"风向",data:a.winddirection+"风"},windpower:{text:"风力",data:a.windpower+"级"},humidity:{text:"湿度",data:a.humidity+"%"}};return b}var d,e;b.data.status&&"1"==b.data.status?b.data.lives?(d=b.data.lives,d&&d.length>0&&(d=d[0],e=c(d),e["liveData"]=d,a.success(e))):b.data.forecasts&&b.data.forecasts[0]&&a.success({forecast:b.data.forecasts[0]}):a.fail({errCode:b.data.infocode,errMsg:b.data.info})},fail:function(b){a.fail({errCode:"0",errMsg:b.errMsg||""})}})}function e(e){wx.request({url:"https://restapi.amap.com/v3/geocode/regeo",data:{key:b.key,location:e,extensions:"all",s:c.s,platform:c.platform,appname:b.key,sdkversion:c.sdkversion,logversion:c.logversion},method:"GET",header:{"content-type":"application/json"},success:function(b){var c,e;b.data.status&&"1"==b.data.status?(e=b.data.regeocode,e.addressComponent?c=e.addressComponent.adcode:e.aois&&e.aois.length>0&&(c=e.aois[0].adcode),d(c)):a.fail({errCode:b.data.infocode,errMsg:b.data.info})},fail:function(b){a.fail({errCode:"0",errMsg:b.errMsg||""})}})}var b=this,c=b.requestConfig;a.city?d(a.city):b.getWxLocation(a,function(a){e(a)})},AMapWX.prototype.getPoiAround=function(a){function d(d){var e={key:b.key,location:d,s:c.s,platform:c.platform,appname:b.key,sdkversion:c.sdkversion,logversion:c.logversion};a.querytypes&&(e["types"]=a.querytypes),a.querykeywords&&(e["keywords"]=a.querykeywords),wx.request({url:"https://restapi.amap.com/v3/place/around",data:e,method:"GET",header:{"content-type":"application/json"},success:function(b){var c,d,e,f;if(b.data.status&&"1"==b.data.status){if(b=b.data,b&&b.pois){for(c=[],d=0;d 2 | 地址解析 3 | 天气查询 4 | 周边兴趣点查询 5 | 静态图 6 | 出行路线规划 7 | -------------------------------------------------------------------------------- /pages/index/index.wxss: -------------------------------------------------------------------------------- 1 | .naviButton{ 2 | border: 1px solid #000; 3 | margin: 26px; 4 | padding: 6px 0; 5 | text-align: center; 6 | } -------------------------------------------------------------------------------- /pages/inputtips/input.js: -------------------------------------------------------------------------------- 1 | var amapFile = require('../../libs/amap-wx.js'); 2 | var config = require('../../libs/config.js'); 3 | var lonlat; 4 | var city; 5 | Page({ 6 | data: { 7 | tips: {} 8 | }, 9 | onLoad: function(e){ 10 | lonlat = e.lonlat; 11 | city = e.city; 12 | }, 13 | bindInput: function(e){ 14 | var that = this; 15 | var keywords = e.detail.value; 16 | var key = config.Config.key; 17 | var myAmapFun = new amapFile.AMapWX({key: key}); 18 | myAmapFun.getInputtips({ 19 | keywords: keywords, 20 | location: lonlat, 21 | city: city, 22 | success: function(data){ 23 | if(data && data.tips){ 24 | that.setData({ 25 | tips: data.tips 26 | }); 27 | } 28 | } 29 | }) 30 | }, 31 | bindSearch: function(e){ 32 | var keywords = e.target.dataset.keywords; 33 | var url = '../poi/poi?keywords=' + keywords; 34 | wx.redirectTo({ 35 | url: url 36 | }) 37 | } 38 | }) -------------------------------------------------------------------------------- /pages/inputtips/input.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {{i.name}} 6 | -------------------------------------------------------------------------------- /pages/inputtips/input.wxss: -------------------------------------------------------------------------------- 1 | .section{ 2 | height: 30px; 3 | width: 100%; 4 | } 5 | .section input{ 6 | width:90%; 7 | margin:5px auto; 8 | border:1px solid #c3c3c3; 9 | height:30px; 10 | border-radius: 3px; 11 | padding: 0 5px; 12 | } 13 | .text_box{ 14 | margin: 10px 25px; 15 | border-bottom:1px solid #c3c3c3; 16 | padding-bottom:10px 17 | } -------------------------------------------------------------------------------- /pages/navigation_bus/navigation.js: -------------------------------------------------------------------------------- 1 | var amapFile = require('../../libs/amap-wx.js'); 2 | var config = require('../../libs/config.js'); 3 | 4 | Page({ 5 | data: { 6 | markers: [{ 7 | iconPath: "../../img/mapicon_navi_s.png", 8 | id: 0, 9 | latitude: 39.989643, 10 | longitude: 116.481028, 11 | width: 23, 12 | height: 33 13 | },{ 14 | iconPath: "../../img/mapicon_navi_e.png", 15 | id: 0, 16 | latitude: 39.90816, 17 | longitude: 116.434446, 18 | width: 24, 19 | height: 34 20 | }], 21 | distance: '', 22 | cost: '', 23 | transits: [], 24 | polyline: [] 25 | }, 26 | onLoad: function() { 27 | var that = this; 28 | var key = config.Config.key; 29 | var myAmapFun = new amapFile.AMapWX({key: key}); 30 | myAmapFun.getTransitRoute({ 31 | origin: '116.481028,39.989643', 32 | destination: '116.434446,39.90816', 33 | city: '北京', 34 | success: function(data){ 35 | if(data && data.transits){ 36 | var transits = data.transits; 37 | for(var i = 0; i < transits.length; i++){ 38 | var segments = transits[i].segments; 39 | transits[i].transport = []; 40 | for(var j = 0; j < segments.length; j++){ 41 | if(segments[j].bus && segments[j].bus.buslines && segments[j].bus.buslines[0] && segments[j].bus.buslines[0].name){ 42 | var name = segments[j].bus.buslines[0].name 43 | if(j!==0){ 44 | name = '--' + name; 45 | } 46 | transits[i].transport.push(name); 47 | } 48 | } 49 | } 50 | } 51 | that.setData({ 52 | transits: transits 53 | }); 54 | 55 | }, 56 | fail: function(info){ 57 | 58 | } 59 | }) 60 | }, 61 | goToCar: function (e) { 62 | wx.redirectTo({ 63 | url: '../navigation_car/navigation' 64 | }) 65 | }, 66 | goToBus: function (e) { 67 | wx.redirectTo({ 68 | url: '../navigation_bus/navigation' 69 | }) 70 | }, 71 | goToRide: function (e) { 72 | wx.redirectTo({ 73 | url: '../navigation_ride/navigation' 74 | }) 75 | }, 76 | goToWalk: function (e) { 77 | wx.redirectTo({ 78 | url: '../navigation_walk/navigation' 79 | }) 80 | } 81 | }) -------------------------------------------------------------------------------- /pages/navigation_bus/navigation.wxml: -------------------------------------------------------------------------------- 1 | 2 | 驾车 3 | 步行 4 | 公交 5 | 骑行 6 | 7 | 8 | 9 | {{j}} 10 | 11 | 12 | -------------------------------------------------------------------------------- /pages/navigation_bus/navigation.wxss: -------------------------------------------------------------------------------- 1 | .flex-style{ 2 | display: -webkit-box; 3 | display: -webkit-flex; 4 | display: flex; 5 | } 6 | .flex-item{ 7 | height: 35px; 8 | line-height: 35px; 9 | text-align: center; 10 | -webkit-box-flex: 1; 11 | -webkit-flex: 1; 12 | flex: 1 13 | } 14 | .flex-item.active{ 15 | color:#0091ff; 16 | } 17 | .text_box{ 18 | margin: 0 15px; 19 | padding: 15px 0; 20 | border-bottom: 1px solid #c3c3c3; 21 | font-size: 13px; 22 | } 23 | .text_box .text_item{display:inline-block;line-height: 8px;} 24 | -------------------------------------------------------------------------------- /pages/navigation_car/navigation.js: -------------------------------------------------------------------------------- 1 | var amapFile = require('../../libs/amap-wx.js'); 2 | var config = require('../../libs/config.js'); 3 | 4 | Page({ 5 | data: { 6 | markers: [{ 7 | iconPath: "../../img/mapicon_navi_s.png", 8 | id: 0, 9 | latitude: 39.989643, 10 | longitude: 116.481028, 11 | width: 23, 12 | height: 33 13 | },{ 14 | iconPath: "../../img/mapicon_navi_e.png", 15 | id: 0, 16 | latitude: 39.90816, 17 | longitude: 116.434446, 18 | width: 24, 19 | height: 34 20 | }], 21 | distance: '', 22 | cost: '', 23 | polyline: [] 24 | }, 25 | onLoad: function() { 26 | var that = this; 27 | var key = config.Config.key; 28 | var myAmapFun = new amapFile.AMapWX({key: key}); 29 | myAmapFun.getDrivingRoute({ 30 | origin: '116.481028,39.989643', 31 | destination: '116.434446,39.90816', 32 | success: function(data){ 33 | var points = []; 34 | if(data.paths && data.paths[0] && data.paths[0].steps){ 35 | var steps = data.paths[0].steps; 36 | for(var i = 0; i < steps.length; i++){ 37 | var poLen = steps[i].polyline.split(';'); 38 | for(var j = 0;j < poLen.length; j++){ 39 | points.push({ 40 | longitude: parseFloat(poLen[j].split(',')[0]), 41 | latitude: parseFloat(poLen[j].split(',')[1]) 42 | }) 43 | } 44 | } 45 | } 46 | that.setData({ 47 | polyline: [{ 48 | points: points, 49 | color: "#0091ff", 50 | width: 6 51 | }] 52 | }); 53 | if(data.paths[0] && data.paths[0].distance){ 54 | that.setData({ 55 | distance: data.paths[0].distance + '米' 56 | }); 57 | } 58 | if(data.taxi_cost){ 59 | that.setData({ 60 | cost: '打车约' + parseInt(data.taxi_cost) + '元' 61 | }); 62 | } 63 | 64 | } 65 | }) 66 | }, 67 | goDetail: function(){ 68 | wx.navigateTo({ 69 | url: '../navigation_car_detail/navigation' 70 | }) 71 | }, 72 | goToCar: function (e) { 73 | wx.redirectTo({ 74 | url: '../navigation_car/navigation' 75 | }) 76 | }, 77 | goToBus: function (e) { 78 | wx.redirectTo({ 79 | url: '../navigation_bus/navigation' 80 | }) 81 | }, 82 | goToRide: function (e) { 83 | wx.redirectTo({ 84 | url: '../navigation_ride/navigation' 85 | }) 86 | }, 87 | goToWalk: function (e) { 88 | wx.redirectTo({ 89 | url: '../navigation_walk/navigation' 90 | }) 91 | } 92 | }) -------------------------------------------------------------------------------- /pages/navigation_car/navigation.wxml: -------------------------------------------------------------------------------- 1 | 2 | 驾车 3 | 步行 4 | 公交 5 | 骑行 6 | 7 | 8 | 9 | 10 | 11 | 12 | {{distance}} 13 | {{cost}} 14 | 详情 15 | -------------------------------------------------------------------------------- /pages/navigation_car/navigation.wxss: -------------------------------------------------------------------------------- 1 | .flex-style{ 2 | display: -webkit-box; 3 | display: -webkit-flex; 4 | display: flex; 5 | } 6 | .flex-item{ 7 | height: 35px; 8 | line-height: 35px; 9 | text-align: center; 10 | -webkit-box-flex: 1; 11 | -webkit-flex: 1; 12 | flex: 1 13 | } 14 | .flex-item.active{ 15 | color:#0091ff; 16 | } 17 | .map_box{ 18 | position:absolute; 19 | top: 35px; 20 | bottom: 90px; 21 | left: 0px; 22 | right: 0px; 23 | } 24 | #navi_map{ 25 | width: 100%; 26 | height: 100%; 27 | } 28 | .text_box{ 29 | position:absolute; 30 | height: 90px; 31 | bottom: 0px; 32 | left: 0px; 33 | right: 0px; 34 | } 35 | .text_box .text{ 36 | margin: 15px; 37 | } 38 | .detail_button{ 39 | position:absolute; 40 | bottom: 30px; 41 | right: 10px; 42 | padding: 3px 5px; 43 | color: #fff; 44 | background: #0091ff; 45 | width:50px; 46 | text-align:center; 47 | border-radius:5px; 48 | } -------------------------------------------------------------------------------- /pages/navigation_car_detail/navigation.js: -------------------------------------------------------------------------------- 1 | var amapFile = require('../../libs/amap-wx.js'); 2 | var config = require('../../libs/config.js'); 3 | 4 | Page({ 5 | data: { 6 | steps: {} 7 | }, 8 | onLoad: function() { 9 | var that = this; 10 | var key = config.Config.key; 11 | var myAmapFun = new amapFile.AMapWX({key: key}); 12 | myAmapFun.getDrivingRoute({ 13 | origin: '116.481028,39.989643', 14 | destination: '116.434446,39.90816', 15 | success: function(data){ 16 | if(data.paths && data.paths[0] && data.paths[0].steps){ 17 | that.setData({ 18 | steps: data.paths[0].steps 19 | }); 20 | } 21 | 22 | }, 23 | fail: function(info){ 24 | 25 | } 26 | }) 27 | } 28 | }) -------------------------------------------------------------------------------- /pages/navigation_car_detail/navigation.wxml: -------------------------------------------------------------------------------- 1 | 2 | {{i.instruction}} 3 | 4 | -------------------------------------------------------------------------------- /pages/navigation_car_detail/navigation.wxss: -------------------------------------------------------------------------------- 1 | .flex-style{ 2 | display: -webkit-box; 3 | display: -webkit-flex; 4 | display: flex; 5 | } 6 | .flex-item{ 7 | height: 35px; 8 | line-height: 35px; 9 | text-align: center; 10 | -webkit-box-flex: 1; 11 | -webkit-flex: 1; 12 | flex: 1 13 | } 14 | .flex-item.active{ 15 | color:#0091ff; 16 | } 17 | .text_box{ 18 | margin: 0 15px; 19 | padding: 15px 0; 20 | border-bottom: 1px solid #c3c3c3; 21 | font-size: 13px; 22 | } 23 | .text_box .text_item{display:inline-block;line-height: 8px;} 24 | -------------------------------------------------------------------------------- /pages/navigation_ride/navigation.js: -------------------------------------------------------------------------------- 1 | var amapFile = require('../../libs/amap-wx.js'); 2 | var config = require('../../libs/config.js'); 3 | 4 | Page({ 5 | data: { 6 | markers: [{ 7 | iconPath: "../../img/mapicon_navi_s.png", 8 | id: 0, 9 | latitude: 39.989643, 10 | longitude: 116.481028, 11 | width: 23, 12 | height: 33 13 | },{ 14 | iconPath: "../../img/mapicon_navi_e.png", 15 | id: 0, 16 | latitude: 39.90816, 17 | longitude: 116.434446, 18 | width: 24, 19 | height: 34 20 | }], 21 | distance: '', 22 | cost: '', 23 | polyline: [] 24 | }, 25 | onLoad: function() { 26 | var that = this; 27 | var key = config.Config.key; 28 | var myAmapFun = new amapFile.AMapWX({key: key}); 29 | myAmapFun.getRidingRoute({ 30 | origin: '116.481028,39.989643', 31 | destination: '116.434446,39.90816', 32 | success: function(data){ 33 | var points = []; 34 | if(data.paths && data.paths[0] && data.paths[0].steps){ 35 | var steps = data.paths[0].steps; 36 | for(var i = 0; i < steps.length; i++){ 37 | var poLen = steps[i].polyline.split(';'); 38 | for(var j = 0;j < poLen.length; j++){ 39 | points.push({ 40 | longitude: parseFloat(poLen[j].split(',')[0]), 41 | latitude: parseFloat(poLen[j].split(',')[1]) 42 | }) 43 | } 44 | } 45 | } 46 | that.setData({ 47 | polyline: [{ 48 | points: points, 49 | color: "#0091ff", 50 | width: 6 51 | }] 52 | }); 53 | if(data.paths[0] && data.paths[0].distance){ 54 | that.setData({ 55 | distance: data.paths[0].distance + '米' 56 | }); 57 | } 58 | if(data.taxi_cost){ 59 | that.setData({ 60 | cost: '打车约' + parseInt(data.taxi_cost) + '元' 61 | }); 62 | } 63 | 64 | }, 65 | fail: function(info){ 66 | 67 | } 68 | }) 69 | }, 70 | goDetail: function(){ 71 | wx.navigateTo({ 72 | url: '../navigation_ride_detail/navigation' 73 | }) 74 | }, 75 | goToCar: function (e) { 76 | wx.redirectTo({ 77 | url: '../navigation_car/navigation' 78 | }) 79 | }, 80 | goToBus: function (e) { 81 | wx.redirectTo({ 82 | url: '../navigation_bus/navigation' 83 | }) 84 | }, 85 | goToRide: function (e) { 86 | wx.redirectTo({ 87 | url: '../navigation_ride/navigation' 88 | }) 89 | }, 90 | goToWalk: function (e) { 91 | wx.redirectTo({ 92 | url: '../navigation_walk/navigation' 93 | }) 94 | } 95 | }) -------------------------------------------------------------------------------- /pages/navigation_ride/navigation.wxml: -------------------------------------------------------------------------------- 1 | 2 | 驾车 3 | 步行 4 | 公交 5 | 骑行 6 | 7 | 8 | 9 | 10 | 11 | 12 | {{distance}} 13 | {{cost}} 14 | 详情 15 | -------------------------------------------------------------------------------- /pages/navigation_ride/navigation.wxss: -------------------------------------------------------------------------------- 1 | .flex-style{ 2 | display: -webkit-box; 3 | display: -webkit-flex; 4 | display: flex; 5 | } 6 | .flex-item{ 7 | height: 35px; 8 | line-height: 35px; 9 | text-align: center; 10 | -webkit-box-flex: 1; 11 | -webkit-flex: 1; 12 | flex: 1 13 | } 14 | .flex-item.active{ 15 | color:#0091ff; 16 | } 17 | .map_box{ 18 | position:absolute; 19 | top: 35px; 20 | bottom: 90px; 21 | left: 0px; 22 | right: 0px; 23 | } 24 | #navi_map{ 25 | width: 100%; 26 | height: 100%; 27 | } 28 | .text_box{ 29 | position:absolute; 30 | height: 90px; 31 | bottom: 0px; 32 | left: 0px; 33 | right: 0px; 34 | } 35 | .text_box .text{ 36 | margin: 15px; 37 | } 38 | .detail_button{ 39 | position:absolute; 40 | bottom: 30px; 41 | right: 10px; 42 | padding: 3px 5px; 43 | color: #fff; 44 | background: #0091ff; 45 | width:50px; 46 | text-align:center; 47 | border-radius:5px; 48 | } -------------------------------------------------------------------------------- /pages/navigation_ride_detail/navigation.js: -------------------------------------------------------------------------------- 1 | var amapFile = require('../../libs/amap-wx.js'); 2 | var config = require('../../libs/config.js'); 3 | 4 | Page({ 5 | data: { 6 | steps: {} 7 | }, 8 | onLoad: function() { 9 | var that = this; 10 | var key = config.Config.key; 11 | var myAmapFun = new amapFile.AMapWX({key: key}); 12 | myAmapFun.getRidingRoute({ 13 | origin: '116.481028,39.989643', 14 | destination: '116.434446,39.90816', 15 | success: function(data){ 16 | if(data.paths && data.paths[0] && data.paths[0].steps){ 17 | that.setData({ 18 | steps: data.paths[0].steps 19 | }); 20 | } 21 | 22 | }, 23 | fail: function(info){ 24 | 25 | } 26 | }) 27 | } 28 | }) -------------------------------------------------------------------------------- /pages/navigation_ride_detail/navigation.wxml: -------------------------------------------------------------------------------- 1 | 2 | {{i.instruction}} 3 | 4 | -------------------------------------------------------------------------------- /pages/navigation_ride_detail/navigation.wxss: -------------------------------------------------------------------------------- 1 | .flex-style{ 2 | display: -webkit-box; 3 | display: -webkit-flex; 4 | display: flex; 5 | } 6 | .flex-item{ 7 | height: 35px; 8 | line-height: 35px; 9 | text-align: center; 10 | -webkit-box-flex: 1; 11 | -webkit-flex: 1; 12 | flex: 1 13 | } 14 | .flex-item.active{ 15 | color:#0091ff; 16 | } 17 | .text_box{ 18 | margin: 0 15px; 19 | padding: 15px 0; 20 | border-bottom: 1px solid #c3c3c3; 21 | font-size: 13px; 22 | } 23 | .text_box .text_item{display:inline-block;line-height: 8px;} 24 | -------------------------------------------------------------------------------- /pages/navigation_walk/navigation.js: -------------------------------------------------------------------------------- 1 | var amapFile = require('../../libs/amap-wx.js'); 2 | var config = require('../../libs/config.js'); 3 | 4 | Page({ 5 | data: { 6 | markers: [{ 7 | iconPath: "../../img/mapicon_navi_s.png", 8 | id: 0, 9 | latitude: 39.989643, 10 | longitude: 116.481028, 11 | width: 23, 12 | height: 33 13 | },{ 14 | iconPath: "../../img/mapicon_navi_e.png", 15 | id: 0, 16 | latitude: 39.90816, 17 | longitude: 116.434446, 18 | width: 24, 19 | height: 34 20 | }], 21 | distance: '', 22 | cost: '', 23 | polyline: [] 24 | }, 25 | onLoad: function() { 26 | var that = this; 27 | var key = config.Config.key; 28 | var myAmapFun = new amapFile.AMapWX({key: key}); 29 | myAmapFun.getWalkingRoute({ 30 | origin: '116.481028,39.989643', 31 | destination: '116.434446,39.90816', 32 | success: function(data){ 33 | var points = []; 34 | if(data.paths && data.paths[0] && data.paths[0].steps){ 35 | var steps = data.paths[0].steps; 36 | for(var i = 0; i < steps.length; i++){ 37 | var poLen = steps[i].polyline.split(';'); 38 | for(var j = 0;j < poLen.length; j++){ 39 | points.push({ 40 | longitude: parseFloat(poLen[j].split(',')[0]), 41 | latitude: parseFloat(poLen[j].split(',')[1]) 42 | }) 43 | } 44 | } 45 | } 46 | that.setData({ 47 | polyline: [{ 48 | points: points, 49 | color: "#0091ff", 50 | width: 6 51 | }] 52 | }); 53 | if(data.paths[0] && data.paths[0].distance){ 54 | that.setData({ 55 | distance: data.paths[0].distance + '米' 56 | }); 57 | } 58 | if(data.paths[0] && data.paths[0].duration){ 59 | that.setData({ 60 | cost: parseInt(data.paths[0].duration/60) + '分钟' 61 | }); 62 | } 63 | 64 | }, 65 | fail: function(info){ 66 | 67 | } 68 | }) 69 | }, 70 | goDetail: function(){ 71 | wx.navigateTo({ 72 | url: '../navigation_walk_detail/navigation' 73 | }) 74 | }, 75 | goToCar: function (e) { 76 | wx.redirectTo({ 77 | url: '../navigation_car/navigation' 78 | }) 79 | }, 80 | goToBus: function (e) { 81 | wx.redirectTo({ 82 | url: '../navigation_bus/navigation' 83 | }) 84 | }, 85 | goToRide: function (e) { 86 | wx.redirectTo({ 87 | url: '../navigation_ride/navigation' 88 | }) 89 | }, 90 | goToWalk: function (e) { 91 | wx.redirectTo({ 92 | url: '../navigation_walk/navigation' 93 | }) 94 | } 95 | }) -------------------------------------------------------------------------------- /pages/navigation_walk/navigation.wxml: -------------------------------------------------------------------------------- 1 | 2 | 驾车 3 | 步行 4 | 公交 5 | 骑行 6 | 7 | 8 | 9 | 10 | 11 | 12 | {{distance}} 13 | {{cost}} 14 | 详情 15 | -------------------------------------------------------------------------------- /pages/navigation_walk/navigation.wxss: -------------------------------------------------------------------------------- 1 | .flex-style{ 2 | display: -webkit-box; 3 | display: -webkit-flex; 4 | display: flex; 5 | } 6 | .flex-item{ 7 | height: 35px; 8 | line-height: 35px; 9 | text-align: center; 10 | -webkit-box-flex: 1; 11 | -webkit-flex: 1; 12 | flex: 1 13 | } 14 | .flex-item.active{ 15 | color:#0091ff; 16 | } 17 | .map_box{ 18 | position:absolute; 19 | top: 35px; 20 | bottom: 90px; 21 | left: 0px; 22 | right: 0px; 23 | } 24 | #navi_map{ 25 | width: 100%; 26 | height: 100%; 27 | } 28 | .text_box{ 29 | position:absolute; 30 | height: 90px; 31 | bottom: 0px; 32 | left: 0px; 33 | right: 0px; 34 | } 35 | .text_box .text{ 36 | margin: 15px; 37 | } 38 | .detail_button{ 39 | position:absolute; 40 | bottom: 30px; 41 | right: 10px; 42 | padding: 3px 5px; 43 | color: #fff; 44 | background: #0091ff; 45 | width:50px; 46 | text-align:center; 47 | border-radius:5px; 48 | } -------------------------------------------------------------------------------- /pages/navigation_walk_detail/navigation.js: -------------------------------------------------------------------------------- 1 | var amapFile = require('../../libs/amap-wx.js'); 2 | var config = require('../../libs/config.js'); 3 | 4 | Page({ 5 | data: { 6 | steps: {} 7 | }, 8 | onLoad: function() { 9 | var that = this; 10 | var key = config.Config.key; 11 | var myAmapFun = new amapFile.AMapWX({key: key}); 12 | myAmapFun.getWalkingRoute({ 13 | origin: '116.481028,39.989643', 14 | destination: '116.434446,39.90816', 15 | success: function(data){ 16 | if(data.paths && data.paths[0] && data.paths[0].steps){ 17 | that.setData({ 18 | steps: data.paths[0].steps 19 | }); 20 | } 21 | 22 | }, 23 | fail: function(info){ 24 | 25 | } 26 | }) 27 | } 28 | }) -------------------------------------------------------------------------------- /pages/navigation_walk_detail/navigation.wxml: -------------------------------------------------------------------------------- 1 | 2 | {{i.instruction}} 3 | 4 | -------------------------------------------------------------------------------- /pages/navigation_walk_detail/navigation.wxss: -------------------------------------------------------------------------------- 1 | .flex-style{ 2 | display: -webkit-box; 3 | display: -webkit-flex; 4 | display: flex; 5 | } 6 | .flex-item{ 7 | height: 35px; 8 | line-height: 35px; 9 | text-align: center; 10 | -webkit-box-flex: 1; 11 | -webkit-flex: 1; 12 | flex: 1 13 | } 14 | .flex-item.active{ 15 | color:#0091ff; 16 | } 17 | .text_box{ 18 | margin: 0 15px; 19 | padding: 15px 0; 20 | border-bottom: 1px solid #c3c3c3; 21 | font-size: 13px; 22 | } 23 | .text_box .text_item{display:inline-block;line-height: 8px;} 24 | -------------------------------------------------------------------------------- /pages/poi/poi.js: -------------------------------------------------------------------------------- 1 | var amapFile = require('../../libs/amap-wx.js'); 2 | var config = require('../../libs/config.js'); 3 | 4 | var markersData = []; 5 | Page({ 6 | data: { 7 | markers: [], 8 | latitude: '', 9 | longitude: '', 10 | textData: {}, 11 | city: '' 12 | }, 13 | makertap: function(e) { 14 | var id = e.markerId; 15 | var that = this; 16 | that.showMarkerInfo(markersData,id); 17 | that.changeMarkerColor(markersData,id); 18 | }, 19 | onLoad: function(e) { 20 | var that = this; 21 | var key = config.Config.key; 22 | var myAmapFun = new amapFile.AMapWX({key: key}); 23 | var params = { 24 | iconPathSelected: '../../img/marker_checked.png', 25 | iconPath: '../../img/marker.png', 26 | success: function(data){ 27 | markersData = data.markers; 28 | var poisData = data.poisData; 29 | var markers_new = []; 30 | markersData.forEach(function(item,index){ 31 | markers_new.push({ 32 | id: item.id, 33 | latitude: item.latitude, 34 | longitude: item.longitude, 35 | iconPath: item.iconPath, 36 | width: item.width, 37 | height: item.height 38 | }) 39 | 40 | }) 41 | if(markersData.length > 0){ 42 | that.setData({ 43 | markers: markers_new 44 | }); 45 | that.setData({ 46 | city: poisData[0].cityname || '' 47 | }); 48 | that.setData({ 49 | latitude: markersData[0].latitude 50 | }); 51 | that.setData({ 52 | longitude: markersData[0].longitude 53 | }); 54 | that.showMarkerInfo(markersData,0); 55 | }else{ 56 | wx.getLocation({ 57 | type: 'gcj02', 58 | success: function(res) { 59 | that.setData({ 60 | latitude: res.latitude 61 | }); 62 | that.setData({ 63 | longitude: res.longitude 64 | }); 65 | that.setData({ 66 | city: '北京市' 67 | }); 68 | }, 69 | fail: function(){ 70 | that.setData({ 71 | latitude: 39.909729 72 | }); 73 | that.setData({ 74 | longitude: 116.398419 75 | }); 76 | that.setData({ 77 | city: '北京市' 78 | }); 79 | } 80 | }) 81 | 82 | that.setData({ 83 | textData: { 84 | name: '抱歉,未找到结果', 85 | desc: '' 86 | } 87 | }); 88 | } 89 | 90 | }, 91 | fail: function(info){ 92 | // wx.showModal({title:info.errMsg}) 93 | } 94 | } 95 | if(e && e.keywords){ 96 | params.querykeywords = e.keywords; 97 | } 98 | myAmapFun.getPoiAround(params) 99 | }, 100 | bindInput: function(e){ 101 | var that = this; 102 | var url = '../inputtips/input'; 103 | if(e.target.dataset.latitude && e.target.dataset.longitude && e.target.dataset.city){ 104 | var dataset = e.target.dataset; 105 | url = url + '?lonlat=' + dataset.longitude + ',' + dataset.latitude + '&city=' + dataset.city; 106 | } 107 | wx.redirectTo({ 108 | url: url 109 | }) 110 | }, 111 | showMarkerInfo: function(data,i){ 112 | var that = this; 113 | that.setData({ 114 | textData: { 115 | name: data[i].name, 116 | desc: data[i].address 117 | } 118 | }); 119 | }, 120 | changeMarkerColor: function(data,i){ 121 | var that = this; 122 | var markers = []; 123 | for(var j = 0; j < data.length; j++){ 124 | if(j==i){ 125 | data[j].iconPath = "../../img/marker_checked.png"; 126 | }else{ 127 | data[j].iconPath = "../../img/marker.png"; 128 | } 129 | markers.push({ 130 | id: data[j].id, 131 | latitude: data[j].latitude, 132 | longitude: data[j].longitude, 133 | iconPath: data[j].iconPath, 134 | width: data[j].width, 135 | height: data[j].height 136 | }) 137 | } 138 | that.setData({ 139 | markers: markers 140 | }); 141 | } 142 | 143 | }) -------------------------------------------------------------------------------- /pages/poi/poi.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "兴趣点查询 - 附近生活服务点" 3 | } -------------------------------------------------------------------------------- /pages/poi/poi.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{textData.name}} 9 | {{textData.desc}} 10 | 11 | -------------------------------------------------------------------------------- /pages/poi/poi.wxss: -------------------------------------------------------------------------------- 1 | .section{ 2 | height: 30px; 3 | width: 100%; 4 | } 5 | .section input{ 6 | width:90%; 7 | margin:5px auto; 8 | border:1px solid #c3c3c3; 9 | height:30px; 10 | border-radius: 3px; 11 | padding: 0 5px; 12 | } 13 | .map_container{ 14 | position: absolute; 15 | top: 42px; 16 | bottom: 80px; 17 | left: 0; 18 | right: 0; 19 | } 20 | .map{ 21 | width: 100%; 22 | height: 100%; 23 | } 24 | .map_text{ 25 | position: absolute; 26 | left: 0; 27 | right: 0; 28 | bottom: 0px; 29 | height: 80px; 30 | background: #fff; 31 | padding: 0 15px; 32 | } 33 | text{ 34 | margin: 5px 0; 35 | display: block; 36 | font-size:12px; 37 | text-overflow: ellipsis; 38 | white-space: nowrap; 39 | overflow: hidden; 40 | } 41 | .h1{ 42 | margin: 15px 0; 43 | font-size:15px; 44 | } -------------------------------------------------------------------------------- /pages/regeo/regeo.js: -------------------------------------------------------------------------------- 1 | var amapFile = require('../../libs/amap-wx.js'); 2 | var config = require('../../libs/config.js'); 3 | 4 | Page({ 5 | data: { 6 | markers: [], 7 | latitude: '', 8 | longitude: '', 9 | textData: {} 10 | }, 11 | onLoad: function() { 12 | var that = this; 13 | var key = config.Config.key; 14 | var myAmapFun = new amapFile.AMapWX({key: key}); 15 | myAmapFun.getRegeo({ 16 | iconPath: "../../img/marker.png", 17 | iconWidth: 22, 18 | iconHeight: 32, 19 | success: function(data){ 20 | var marker = [{ 21 | id: data[0].id, 22 | latitude: data[0].latitude, 23 | longitude: data[0].longitude, 24 | iconPath: data[0].iconPath, 25 | width: data[0].width, 26 | height: data[0].height 27 | }] 28 | that.setData({ 29 | markers: marker 30 | }); 31 | that.setData({ 32 | latitude: data[0].latitude 33 | }); 34 | that.setData({ 35 | longitude: data[0].longitude 36 | }); 37 | that.setData({ 38 | textData: { 39 | name: data[0].name, 40 | desc: data[0].desc 41 | } 42 | }) 43 | }, 44 | fail: function(info){ 45 | // wx.showModal({title:info.errMsg}) 46 | } 47 | }) 48 | } 49 | }) -------------------------------------------------------------------------------- /pages/regeo/regeo.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "逆地理编码 - 地址解析" 3 | } -------------------------------------------------------------------------------- /pages/regeo/regeo.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {{textData.name}} 6 | {{textData.desc}} 7 | 8 | -------------------------------------------------------------------------------- /pages/regeo/regeo.wxss: -------------------------------------------------------------------------------- 1 | .map_container{ 2 | position: absolute; 3 | top: 0; 4 | bottom: 80px; 5 | left: 0; 6 | right: 0; 7 | } 8 | .map{ 9 | width: 100%; 10 | height: 100%; 11 | } 12 | .map_text{ 13 | position: absolute; 14 | left: 0; 15 | right: 0; 16 | bottom: 0px; 17 | height: 80px; 18 | background: #fff; 19 | padding: 0 15px; 20 | } 21 | text{ 22 | margin: 5px 0; 23 | display: block; 24 | font-size:12px; 25 | } 26 | .h1{ 27 | margin: 15px 0; 28 | font-size:15px; 29 | } -------------------------------------------------------------------------------- /pages/staticmap/staticmap.js: -------------------------------------------------------------------------------- 1 | var amapFile = require('../../libs/amap-wx.js'); 2 | var config = require('../../libs/config.js'); 3 | 4 | Page({ 5 | data: { 6 | src: '' 7 | }, 8 | onLoad: function() { 9 | var that = this; 10 | var key = config.Config.key; 11 | var myAmapFun = new amapFile.AMapWX({key: key}); 12 | wx.getSystemInfo({ 13 | success: function(data){ 14 | var height = data.windowHeight; 15 | var width = data.windowWidth; 16 | var size = width + "*" + height; 17 | myAmapFun.getStaticmap({ 18 | zoom: 10, 19 | size: size, 20 | scale: 2, 21 | location: "116.38482,39.94858", 22 | markers: "mid,0xFF0000,A:116.37359,39.92437;116.47359,39.92437", 23 | labels: "朝阳公园,2,0,16,0xFFFFFF,0x008000:116.48482,39.94858", 24 | // paths: "10,0x0000ff,0.1,0x0000ff,0.7:116.31604,39.96491;116.320816,39.966606;116.321785,39.966827;116.32361,39.966957;116.39361,39.966957;116.39361,39.936957", 25 | paths: '10,0x0000ff,1,,:116.31604,39.96491;116.320816,39.966606;116.321785,39.966827;116.32361,39.966957', 26 | success: function(data){ 27 | that.setData({ 28 | src: data.url 29 | }) 30 | }, 31 | fail: function(info){ 32 | // wx.showModal({title:info.errMsg}) 33 | } 34 | }) 35 | 36 | } 37 | }) 38 | 39 | } 40 | }) -------------------------------------------------------------------------------- /pages/staticmap/staticmap.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "静态地图 - 地图图片" 3 | } -------------------------------------------------------------------------------- /pages/staticmap/staticmap.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /pages/staticmap/staticmap.wxss: -------------------------------------------------------------------------------- 1 | .img_box{ 2 | position: absolute; 3 | top: 0; 4 | bottom: 0; 5 | left: 0; 6 | right: 0; 7 | } 8 | .img_box image{ 9 | width: 100%; 10 | height: 100%; 11 | } -------------------------------------------------------------------------------- /pages/weather/weather.js: -------------------------------------------------------------------------------- 1 | var amapFile = require('../../libs/amap-wx.js'); 2 | var config = require('../../libs/config.js'); 3 | 4 | Page({ 5 | data: { 6 | weather: {} 7 | }, 8 | onLoad: function() { 9 | var that = this; 10 | var key = config.Config.key; 11 | var myAmapFun = new amapFile.AMapWX({key: key}); 12 | myAmapFun.getWeather({ 13 | success: function(data){ 14 | that.setData({ 15 | weather: data 16 | }); 17 | }, 18 | fail: function(info){ 19 | // wx.showModal({title:info.errMsg}) 20 | } 21 | }) 22 | } 23 | }) -------------------------------------------------------------------------------- /pages/weather/weather.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "天气查询 - 当前实时天气" 3 | } -------------------------------------------------------------------------------- /pages/weather/weather.wxml: -------------------------------------------------------------------------------- 1 | 2 | {{weather.city.text}} : {{weather.city.data}} 3 | {{weather.weather.text}} : {{weather.weather.data}} 4 | {{weather.temperature.text}} : {{weather.temperature.data}} ℃ 5 | 风速 : {{weather.winddirection.data}} {{weather.windpower.data}} 6 | {{weather.humidity.text}} : {{weather.humidity.data}} 7 | -------------------------------------------------------------------------------- /pages/weather/weather.wxss: -------------------------------------------------------------------------------- 1 | .container{ 2 | position: absolute; 3 | top: 0; 4 | bottom: 0; 5 | left: 0; 6 | right: 0; 7 | background: #4D8AD7; 8 | color: #fff; 9 | font-size: 18px; 10 | padding-top: 200rpx; 11 | padding-left: 150rpx; 12 | } 13 | .container text{ 14 | display: block; 15 | margin: 30px; 16 | } --------------------------------------------------------------------------------