美文网首页
uni-App H5网页 导航功能

uni-App H5网页 导航功能

作者: 郭的妻 | 来源:发表于2021-03-09 17:46 被阅读0次

    1.首先你需要申请 腾讯地图 key

    2.使用 HBuilder X 编辑器的 小伙伴 们

    3.找到uni-app 项目的 manifest.json 文件 如图


    image.png

    4.打开 manifest.json 文件 选择H5配置 如图


    image.png

    5.选择H5配置后 找到定位和地图 如图


    image.png

    6.在你需要使用 导航的页面 以下 添加点击事件

    注意:只有在真机上测试有效,在电脑上模拟手机是不行的
    /* 点击 导航位置 */
            OpenLocation(lat,lng){
                console.log(lat,lng)
                if(lat && lng){
                    uni.getLocation({
                        type: 'gcj02', //返回可以用于uni.openLocation的经纬度
                        success: function (res) {
                            console.log(res);
                            uni.openLocation({
                                latitude: Number(lat),
                                longitude:Number(lng),
                                success: function (res) {
                                    console.log(res);
                                    console.log('success');
                                }
                            });
                        }
                    });
                }else{
                    this.showToast('暂无位置信息无法导航位置哦');
                }
            },
    

    相关文章

      网友评论

          本文标题:uni-App H5网页 导航功能

          本文链接:https://www.haomeiwen.com/subject/gisbqltx.html