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. 搞定 复制可用!感谢您的浏览!

相关推荐
willow2 小时前
uniapp实战
uni-app
只会cv的前端攻城狮3 小时前
兼容性地狱-Uniapp钉钉小程序环境隔离踩坑实录
前端·uni-app
codingWhat2 天前
小程序里「嵌」H5:一套完整可落地的 WebView 集成方案
前端·uni-app·webview
小时前端3 天前
微信小程序选不了本地文件?用 web-view + H5 一招搞定
前端·微信小程序·uni-app
Mr_li4 天前
给 Vue 开发者的 uni-app 快速指南
vue.js·uni-app
anyup4 天前
🔥2026最推荐的跨平台方案:H5/小程序/App/鸿蒙,一套代码搞定
前端·uni-app·harmonyos
Mintopia5 天前
Vue3 项目如何迁移到 uni-app x:从纯 Web 到多端应用的系统指南
uni-app
Mintopia5 天前
uni-app x 发展前景技术分析:跨端统一的新阶段?
uni-app
不爱说话郭德纲6 天前
告别漫长的HbuilderX云打包排队!uni-app x 安卓本地打包保姆级教程(附白屏、包体积过大排坑指南)
android·前端·uni-app
HashTang7 天前
【AI 编程实战】第 12 篇:从 0 到 1 的回顾 - 项目总结与 AI 协作心得
前端·uni-app·ai编程