2025年微信小程序——地图(定位,多个标记点)

微信小程序——地图(定位,多个标记点)地图 定位 多个标记点 效果图 使用的是微信自带的腾讯地图 使用起来方便 简单 代码也很好理解 喜欢的朋友请收藏 js 代码 Page data longitude 113 14278

大家好,我是讯享网,很高兴认识大家。

地图(定位,多个标记点)

效果图:
在这里插入图片描述
讯享网
.
.
.

使用的是微信自带的腾讯地图,
使用起来方便,简单,代码也很好理解
喜欢的朋友请收藏
.
.
.
.
.
.

.js代码:

Page({ 
    data: { 
    longitude: 113.14278, //地图界面中心的经度 latitude: 23.02882, //地图界面中心的纬度 markers: [ //标志点的位置 //位置0 { 
    id: 0, iconPath: "../images/1.png", latitude: 23.055, longitude: 113.273, width: 28, height: 32 }, //位置1 { 
    id: 1, iconPath: "../images/1.png", latitude: 23.072, longitude: 113.608, width: 28, height: 32 }, //位置2 { 
    id: 2, iconPath: "../images/1.png", latitude: 23.093, longitude: 113.229, width: 28, height: 32 }, //位置3 { 
    id: 3, iconPath: "../images/1.png", latitude: 23.087, longitude: 113.13, width: 28, height: 32 }, //位置4 { 
    id: 4, iconPath: "../images/1.png", latitude: 23.0694, longitude: 113.798, width: 28, height: 32 }, ] }, onLoad: function () { 
    var that = this; wx.getLocation({ 
    type: "wgs84", success: function (res) { 
    var latitude = res.latitude; var longitude = res.longitude; console.log("当前位置的经纬度为:", res.latitude, res.longitude); that.setData({ 
    latitude: res.latitude, longitude: res.longitude, }) } }) }, onReady: function () { 
    }, / * 地图放大缩小事件触发 * @param {*} e */ bindregionchange(e) { 
    console.log('=bindregiοnchange=', e) }, / * 点击地图事件,有经纬度信息返回 * @param {*} e */ bindtapMap(e) { 
    console.log('=bindtapMap=', e) } }) 

讯享网

.
.
.

.wxss代码:

讯享网page{ 
    height: 100%; } 

.
.
.
.

.wxml代码:

<view class="" hover-class="none" hover-stop-propagation="false" style="width: 100%; height: 100%;"> <map id="map" longitude="{ 
   {longitude}}" latitude=" { 
   {latitude}}" markers="{ 
   {markers}}" scale="14" show-location style="width: 100%; height: 100%;" bindregionchange="bindregionchange" bindtap="bindtapMap"></map> </view> 

.
.
.

app.json增加代码:

讯享网"permission": { 
    "scope.userLocation": { 
    "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, 

图标 1.png
在这里插入图片描述

小讯
上一篇 2025-01-15 19:08
下一篇 2025-01-06 10:28

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/68065.html