本小程序仿摩拜单车的地图显示和拖动部分,单车数据采用周边厕所模拟。index.wxml如下:
-
<map id="map" bindcontroltap="bindcontroltap" bindregionchange="bindregionchange"
longitude="{ {jd}}" latitude="{ {wd}}" markers="{ {markers}}" controls="{ {controls}}"
style="width: 100%; height: { {height}}px;" scale="16" show-location>
-
</map>
拖动地图,视野变化设置bindregionchange
页面加载时设置地图高度,control标注,头部广告及注册登录、返回当
前位置、优惠券、充值等。
-
wx.getSystemInfo({
-
success: function (res) {
-
maph = res.windowHeight
-
mapw = res.windowWidth
-
-
that.setData({
-
height: maph,
-
controls: [
-
{
-
id: 1,
-
iconPath: '../libs/banner.jpg',
-
position: {
-
left: 10,
-
top: 10,
-
width: 390,
-
height: 80
-
},
-
clickable: true
-
},
-
{
-
id: 2,
-
iconPath: '../libs/gps.jpg',
-
position: {
-
left: 10,
-
top: maph - 50,