這個城市看過美也看過丑陋,看過豪華的當然更多是簡陋,我們試着在這鋼筋結構中,搓出一點火星將渴望自由靈魂解救
詳細請參考: https://developers.weixin.qq.com/miniprogram/dev/component/map.html
當前頁面中直接使用map標簽
地圖撐滿全屏
經緯度顯示當前位置
詳情請參考: https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.getLocation.html
地圖控件
詳細請查看: https://developers.weixin.qq.com/miniprogram/dev/component/map.html
讓地圖控件顯示在我的位置的中間 當前屏幕寬度-圖片一半 獲取小程序當前寬高度 (在全局中獲取) wx.getSystemInfo({})
https://developers.weixin.qq.com/miniprogram/dev/api/base/system/system-info/wx.getSystemInfo.html
實現位置變化(需要獲取實例)
拖動后返回自己的位置這時候需要第二個圖標了添加事件
點擊回到初始位置必須要有一個id值(事件已經在map標簽中產生了,自帶的) https://developers.weixin.qq.com/miniprogram/dev/api/media/map/wx.createMapContext.html MapContext.moveToLocation({})需要配合圖標使用 它是地圖控件所以要創建地圖的實例對象才能使用wx.createMapContext 通過wx.createMapContext在使用的頁面加載中就要創建