在此之前,采用了高德地图微信小程序API实现路线规划,但是由于公交路线规划不够准确,同时没有做转车等显示,所以这里补加微信小程序wx.openLoaction实现该效果!
width="560" height="315" src="http://rattenking.gitee.io/stone/video/rtpn.mp4" allowfullscreen="">
<map class="rui-rtpn-map" markers="{{markers}}" longitude="{{longitude}}" latitude="{{latitude}}">
<cover-view class='rui-rtpn-location' bindtap='openLocation' style='background:#fff url({{iconPath.iconLocation}}) no-repeat center center/10vw 10vw;'></cover-view>
</map>
// pages/map/map.js
const iconPath = require('../../utils/iconPath.js');
Page({
data: {
latitude: 30.5427,
longitude: 104.0527,
markers: [{
id: 1,
latitude: 30.5427,
longitude: 104.0527
}]
},
onLoad () {
this.setData({ iconPath: iconPath})
this.openLocation();
},
openLocation(){
wx.openLocation({
latitude: this.data.latitude,
longitude: this.data.longitude,
scale: 28,
name: '西部电信中心',
address: '益州大道1666号'
})
}
})
.rui-rtpn-map{
width: 100vw;
height: 100vh;
position: relative;
}
.rui-rtpn-location{
width: 15vw;
height: 15vw;
border-radius: 50%;
position: absolute;
bottom: 12vw;
right: 2vw;
border: 1px solid #1296db;
z-index: 10;
}