uniapp地图点击获取位置

主页面

javascript 复制代码
<view class="right-content" @click.stop="kilometer(item)">
	<view class="km">
     {{item.distance||'0'}}km
	</view>
	<image src="../../static/map.png" mode=""
		style="width: 32rpx; height: 32rpx; margin-left: 10rpx; margin-right: 10px;">
	</image>
</view>
   kilometer(item){
		uni.navigateTo({
			url: `/subpkg/map/map?item=${(JSON.stringify(item))}`,
		})
	},

点击跳转的页面

javascript 复制代码
<template>
	<view>
		<map style="width: 100%; height: 400px;" enable-building="true" show-compass="true" :latitude="latitude"
			:longitude="longitude" :markers="markers">
		</map>
	</view>
</template>

<script>
	export default {
		data() {
			return {

				latitude: 0,
				longitude: 0,
				markers: [{
					id: 1,
					latitude: 0,
					longitude: 0,
					width: '30', // 标记点图标宽度
					height: '50' // 标记点图标高度
				}],
				msgInfo: {}
			}

		},
		onLoad(option) {
			this.msgInfo = JSON.parse(option.item || '{}');
			this.latitude = Number(this.msgInfo.lat || 0);
			this.longitude = Number(this.msgInfo.lng || 0);

			// 更新 covers 数组中的标记点位置  
			this.markers[0].latitude = this.latitude;
			this.markers[0].longitude = this.longitude;


		}
	}
</script>

<style lang="scss">

</style>
相关推荐
AH_HH几秒前
UniApp H5 代理失效的终极替代方案
uni-app
不努力code9 分钟前
uniapp浮动面板-movable-area
前端·javascript·uni-app
游戏开发爱好者82 小时前
iPhone HTTPS 抓包实战指南,移动端加密流量分析、代理解密失败排查与底层数据流捕获
android·ios·小程序·https·uni-app·iphone·webview
2501_9159090615 小时前
iOS 反编译防护工具全景解析 从底层符号到资源层的多维安全体系
android·安全·ios·小程序·uni-app·iphone·webview
lvha16 小时前
uniapp BLE低功耗蓝牙插件 支持安卓 iOS 鸿蒙NEXT 微信小程序
uni-app·蓝牙
Redundantº21 小时前
Uniapp 适配安卓与 iOS 的 PDF、DOC 文件上传
android·ios·pdf·uni-app·webview
Harry技术1 天前
UniApp H5 代理失效的终极替代方案
uni-app
2501_915918411 天前
iOS 应用如何防止破解?从逆向链路还原攻击者视角,构建完整的反破解工程实践体系
android·macos·ios·小程序·uni-app·cocoa·iphone
2501_916007471 天前
iOS 压力测试的工程化体系 构建多工具协同的极限稳定性验证方案
android·ios·小程序·uni-app·压力测试·iphone·webview
2501_916007471 天前
iOS 应用上架流程的工程化拆解 从签名体系到提交审核的全过程管控
android·ios·小程序·https·uni-app·iphone·webview