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

相关推荐
喵喵虫16 小时前
uniapp修改封装组件失败 styleIsolation
uni-app
游戏开发爱好者81 天前
日常开发与测试的 App 测试方法、查看设备状态、实时日志、应用数据
android·ios·小程序·https·uni-app·iphone·webview
2501_915106321 天前
app 上架过程,安装包准备、证书与描述文件管理、安装测试、上传
android·ios·小程序·https·uni-app·iphone·webview
2501_915106321 天前
使用 Sniffmaster TCP 抓包和 Wireshark 网络分析
网络协议·tcp/ip·ios·小程序·uni-app·wireshark·iphone
宠友信息1 天前
2025社交+IM及时通讯社区APP仿小红书小程序
java·spring boot·小程序·uni-app·web app
“负拾捌”1 天前
python + uniapp 结合腾讯云实现实时语音识别功能(WebSocket)
python·websocket·微信小程序·uni-app·大模型·腾讯云·语音识别
局外人LZ2 天前
Uniapp脚手架项目搭建,uniapp+vue3+uView pro+vite+pinia+sass
前端·uni-app·sass
2501_915918412 天前
在 iOS 环境下查看 App 详细信息与文件目录
android·ios·小程序·https·uni-app·iphone·webview
前端呆头鹅2 天前
Websocket使用方案详解(uniapp版)
websocket·网络协议·uni-app
浮桥2 天前
uniapp+h5 公众号实现分享海报绘制
uni-app·notepad++