程序是在微信小程序实现的
1:概括
腾讯地图使用api:apihttps://lbs.qq.com/miniProgram/jsSdk/jsSdkGuide/jsSdkOverview
关键是,申请密钥,在小程序中要使用。
2:室外地图
当你进入室内地图,提醒你是否切换到室内地图
wxml
<map
id="map"
longitude="{
{longitude}}"
latitude='{
{latitude}}'
scale='18'
show-location
markers='{
{markers}}'
subkey="自己申请的key"
style="height: {
{height}}px;">
</map>
<view class="button-position"></view>
js
Page({
data: {
height: 0,
longitude: 0,
latitude: 0,
markers: [],
posTimer: null,
timeGap: 10000
},
onLoad: function (options) {
const _this = this;
// 获取系统高度,设置地图尺寸
wx.getSystemInfo({
success: function (res) {
_this.setData({
height: res.windowHeight
})
},
});
// 获取当前定位
wx.getLocation({
type: 'gcj02',
success(res) {
_this.setData({
longitude: res.longitude,
latitude: res.latitude
})
console.log(res.longitude+"jjj"+res.latitude)
}
});
// 读取缓存中的配置文件
wx.getStorage({
key: 'config',
success(res) {
const data = res.data;
_this.setData({
outdoorTimeGap: Number(data.outdoorTimeGap) * 1000
});
},
fail(res) {
console.warn('配置文件读取失败!');
}
});
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
let isGoIndoor = true,
_this = this;
const timer = setInterval(function () {
wx.getLocation({
type: 'gcj02',
success: function (res) {
if(res.longitude>105 && res.longitude<115 &&