欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 八卦 > uniapp地图点击获取位置

uniapp地图点击获取位置

2024/10/25 16:20:25 来源:https://blog.csdn.net/weixin_59527403/article/details/139992255  浏览:    关键词: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>

在这里插入图片描述

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com