在小程序中使用腾讯地图卫星地图需要以下步骤:
1. 在小程序的 app.json 文件中添加权限配置:
```json
{
"mp-locations": {
"scope": "scope.userLocation"
}
}
```
2. 在对应页面的 wxml 中添加地图组件
```html
<map id="map"
latitude="{{latitude}}"
longitude="{{longitude}}"
scale="{{scale}}"
markers="{{markers}}"
show-location="{{showLocation}}"
show-compass="{{showCompass}}"
enable-overlooking="{{enableOverlooking}}"
enable-zoom="{{enableZoom}}"
enable-scroll="{{enableScroll}}"
style="width: 100%; height: 100%;"></map>
```
3. 在对应页面的 js 文件中引入腾讯地图 SDK 并设置卫星地图:
```javascript
const QQMapWX = require('../../utils/qqmap-wx-jssdk.min.js')
Page({
data: {
latitude: 39.984060,
longitude: 116.307520,
scale: 15,
markers: [],
showLocation: true,
showCompass: true,
enableOverlooking: true,
enableZoom: true,
enableScroll: true
},
onReady: function () {
const mapCtx = wx.createMapContext('map')
this.qqmapsdk = new QQMapWX({
key: '你的腾讯地图 Key'
})
this.qqmapsdk.getSatelliteMap({
success: function (res) {
mapCtx.setMapStyle({
style: res.result.style_id
})
}
})
}
})
```
其中,腾讯地图API Key 可以在腾讯位置服务官网(lbs.qq.com)上申请。