• uniapp地图点击获取位置


    主页面

    <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))}`,
    		})
    	},
    

    点击跳转的页面

    <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>
    

    在这里插入图片描述

  • 相关阅读:
    安全测试BurpSuite-抓包篡改数据
    钡铼profinet总线模块可以拓展IO
    golang流程控制
    再出发感怀
    浅析即时通讯开发WebSocket热门疑问
    网页游戏的测试流程
    【Java】replace替换方法
    关于Spring-Boot配置加载顺序解读
    如何保证消息的顺序性
    Python读取hbase数据库
  • 原文地址:https://blog.csdn.net/weixin_59527403/article/details/139992255