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

相关推荐
棋宣3 小时前
uni-app编译到微信小程序中,父传子props首次传递数据不接收的bug
微信小程序·uni-app·bug
阳光先做1 天前
uniapp打包鸿蒙安装包问题
uni-app
码海扬帆:前端探索之旅2 天前
深度定制 uni-combox:新增功能详解与实战指南
前端·vue.js·uni-app
计算机学姐2 天前
基于微信小程序的图书馆座位预约系统【uniapp+springboot+vue】
vue.js·spring boot·微信小程序·小程序·java-ee·uni-app·intellij-idea
中犇科技2 天前
电商app源码系统推荐|开源 uniapp 商城系统
uni-app
海水冷却2 天前
uniapp 实现直播功能的完整方案与实战指南
uni-app
wuxianda10302 天前
Object-C/Swift/UniApp项目苹果商店上架3天极速解决方案汇报总结
ios·uni-app·objective-c·cocoa·苹果上架
WKK_2 天前
uniapp 微信小程序使用TextEncoder,arrayBufferToBase64
微信小程序·小程序·uni-app
喜崽2 天前
uniapp消息会话界面【消息组件一左一右】-01
uni-app
一渊之隔2 天前
uniapp蓝牙搜索连接展示蓝牙设备包含信号显示
前端·网络·uni-app·bluetooth