uniapp:跳转第三方地图

1.跳转第三方高德地图

//跳转地图
toMap(item){
	uni.navigateTo({
		url: (window.location.href = `https://uri.amap.com/navigation?to=${item.lng},${item.lat},${item.shopName}&mode=car&policy=1&src=https://gawl.gazhcs.com/wap/index.html&callnative=0`)
	})
},

2.可选择第三方地图

// 地图
headMap(e){
  uni.openLocation({
	longitude: Number(e.F_lng),
	latitude: Number(e.F_Lat),          
	name: e.F_FullName, // 位置名称
	address: e.F_Address, // 位置地点
	success: function (res) {
		console.log('打开系统位置地图成功')
	},
	fail: function (error) {
		console.log(error)
	},
  })
},

h5端 (小程序端会直接换起第三方地图选择,直接跳转第三方地图app)

3.搜索地图及周边

1.引用腾讯地图文件及key值

​
//引入SDK核心类
var QQMapWX = require('../../assert/qqmap-wx-jssdk.min.js');
// 实例化API核心类
var qqmapsdk = new QQMapWX({
	key: 'key_zhi' // 必填
});

​

 2.搜索请求

// 搜索附近交通
async searchNearbyTransit() {
	try {
		const keyword = this.ggtitle; // 搜索关键词,可以是多个用'|'分隔
		console.log(keyword)
		const response = await new Promise((resolve, reject) => {
		    this.qqmapsdk.search({
			    keyword: keyword,
			    location: `${this.latitude},${this.longitude}`, // 当前位置坐标
			    radius: 1000, // 搜索半径,单位:米
			    success: resolve,
		    	fail: reject,
		    });
		});

		this.nearbyTransports = response.data || [];
		if(this.nearbyTransports.length == 0){
			uni.showToast({
				title:'暂无数据',
				icon:'none',
				duration:2000
			})
		}
		console.log('附近交通设施:', this.nearbyTransports);
	} catch (error) {
		uni.showToast({
			title:'请求key今日已达上限!',
			icon:'none',
			duration:2000
		})
		console.error('搜索附近交通设施失败:', error);
	}
},

3.点击切换不同搜索请求

tab(e) {
   this.active = e
   if(e == 1){
	  this.ggtitle = '公交站|地铁站'
   }else if(e == 2){
	  this.ggtitle = '风景名胜'
   }else if(e == 3){
		this.ggtitle = '餐饮'
   }else if(e == 4){
		this.ggtitle = '商店超市'
   }
	this.searchNearbyTransit()
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

_木棠

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值