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>
相关推荐
淡淡的幼稚8 小时前
【YFIOs】从传感芯片到表格曲线
uni-app·.net
宠友信息10 小时前
多端即时通讯源码技术实践,Redis路由、MySQL持久化与Socket接入
spring boot·websocket·mysql·uni-app
宠友信息12 小时前
Spring Boot与异步审核构建仿小红书源码内容发布全流程
java·数据库·spring boot·redis·mysql·oracle·uni-app
蜡台12 小时前
uniapp vue2 转 vue3
前端·javascript·uni-app·vue3·vue2
2501_9160088915 小时前
iOS 证书管理最佳实践 从创建到续期的完整指南
android·ios·小程序·https·uni-app·iphone·webview
敖行客 Allthinker1 天前
UniApp iOS APNs 推送证书一站式配置
uni-app·mac
梦曦i1 天前
uni-router新推useUniEventChannel,彻底解决页面通信难题
前端·uni-app
宠友信息1 天前
内容社区源码多端数据协议与 Spring Boot 状态流转实现思路
java·spring boot·websocket·uni-app
2501_916007472 天前
iPad 怎么抓包 从代理模式到暴力抓包的操作方法
android·ios·小程序·uni-app·代理模式·iphone·ipad
2501_915918412 天前
PerfDog 太贵?iOS 性能监控工具的功能对比与选择
android·ios·小程序·https·uni-app·iphone·webview