這篇文章主要介紹了微信小程序 可搜索的地址選擇實現詳解,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
最終實現效果:

效果實現步驟
新建index文件夾
index.wxml
<!--pages/index/index.wxml--><view class='container'> <view bindtap='onChangeAddress'>  <input value="{{address}}" name="address" placeholder="選擇地點"> </view></view>index.js
// pages/index/index.jsPage({ data: {  address: '' }, onChangeAddress() {  var _page = this;  wx.chooseLocation({   success: (res) => {    _page.setData({     address: res.name    });   },   fail: (err) => {    console.log(err);   }  }); }})新建map文件夾
map.wxml
<!--pages/map/map.wxml--><view class="container"> <map  id="myMap"  style="width: 100%; height: 100%;"  latitude="{{latitude}}"  longitude="{{longitude}}"  markers="{{markers}}"  show-location ></map></view>map.js
// pages/map/map.jsPage({ data: {  latitude: 31.22786,  longitude: 121.46658,  markers: [{   id: 1,   latitude: 31.22786,   longitude: 121.46658,   name: '上海招商局廣場'  }] }, onReady(e) {  this.mapCtx = wx.createMapContext('myMap') }})以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。
新聞熱點
疑難解答