【2025年1月2日】关于腾讯云小程序平台更名为腾讯云超级应用服务的公告
控制台更新动态
Android SDK 更新动态
iOS SDK 更新动态
Flutter 更新动态
IDE 更新动态
基础库更新动态
<!-- map.wxml --><map id="myMap" show-location /><button type="primary" bindtap="getCenterLocation">获取位置</button><button type="primary" bindtap="moveToLocation">移动位置</button><button type="primary" bindtap="translateMarker">移动标注</button><button type="primary" bindtap="includePoints">缩放视野展示所有经纬度</button>
// 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,}]})}})
属性 | 类型 | 默认值 | 必填 | 说明 |
id | number | - | 是 | 圆弧 id |
start | Object | - | 是 | 起始点 |
end | Object | - | 是 | 终点 |
pass | Object | - | 否 | 途经点 |
angle | number | 0 | 否 | 夹角角度 |
width | number | 5 | 否 | 线宽 |
color | number | #000000 | 否 | 线的颜色 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
结构属性 | 类型 | 默认值 | 必填 | 说明 |
longitude | number | - | 是 | 经度 |
latitude | number | - | 是 | 纬度 |
结构属性 | 类型 | 默认值 | 必填 | 说明 |
longitude | number | - | 是 | 经度 |
latitude | number | - | 是 | 纬度 |
结构属性 | 类型 | 默认值 | 必填 | 说明 |
longitude | number | - | 是 | 经度 |
latitude | number | - | 是 | 纬度 |
属性 | 类型 | 默认值 | 必填 | 说明 |
layerId | string | - | 是 | 个性化图层id |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 默认值 | 必填 | 说明 |
id | String | - | 是 | 图片图层 id |
src | String | - | 是 | 图片路径,支持网络图片、临时路径、代码包路径 |
bounds | Object | - | 是 | 图片覆盖的经纬度范围 |
visible | Boolean | true | 否 | 是否可见 |
zIndex | Number | 1 | 否 | 图层绘制顺序 |
opacity | Number | 1 | 否 | 图层透明度 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
结构属性 | 类型 | 默认值 | 必填 | 说明 |
southwest | Object | - | 是 | 西南角经纬度 |
northeast | Object | - | 是 | 东北角经纬度 |
结构属性 | 类型 | 默认值 | 必填 | 说明 |
longitude | number | - | 是 | 经度 |
latitude | number | - | 是 | 纬度 |
结构属性 | 类型 | 默认值 | 必填 | 说明 |
longitude | number | - | 是 | 经度 |
latitude | number | - | 是 | 纬度 |
该 方法 使用方式为 MapContext.addMarkers(Object object)
属性 | 类型 | 默认值 | 必填 | 说明 |
markers | array | - | 是 | 同传入 map 组件的 marker 属性 |
clear | boolean | false | 否 | 是否先清空地图上所有 marker |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 默认值 | 必填 | 说明 |
lines | Array.<Object> | - | 是 | |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
结构属性 | 类型 | 默认值 | 必填 | 说明 |
id | number | - | 是 | 线段的 id |
index | number | - | 是 | 指定线段的某一段,线段起点 index 为0 |
point | Object | - | 是 | 指定线段某一段中的点 |
clear | boolean | true | 否 | 为 true 是擦除,false 是置灰 |
结构属性 | 类型 | 默认值 | 必填 | 说明 |
longitude | number | - | 是 | 经度 |
latitude | number | - | 是 | 纬度 |
属性 | 类型 | 默认值 | 必填 | 说明 |
x | number | - | 是 | x 坐标值 |
y | number | - | 是 | y 坐标值 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 说明 |
latitude | number | 纬度 |
longitude | number | 经度 |
属性 | 类型 | 默认值 | 必填 | 说明 |
iconPath | string | - | 否 | 图标路径,支持网络路径、本地路径、代码包路径 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 说明 |
longitude | number | 经度 |
latitude | number | 纬度 |
属性 | 类型 | 默认值 | 必填 | 说明 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 说明 |
southwest | object | 西南角经纬度 |
northeast | object | 东北角经纬度 |
结构属性 | 类型 | 说明 |
longitude | number | 经度 |
latitude | number | 纬度 |
结构属性 | 类型 | 说明 |
longitude | number | 经度 |
latitude | number | 纬度 |
属性 | 类型 | 默认值 | 必填 | 说明 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 说明 |
rotate | number | 旋转角 |
属性 | 类型 | 默认值 | 必填 | 说明 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 说明 |
scale | number | 缩放值 |
属性 | 类型 | 默认值 | 必填 | 说明 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 说明 |
skew | number | 倾斜角 |
属性 | 类型 | 默认值 | 必填 | 说明 |
points | array.<Object> | - | 是 | 要显示在可视区域内的坐标点列表 |
padding | array.<number> | - | 否 | 坐标点形成的矩形边缘到地图边缘的距离,单位:像素。格式为[上,右,下,左],Android 上只能识别数组第一项,上下左右的 padding 一致。开发者工具暂不支持 padding 参数。 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
结构属性 | 类型 | 默认值 | 必填 | 说明 |
longitude | number | - | 是 | 经度 |
latitude | number | - | 是 | 纬度 |
属性 | 类型 | 默认值 | 必填 | 说明 |
enableDefaultStyle | boolean | true | 否 | 启用默认的聚合样式 |
zoomOnClick | boolean | true | 否 | 点击已经聚合的标记点时是否实现聚合分离 |
gridSize | number | 60 | 否 | 聚合算法的可聚合距离,即距离小于该值的点会聚合至一起,以像素为单位 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
marker,用于轨迹回放等场景。动画完成时触发回调事件,若动画进行中,对同一 marker 再次调用 moveAlong 方法,前一次的动画将被打断。属性 | 类型 | 默认值 | 必填 | 说明 |
markerId | number | - | 是 | 指定 marker |
path | array | - | 是 | 移动路径的坐标串,坐标点格式 {longitude, latitude} |
autoRotate | boolean | true | 否 | 根据路径方向自动改变 marker 的旋转角度 |
duration | number | - | 是 | 平滑移动的时间 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 默认值 | 必填 | 说明 |
longitude | number | - | 否 | 经度 |
latitude | number | - | 否 | 纬度 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
参数 | 类型 | 说明 |
layerId | String | 图层 id |
eventType | String | 事件类型 |
eventInfo | String | 事件信息 |
参数 | 类型 | 说明 |
clusters | Array<ClusterInfo> | 聚合簇数据 |
参数 | 类型 | 说明 |
cluster | ClusterInfo | 聚合簇 |
参数 | 类型 | 说明 |
clusterId | Number | 聚合簇的 id |
center | LatLng | 聚合簇的坐标 |
markerIds | Array<Number> | 该聚合簇内的点标记数据数组 |
MapContext.on('visualLayerEvent', (res) => {})MapContext.on('markerClusterCreate', (res) => {})MapContext.on('markerClusterClick', (res) => {})
属性 | 类型 | 默认值 | 必填 | 说明 |
longitude | number | - | 是 | 目的地经度 |
latitude | number | - | 是 | 目的地纬度 |
destination | string | - | 是 | 目的地名称 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 默认值 | 必填 | 说明 |
id | number | - | 是 | 圆弧 id |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 默认值 | 必填 | 说明 |
layerId | string | - | 是 | 个性化图层id |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 默认值 | 必填 | 说明 |
id | String | - | 是 | 图片图层 id |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 默认值 | 必填 | 说明 |
markerIds | array | - | 是 | marker 的 id 集合。 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 默认值 | 必填 | 说明 |
southwest | Object | - | 是 | 西南角经纬度 |
northeast | Object | - | 是 | 东北角经纬度 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
结构属性 | 类型 | 默认值 | 必填 | 说明 |
longitude | number | - | 是 | 经度 |
latitude | number | - | 是 | 纬度 |
结构属性 | 类型 | 默认值 | 必填 | 说明 |
longitude | number | - | 是 | 经度 |
latitude | number | - | 是 | 纬度 |
属性 | 类型 | 默认值 | 必填 | 说明 |
offset | Array.<number> | - | 是 | 偏移量,两位数组 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 默认值 | 必填 | 说明 |
iconPath | string | - | 否 | 图标路径,支持网络路径、本地路径、代码包路径 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 默认值 | 必填 | 说明 |
latitude | number | - | 是 | 纬度 |
longitude | number | - | 是 | 经度 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 说明 |
x | number | x 坐标值 |
y | number | y 坐标值 |
属性 | 类型 | 默认值 | 必填 | 说明 |
markerId | number | - | 是 | 指定 marker |
destination | object | - | 是 | 指定 marker 移动到的目标点 |
animationEnd | function | - | 否 | 动画结束回调函数 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
结构属性 | 类型 | 默认值 | 必填 | 说明 |
longitude | number | - | 是 | 经度 |
latitude | number | - | 是 | 纬度 |
属性 | 类型 | 默认值 | 必填 | 说明 |
id | string | - | 是 | 图片图层 id |
src | string | - | 是 | 图片路径,支持网络图片、临时路径、代码包路径 |
bounds | object | - | 是 | 图片覆盖的经纬度范围 |
visible | boolean | true | 否 | 是否可见 |
zIndex | number | 1 | 否 | 图层绘制顺序 |
opacity | number | 1 | 否 | 图层透明度 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
结构属性 | 类型 | 默认值 | 必填 | 说明 |
southwest | Object | - | 是 | 西南角经纬度 |
northeast | Object | - | 是 | 东北角经纬度 |
结构属性 | 类型 | 默认值 | 必填 | 说明 |
longitude | number | - | 是 | 经度 |
latitude | number | - | 是 | 纬度 |
结构属性 | 类型 | 默认值 | 必填 | 说明 |
longitude | number | - | 是 | 经度 |
latitude | number | - | 是 | 纬度 |
属性 | 类型 | 默认值 | 必填 | 说明 |
region | string | - | 是 | |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 说明 |
taskId | string | 任务 ID |
属性 | 类型 | 默认值 | 必填 | 说明 |
taskId | string | - | 是 | 任务 ID |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 默认值 | 必填 | 说明 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 说明 |
id | string | 离线包唯一 ID |
region | string | 区域名称 |
size | number | 包大小(字节) |
属性 | 类型 | 默认值 | 必填 | 说明 |
id | string | - | 是 | 需要删除的离线包ID |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 说明 |
id | string | 离线包唯一 ID |
region | string | 区域名称 |
size | number | 包大小(字节) |
属性 | 类型 | 说明 |
taskId | string | 任务 ID |
region | string | 区域名称 |
id | string | 离线包唯一 ID |
size | number | 包大小(字节) |
属性 | 类型 | 说明 |
taskId | string | 任务 ID |
region | string | 区域名称 |
error | object | 失败原因 |
属性 | 类型 | 默认值 | 必填 | 说明 |
sourceUrlFormat | string | - | 是 | 瓦片数据路径格式(支持网络地址、APP沙盒路径地址、小程序沙盒路径地址) 注意:在线地址需要在控制台上配置DownloadFile白名单。 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 说明 |
layerId | string | 自定义瓦片图层ID |
参数名 | 说明 |
x | 经度 |
y | 纬度 |
z | 缩放级别 |
// createLayercreateLayer: function () {const mapContext = wx.createMapContext('customMap');mapContext.addTileLayer({sourceUrlFormat: 'http://x.x.x.x/{z}/{y}/{x}',success: (res) => {console.log('addTileLayer success', res);},fail: (res) => {console.log('addTileLayer fail', res);}})}
// downloadAndCreateLayerdownloadAndCreateLayer: function () {console.log(wx.env.USER_DATA_PATH)wx.downloadFile({url: 'http://x.x.x.x/download',success: (res) => {console.log('downloadFile success', res);const tempFilePath = res.tempFilePath;const targetPath = wx.env.USER_DATA_PATH + '/customFile';console.log('targetPath', targetPath);const systemManager = wx.getFileSystemManager();systemManager.unzip({zipFilePath: tempFilePath,targetPath: targetPath,success: (res) => {console.log('unzip success', res);const sourceUrlFormat = `${targetPath}/{z}/{y}/{x}`;console.log('sourceUrlFormat', sourceUrlFormat);this.mapContext.addTileLayer({sourceUrlFormat,success: (res) => {console.log('addTileLayer success', res);},fail: (res) => {console.log('addTileLayer fail', res);}})}})},onfail: (res) => {console.log('downloadFile fail', res);}})},
属性 | 类型 | 默认值 | 必填 | 说明 |
layerId | string | - | 是 | 自定义瓦片图层ID |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 默认值 | 必填 | 说明 |
layerId | string | - | 是 | 自定义瓦片图层ID |
visible | boolean | - | 是 | 是否可见 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
文档反馈