您的位置:首页 > 汽车 > 新车 > 南昌企业制作网站设计_打车软件app开发_重庆seo教程搜索引擎优化_游戏代理平台哪个好

南昌企业制作网站设计_打车软件app开发_重庆seo教程搜索引擎优化_游戏代理平台哪个好

2025/3/10 16:10:44 来源:https://blog.csdn.net/apple_70049717/article/details/146073901  浏览:    关键词:南昌企业制作网站设计_打车软件app开发_重庆seo教程搜索引擎优化_游戏代理平台哪个好
南昌企业制作网站设计_打车软件app开发_重庆seo教程搜索引擎优化_游戏代理平台哪个好

 一、效果展示

二、完整代码

<template><view class="container"><map class="map-container" :latitude="latitude" :longitude="longitude" :markers="markers" :controls="controls" show-location @markertap="onMarkerTap"></map></view>
</template><script>
export default {data() {return {latitude: 34.341568, // 默认中心点(西安)longitude: 108.940174,// 标记点(多个位置)markers: [{id: 1,latitude: 34.341568,longitude: 108.940174,title: "",iconPath: "/static/location.png", // 标记点图标width: 30,height: 30,callout: {content: "点击导航",color: "#ffffff",fontSize: 14,borderRadius: 10,bgColor: "#000000",padding: 8,display: "ALWAYS"}},{id: 2,latitude: 34.250568,longitude: 108.950174,title: "",iconPath: "/static/location.png",width: 30,height: 30,callout: {content: "点击导航",color: "#ffffff",fontSize: 14,borderRadius: 10,bgColor: "#000000",padding: 8,display: "ALWAYS"}}]};},methods: {// 点击标记点触发导航onMarkerTap(e) {const marker = this.markers.find(m => m.id === e.markerId);if (marker) {uni.openLocation({latitude: marker.latitude,longitude: marker.longitude,name: marker.title,address: marker.title,scale: 18});}}}
};
</script><style>
.container {width: 100vw;height: 100vh;overflow: hidden;
}.map-container {width: 100%;height: 100%;position: absolute;top: 0;left: 0;
}
</style>

三、代码解释 

整体说一下就是map直接组件就显示地图,marker就是标记点传进来显示,uni.openLocation这个就是打开手机内置地图然后选择你的地图就能正常导航过去

版权声明:

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

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