微信小程序如何创建并返回map上下文mapContext对象
发表于:2024-10-07 作者:千家信息网编辑
千家信息网最后更新 2024年10月07日,这篇文章主要介绍了微信小程序如何创建并返回map上下文mapContext对象的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇微信小程序如何创建并返回map上下文mapCo
千家信息网最后更新 2024年10月07日微信小程序如何创建并返回map上下文mapContext对象
这篇文章主要介绍了微信小程序如何创建并返回map上下文mapContext对象的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇微信小程序如何创建并返回map上下文mapContext对象文章都会有所收获,下面我们一起来看看吧。
wx.createMapContext(mapId)
创建并返回 map 上下文 mapContext
对象。在自定义组件下,第二个参数传入组件实例this,以操作组件内 组件
mapContext
mapContext
通过 mapId 跟一个组件绑定,通过它可以操作对应的
组件。
mapContext 对象的方法列表
方法 | 参数 | 说明 | 最低版本 |
---|---|---|---|
getCenterLocation | OBJECT | 获取当前地图中心的经纬度,返回的是 gcj02 坐标系,可以用于 wx.openLocation | |
moveToLocation | 无 | 将地图中心移动到当前定位点,需要配合map组件的show-location使用 | |
translateMarker | OBJECT | 平移marker,带动画 | 1.2.0 |
includePoints | OBJECT | 缩放视野展示所有经纬度 | 1.2.0 |
getRegion | OBJECT | 获取当前地图的视野范围 | 1.4.0 |
getScale | OBJECT | 获取当前地图的缩放级别 | 1.4.0 |
getCenterLocation 的 OBJECT 参数列表
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
success | Function | 否 | 接口调用成功的回调函数 ,res = { longitude: "经度", latitude: "纬度"} |
fail | Function | 否 | 接口调用失败的回调函数 |
complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
translateMarker 的 OBJECT 参数列表
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
markerId | Number | 是 | 指定marker |
destination | Object | 是 | 指定marker移动到的目标点 |
autoRotate | Boolean | 是 | 移动过程中是否自动旋转marker |
rotate | Number | 是 | marker的旋转角度 |
duration | Number | 否 | 动画持续时长,默认值1000ms,平移与旋转分别计算 |
animationEnd | Function | 否 | 动画结束回调函数 |
fail | Function | 否 | 接口调用失败的回调函数 |
includePoints 的 OBJECT 参数列表
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
points | Array | 是 | 要显示在可视区域内的坐标点列表,[{latitude, longitude}] |
padding | Array | 否 | 坐标点形成的矩形边缘到地图边缘的距离,单位像素。格式为[上,右,下,左],安卓上只能识别数组第一项,上下左右的padding一致。开发者工具暂不支持padding参数。 |
getRegion 的 OBJECT 参数列表
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
success | Function | 否 | 接口调用成功的回调函数,res = {southwest, northeast},西南角与东北角的经纬度 |
fail | Function | 否 | 接口调用失败的回调函数 |
complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
getScale 的 OBJECT 参数列表
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
success | Function | 否 | 接口调用成功的回调函数,res = {scale} |
fail | Function | 否 | 接口调用失败的回调函数 |
complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
示例代码:
// map.jsPage({ onReady: function (e) { // 使用 wx.createMapContext 获取 map 上下文 this.mapCtx = wx.createMapContext('myMap') }, getCenterLocation: function () { this.mapCtx.getCenterLocation({ success: function(res){ console.log(res.longitude) console.log(res.latitude) } }) }, moveToLocation: function () { this.mapCtx.moveToLocation() }, translateMarker: function() { this.mapCtx.translateMarker({ markerId: 0, autoRotate: true, duration: 1000, destination: { latitude:23.10229, longitude:113.3345211, }, animationEnd() { console.log('animation end') } }) }, includePoints: function() { this.mapCtx.includePoints({ padding: [10], points: [{ latitude:23.10229, longitude:113.3345211, }, { latitude:23.00229, longitude:113.3345211, }] }) }})
关于"微信小程序如何创建并返回map上下文mapContext对象"这篇文章的内容就介绍到这里,感谢各位的阅读!相信大家对"微信小程序如何创建并返回map上下文mapContext对象"知识都有一定的了解,大家如果还想学习更多知识,欢迎关注行业资讯频道。
参数
函数
接口
上下
组件
上下文
对象
成功
地图
类型
移动
程序
经纬
经纬度
知识
视野
位置
内容
动画
方法
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
aspmysql数据库
数据库运维试卷代码4046
四大中文数据库检索途径的比较
保护网络安全的图片
网络技术初学
广州大美网络技术有限公司
网络安全审查办法自哪年起实施
服务器 批量 管理
莆田市所的网络技术有限公司
网络安全攻击的一般步骤
网络技术安全保障工作
搜索数据库软件制作
达芬奇数据库不兼容怎么办
数据库查询分不清楚哪一列
mysql数据库锁表
谷歌服务器框架怎么下载
2012R服务器激活码
会计和数据库的结合
nfv网络安全
退役军人网络安全知识培训
cs柑露版服务器
服务器双光纤模式设置方法
服务器lE安全怎么降低
网络技术研究与应用毕业论文
ccd定位软件开发
ace元件数据库制造商
株洲java软件开发短期班
dts支持哪些环境下的数据库
我的世界beta版中国服务器
海康服务器如何进入安全模式