uniapp H5 打开地图 并选中标记点

uniapp H5 打开地图 并选中标记点

  1. 先上代码
javascript 复制代码
			//打开地图 显示景区位置
			openMap() {
			    // 支付宝
				// #ifdef MP-ALIPAY
				my.openLocation({
					longitude: Number(this.detailObj.longitude), // 经度
					latitude: Number(this.detailObj.latitude), // 纬度
					name: this.detailObj.scenicName, // 标点名称
					address: this.detailObj.address, // 标点地址
					success: res => {
						// console.log(res);
					},
					fail: res => {
						// console.log(res);
					},
				});
				// #endif


				// 小程序
				// #ifdef MP-WEIXIN
				uni.openLocation({
					latitude: Number(this.detailObj.latitude), // 纬度
					longitude: Number(this.detailObj.longitude), // 经度
					name: this.detailObj.scenicName, // 标点名称
					success: function() {}
				});
				// #endif

                // H5------------------------------------------------------------------------------
                // this.detailObj.latitude // 纬度
                // this.detailObj.longitude // 经度
                // this.detailObj.scenicName // 标点名称
                
				// #ifdef H5
				uni.navigateTo({
					url:'/pages/webpage/webpage?urlEncode='+ encodeURIComponent(`https://uri.amap.com/marker?position=${this.detailObj.longitude},${this.detailObj.latitude}&name=${this.detailObj.scenicName}`)
				})
				// #endif
			},
  1. webview 页面/pages/webpage/webpage
javascript 复制代码
<template>
	<view>
		<web-view :webview-styles="webviewStyles" :src="urlSrc"></web-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				urlSrc:'',
				webviewStyles: {
					progress: {
						color: '#ff4643'
					}
				},
			};
		},
		onLoad(options) {
			if(options.urlEncode){
				this.urlSrc = decodeURIComponent(options.urlEncode)
				return
			}
		}
	}
</script>
  1. 这是高德提供的免费地址https://uri.amap.com/marker 高德官网

  2. 更多参数

  3. 搞定 复制可用!感谢您的浏览!

相关推荐
2501_9160088913 小时前
iOS 26 性能分析深度指南 包含帧率、渲染、资源瓶颈与 KeyMob 协助策略
android·macos·ios·小程序·uni-app·cocoa·iphone
iOS阿玮15 小时前
喜欢做马甲包的有福了~现在多了一招续费方式!
uni-app·app·apple
_AaronWong18 小时前
一键搞定UniApp WiFi连接!这个Vue 3 Hook让你少走弯路
前端·微信小程序·uni-app
2501_915909061 天前
tcpdump 抓包数据分析实战,命令、过滤、常见故障定位与真机补充流程
网络·测试工具·ios·小程序·uni-app·iphone·tcpdump
赵庆明老师1 天前
Uniapp微信小程序开发:微信小程序支付功能后台代码
微信小程序·小程序·uni-app
曹申阳1 天前
1. 使用VSCode开发uni-app环境搭建
ide·vscode·uni-app
雪芽蓝域zzs1 天前
uniapp开发 APP嵌入另一个APP打包的wgt文件,实现点击携带参数跳转到wgtAPP的某一个页面
uni-app·apache
00后程序员张1 天前
tcpdump 抓包分析,命令、过滤技巧、常见症状定位与移动真机补充方案
网络·测试工具·ios·小程序·uni-app·iphone·tcpdump
BumBle1 天前
基于UniApp实现DeepSeek AI对话:流式数据传输与实时交互技术解析
前端·uni-app