新增只显示当前坐标,不存储

main
Tuzki 2 years ago
parent fd319de460
commit 7425a25bd5
  1. 9
      pages.json
  2. 15
      pages/index/index.vue
  3. 45
      pages/index/myLocation/myLocation.vue
  4. 2
      pages/index/pointPick/pointPick.vue

@ -24,6 +24,15 @@
}
}
,{
"path" : "pages/index/myLocation/myLocation",
"style" :
{
"navigationBarTitleText": "我的位置",
"enablePullDownRefresh": false
}
}
],
"globalStyle": {
"navigationBarTextStyle": "black",

@ -1,7 +1,8 @@
<template>
<view class="container">
<button @click="pick(1)">点位拾取</button>
<button @click="pick(2)">线路绘制</button>
<button v-if="false" @click="pick(1)">点位拾取</button>
<button v-if="false" @click="pick(2)">线路绘制</button>
<button @click="pick(3)">我的位置</button>
</view>
</template>
@ -20,10 +21,14 @@ export default {
uni.navigateTo({
url:'pointPick/pointPick'
})
}else{
}else if(val == 2){
uni.navigateTo({
url:'lineDraw/lineDraw'
})
}else{
uni.navigateTo({
url:'myLocation/myLocation'
})
}
}
}
@ -31,5 +36,7 @@ export default {
</script>
<style lang="scss">
.container{
margin: 50rpx 40rpx;
}
</style>

@ -0,0 +1,45 @@
<template>
<view>
<view class="location">
<view>经度{{longitude}}</view>
<view>纬度{{latitude}}</view>
</view>
<button class="center-btn" @click="showMeLocation">我在哪</button>
</view>
</template>
<script>
export default {
data() {
return {
longitude:'',
latitude:''
}
},
methods: {
showMeLocation(){
let this_ = this;
uni.getLocation({
type: 'gcj02',
success: function (res) {
console.log('当前位置的经度:' + res.longitude);
console.log('当前位置的纬度:' + res.latitude);
this_.longitude = res.longitude;
this_.latitude = res.latitude;
}
});
}
}
}
</script>
<style lang="scss" scoped>
.location{
padding: 40rpx;
margin: 50rpx 20rpx;
background-color: #eee;
}
.center-btn{
margin: 0 50rpx;
}
</style>

@ -207,7 +207,7 @@ export default {
getLocation() {
let this_ = this;
uni.getLocation({
type: 'wgs84',
type: 'gcj02',
success: function (res) {
console.log('当前位置的经度:' + res.longitude);
console.log('当前位置的纬度:' + res.latitude);

Loading…
Cancel
Save