Skip to content

Commit ba462cc

Browse files
committed
小程序的地图
小程序的地图
1 parent 9905f99 commit ba462cc

File tree

4 files changed

+65
-8
lines changed

4 files changed

+65
-8
lines changed

微信小程序的测试/app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"pages":[
3+
"pages/index/index",
34
"pages/dataStore/index",
45
"pages/zhouqi/index",
56

67
"pages/customMusic/index",
7-
"pages/index/index",
88
"pages/logs/logs"
99
],
1010
"window":{

微信小程序的测试/pages/index/index.js

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ onReady: function (e) {
157157
this.audioCtx = wx.createAudioContext('myAudio')
158158
},
159159
data: {
160+
position: '', // 当前的位置
161+
tempFilePaths: '', // 文件的位置
160162
poster: 'http://y.gtimg.cn/music/photo_new/T002R300x300M000003rsKF44GyaSk.jpg?max_age=2592000',
161163
name: '此时此刻',
162164
author: '许巍',
@@ -173,5 +175,58 @@ audio14: function () {
173175
},
174176
audioStart: function () {
175177
this.audioCtx.seek(0)
176-
}
178+
},
179+
onLoad(){
180+
// 逆向解码获得具体的位置信息
181+
var that = this;
182+
wx.getLocation({
183+
type: 'wgs84',
184+
success: function(res) {
185+
var latitude = res.latitude
186+
var longitude = res.longitude
187+
var speed = res.speed
188+
var accuracy = res.accuracy
189+
var location = latitude+','+longitude
190+
// wx.openLocation({
191+
// latitude: latitude,
192+
// longitude: longitude,
193+
// scale: 28
194+
// })
195+
wx.request({
196+
url: 'http://api.map.baidu.com/geocoder/v2/?location='+location+'&output=json&pois=1&ak=TmrCpX3fYsHAczyCnoL7cln6AADvYHCu',
197+
success: function(res){
198+
// debugger
199+
console.log(res.data.result.formatted_address)
200+
that.setData({
201+
position: res.data.result.formatted_address
202+
})
203+
}
204+
})
205+
// that.chooseImg()
206+
}
207+
})
208+
},
209+
chooseImg(){
210+
var that = this;
211+
wx.chooseImage({
212+
count: 1, // 默认9
213+
sizeType: ['original'], // 可以指定是原图还是压缩图,默认二者都有
214+
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
215+
success: function (res) {
216+
// 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
217+
that.setData({
218+
tempFilePaths: res.tempFilePaths[0]
219+
})
220+
221+
}
222+
})
223+
},
224+
// 转发 开启之后才会有效果的
225+
onShareAppMessage(){
226+
// debugger
227+
// return {
228+
// title: '你好,世界',
229+
// path: '/pages/index/index'
230+
// }
231+
}
177232
})

微信小程序的测试/pages/index/index.wxml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--index.wxml-->
22
<view class="container">
3-
3+
<text>{{position}}</text>
44
<audio poster="{{poster}}" name="{{name}}" author="{{author}}" src="{{src}}" id="myAudio" controls loop></audio>
55

66
<button type="primary" bindtap="audioPlay">播放</button>
@@ -40,4 +40,6 @@
4040
</view>
4141
</view>
4242
</view> -->
43+
<image wx:if="{{tempFilePaths}}!=''" src="{{tempFilePaths}}" mode="{{}}"></image>
44+
<!-- <button type="default" size="default" plain="false" bindtap="chooseImg" hover-class="button-hover">button</button> -->
4345
</view>

微信小程序的测试/project.config.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"description": "项目配置文件。",
33
"setting": {
4-
"urlCheck": true,
5-
"es6": true,
6-
"postcss": true,
7-
"minified": true,
4+
"urlCheck": false,
5+
"es6": false,
6+
"postcss": false,
7+
"minified": false,
88
"newFeature": true
99
},
1010
"compileType": "miniprogram",
1111
"libVersion": "1.5.4",
1212
"appid": "wx211f510021b4eb18",
13-
"projectname": "%E5%BE%AE%E4%BF%A1%E5%B0%8F%E7%A8%8B%E5%BA%8F%E7%9A%84%E6%B5%8B%E8%AF%95%E7%89%88",
13+
"projectname": "%E5%9C%B0%E7%90%86%E4%BD%8D%E7%BD%AE%E7%9A%84%E6%B5%8B%E8%AF%95",
1414
"condition": {
1515
"search": {
1616
"current": -1,

0 commit comments

Comments
 (0)