提交 c317a117 编写于 作者: zhaofengliang920817's avatar zhaofengliang920817

app端调整getLocation页面示例.

上级 1bee97a6
<template> <template>
<page-head :title="title"></page-head> <!-- #ifdef APP -->
<view style="padding: 4px"> <scroll-view style="flex: 1;">
<text class="hello-text"> <!-- #endif -->
定位功能默认调用操作系统定位API实现。\n <page-head :title="title"></page-head>
部分手机因gms兼容不好可能导致无法定位。\n <view style="padding: 4px">
gcj国标、逆地理信息等功能需三方sdk定位。如果需要类似能力可以下载腾讯定位插件,打包自定义基座。参考示例:</text> <text class="hello-text">
<u-link :href="'https://ext.dcloud.net.cn/plugin?id=14569'" :text="'https://ext.dcloud.net.cn/plugin?id=14569'" 定位功能默认调用操作系统定位API实现。\n
:inWhiteList="true"></u-link> 部分手机因gms兼容不好可能导致无法使用系统定位。\n
</view> gcj国标、逆地理信息等功能需调用内置腾讯定位或者其他三方sdk定位。如果需要类似能力请参考之前的腾讯定位插件版本,打包自定义基座。参考示例:</text>
<u-link :href="'https://ext.dcloud.net.cn/plugin?id=14569'" :text="'https://ext.dcloud.net.cn/plugin?id=14569'"
<view class="uni-padding-wrap uni-common-mt"> :inWhiteList="true"></u-link>
<view class="uni-list-cell-db">定位服务商provider(如系统定位,腾讯定位等)</view>
<view class="uni-list" style="margin-bottom: 20px">
<radio-group @change="radioChangePV">
<radio class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in providerList" :key="item.id"
:class="index < providerList.length - 1 ? 'uni-list-cell-line' : ''" :value="item.id"
:checked="index === currentProvider">
{{ item.name }}
</radio>
</radio-group>
</view>
<view class="uni-list-cell-db">定位类型1</view>
<view class="uni-list">
<radio-group @change="radioChange">
<radio class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in items" :key="item.value"
:class="index < items.length - 1 ? 'uni-list-cell-line' : ''" :value="item.value"
:checked="index === current">
{{ item.name }}
</radio>
</radio-group>
</view>
<view class="uni-list-cell uni-list-cell-pd" style="margin-top: 20px">
<view class="uni-list-cell-db">高度信息</view>
<switch :checked="altitudeSelect" @change="altitudeChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">开启高精度定位</view>
<switch :checked="isHighAccuracySelect" @change="highAccuracySelectChange" />
</view> </view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">是否解析地址信息</view> <view class="uni-padding-wrap uni-common-mt">
<switch :checked="geocodeSelect" @change="geocodeChange" /> <view class="uni-list-cell-db">定位服务商provider(如系统定位,腾讯定位等)</view>
</view> <view class="uni-list" style="margin-bottom: 20px">
<text>{{ exeRet }}</text> <radio-group @change="radioChangePV">
<view class="uni-btn-v"> <radio class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in providerList" :key="item.id"
<button class="uni-btn" type="default" @tap="getLocationTap"> :class="index < providerList.length - 1 ? 'uni-list-cell-line' : ''" :value="item.id"
获取定位 :checked="index === currentProvider">
</button> {{ item.name }}
</radio>
</radio-group>
</view>
<view class="uni-list-cell-db">定位类型</view>
<view class="uni-list">
<radio-group @change="radioChange">
<radio class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in items" :key="item.value"
:class="index < items.length - 1 ? 'uni-list-cell-line' : ''" :value="item.value"
:checked="index === current">
{{ item.name }}
</radio>
</radio-group>
</view>
<view class="uni-list-cell uni-list-cell-pd" style="margin-top: 20px">
<view class="uni-list-cell-db">高度信息</view>
<switch :checked="altitudeSelect" @change="altitudeChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">开启高精度定位</view>
<switch :checked="isHighAccuracySelect" @change="highAccuracySelectChange" />
</view>
<view class="uni-list-cell uni-list-cell-pd">
<view class="uni-list-cell-db">是否解析地址信息</view>
<switch :checked="geocodeSelect" @change="geocodeChange" />
</view>
<text>{{ exeRet }}</text>
<view class="uni-btn-v">
<button class="uni-btn" type="default" @tap="getLocationTap">
获取定位
</button>
</view>
</view> </view>
</view> <!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template> </template>
<script lang="uts"> <script lang="uts">
export type LocationItem = { id : string, name : string, provider ?: UniProvider } export type LocationItem = { id : string, name : string, provider ?: UniProvider }
...@@ -108,7 +114,11 @@ ...@@ -108,7 +114,11 @@
}); });
this.providerList.forEach((value, index) => {
if (value.id == "system") {
this.currentProvider = index
}
})
}, },
altitudeChange: function (e : UniSwitchChangeEvent) { altitudeChange: function (e : UniSwitchChangeEvent) {
this.altitudeSelect = e.detail.value this.altitudeSelect = e.detail.value
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册