uni-app点击使用高德地图导航

2023-11-20  本文已影响0人  甘道夫老矣
// 点击导航
            handleLocationDh() {
                uni.showActionSheet({
                    itemList: ['高德地图'],
                    success: (res) => {
                        this.guideFun(res.tapIndex)
                    },
                    fail: function(res) {
                        console.log(res.errMsg);
                    }
                });
            },
// 高德导航
            guideFun(signMap) {
                          //this.longitude ,latitude是目标点的坐标
                if (this.longitude && this.latitude) {
                    // 高德地图
                    let lng = this.longitude;
                    let lat = this.latitude;
                    uni.getSystemInfo({
                        success: (res) => {
                            if (res.platform === "android") {
                                window.location.href =
                                    "androidamap://viewMap?sourceApplication=appname&poiname=线索位置" + "&lat=" +
                                    lat + "&lon=" + lng + "&dev=0";
                            } else if (res.platform === "ios") { 
                                window.location.href  =
                                    `iosamap://viewMap?sourceApplication=applicationName&poiname=线索位置&lat=${lat}&lon=${lng}&dev=0`;
                            }else{
                                uni.showToast({
                                    title: '暂只支持安卓导航',
                                    icon: 'none',
                                    duration: 2000,
                                });
                            }
                        }
                    })
                } else {
                    uni.showToast({
                        title: '暂不知道该地点位置',
                        icon: 'none',
                        duration: 2000,
                    });
                }
            },
上一篇 下一篇

猜你喜欢

热点阅读