更新记录

1.0.0(2025-08-21) 下载此版本

新发布


平台兼容性

uni-app(4.07)

Vue2 Vue3 Chrome Safari app-vue app-nvue Android iOS 鸿蒙
- - - - - - -
微信小程序 支付宝小程序 抖音小程序 百度小程序 快手小程序 京东小程序 鸿蒙元服务 QQ小程序 飞书小程序 快应用-华为 快应用-联盟
- - - - - - - - - - -

uni-app x(4.07)

Chrome Safari Android iOS 鸿蒙 微信小程序
- - - - - -

其他

多语言 暗黑模式 宽屏模式
× ×

fx-map使用方法

支持easycom 重点事项:使用前请在fx-map目录下执行pnpm install安装openlayers依赖

<template>
    <view class="h-fill relative overflow-hidden">
        <fx-map :location="position" :direction="direction" @ready="onMapReady" @location-changed="onLocationChange" />
        <view class="absolute location float-button" @click="getPosition">
            <fx-icon name="dingwei" />
        </view>
    </view>
</template>

<script setup>
    import {
        ref,
        computed,
        onMounted
    } from 'vue';
    import {
        onUnload
    } from '@dcloudio/uni-app';
    import {
        useCompass
    } from '../../../hooks/tools/useCompass';
    import {
        useGeolocation
    } from '../../../hooks/tools/useGeolocation';

    /**
     * @type { import('vue').Ref<Number> } 当前方位角 
     */
    const direction = ref(0);

    /**
     * 获取定位
     * @type {{ position: Location, getPosition: () => Promise<[nuber, number]>}}
     */
    const {
        position,
        getPosition
    } = useGeolocation();

    const {
        onCompassChange,
        offCompassChange
    } = useCompass();

    const onMapReady = async () => {
        // #ifndef H5
        // await getPosition();

        onCompassChange((res) => {
            if (Math.abs(res.direction - direction.value) >= 1) {
                direction.value = res.direction;
            }
        });
        // #endif
    };

    const onLocationChange = () => {
        uni.hideLoading();
    }

    onUnload(() => {
        offCompassChange();
    });
</script>

<style scoped>
    .float-button {
        background: white;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 16rpx;
        width: 70rpx;
        height: 70rpx;
    }

    .location {
        bottom: 200rpx;
        right: 40rpx;
        z-index: 100000;
    }
</style>

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

暂无用户评论。