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>
相关推荐
游戏开发爱好者84 小时前
iOS 开发者的安全加固工具,从源码到成品 IPA 的多层防护体系实践
android·安全·ios·小程序·uni-app·cocoa·iphone
游戏开发爱好者87 小时前
Charles 抓不到包怎么办?从 HTTPS 代理排错到底层数据流补抓的完整解决方案
网络协议·http·ios·小程序·https·uni-app·iphone
骨子里的偏爱13 小时前
uniapp实现数据存储到本地文件,除非卸载app,否则数据一直存在
javascript·chrome·uni-app
_Jyann_16 小时前
uniapp两种方式实现自定义tabbar
前端·javascript·uni-app
郑州光合科技余经理16 小时前
PHP技术栈:上门系统海外版开发与源码解析
java·开发语言·javascript·git·uni-app·php·uniapp
2501_9159214316 小时前
Fiddler抓包工具详解,HTTPHTTPS调试、代理配置与接口分析实战教程
服务器·ios·小程序·fiddler·uni-app·php·webview
undsky16 小时前
【RuoYi-SpringBoot3-UniApp】:一套代码,多端运行的移动端开发方案
前端·uni-app
diygwcom17 小时前
UniApp 鸿蒙NEXT蓝牙连接及数据写入
华为·uni-app·harmonyos
00后程序员张17 小时前
数据流抓包实战指南,TCPUDP 流量分析、HTTPS 解密与多工具协同方案
网络协议·http·ios·小程序·https·uni-app·iphone
2501_9159214318 小时前
iOS 性能分析工具全景解析,构建从底层诊断到真机监控的多层级性能分析体系
android·ios·小程序·https·uni-app·iphone·webview