欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 房产 > 建筑 > uniapp map组件的基础与实践

uniapp map组件的基础与实践

2025/9/27 8:56:06 来源:https://blog.csdn.net/weixin_55493330/article/details/148472063  浏览:    关键词:uniapp map组件的基础与实践

UniApp 中的 map 组件用于在应用中展示地图,并且支持在地图上添加标记、绘制线条和多边形等功能。以下是一些基本用法:

1. 基本结构

首先,确保你在页面的 .vue 文件中引入了 map 组件。以下是创建一个简单地图的基本代码结构:

<template><view class="container"><map style="width: 100%; height: 300px;":latitude="latitude":longitude="longitude":markers="markers":polyline="polyline"@markertap="markertap"@callouttap="callouttap"@controltap="controltap"@regionchange="regionchange"></map></view>
</template><script>
export default {data() {return {latitude: 39.909, // 地图中心纬度longitude: 116.39742, // 地图中心经度markers: [{id: 0,latitude: 39.909,longitude: 116.39742,iconPath: '/static/images/marker.png', // 自定义图标路径width: 30, // 图标宽度height: 45, // 图标高度title: '这是一个标记点',callout: { // 标记点上方气泡content: '北京',color: '#000',fontSize: 14,borderRadius: 15,bgColor: '#fff',display: 'ALWAYS'}}],polyline: [{points: [{latitude: 39.909,longitude: 116.39742,}, {latitude: 39.919,longitude: 116.40742,}],color: "#FF0000DD",width: 2,dottedLine: true}]}},methods: {markertap(e) {console.log('marker:', e.detail.markerId);}

版权声明:

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

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

热搜词