• <fieldset id="8imwq"><menu id="8imwq"></menu></fieldset>
  • <bdo id="8imwq"><input id="8imwq"></input></bdo>
    最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
    問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
    當前位置: 首頁 - 科技 - 知識百科 - 正文

    微信小程序map組件結合高德地圖API實現wx.chooseLocation功能示例

    來源:懂視網 責編:小采 時間:2020-11-27 22:01:38
    文檔

    微信小程序map組件結合高德地圖API實現wx.chooseLocation功能示例

    微信小程序map組件結合高德地圖API實現wx.chooseLocation功能示例:本文實例講述了微信小程序map組件結合高德地圖API實現wx.chooseLocation功能。分享給大家供大家參考,具體如下: 聲明 bug: 頁面搜索返回的列表在真機測試是會出現不顯示問題? 造成原因:在小程序map組件的同一區域,map組件的視圖層比普通的文本視圖層
    推薦度:
    導讀微信小程序map組件結合高德地圖API實現wx.chooseLocation功能示例:本文實例講述了微信小程序map組件結合高德地圖API實現wx.chooseLocation功能。分享給大家供大家參考,具體如下: 聲明 bug: 頁面搜索返回的列表在真機測試是會出現不顯示問題? 造成原因:在小程序map組件的同一區域,map組件的視圖層比普通的文本視圖層

    WXML

    <view class="map-inputtips-input">
     <input bindinput="bindInput" placeholder="搜索" focus="true" />
    </view>
    <view class="map_container">
     <map class="map" latitude='{{latitude}}' longitude='{{longitude}}' markers='{{markers}}'>
     <cover-view class="map-search-list {{isShow ? '' : 'map-hide'}}">
     <cover-view bindtouchstart="bindSearch" wx:key="searchId" data-keywords="{{item.name}}" data-location="{{item.location}}" class="map-box" wx:for="{{tips}}">
     {{item.name}}
     </cover-view>
     </cover-view>
     </map>
    </view>
    
    

    WXSS

    .map-inputtips-input{
     height: 80rpx;
     line-height: 80rpx;
     width: 100%;
     box-sizing: border-box;
     font-size: 30rpx;
     padding: 0 10px;
     background-color: #fff;
     position: fixed;
     top: 0;
     left: 0;
     z-index: 1000;
     border-bottom:1px solid #c3c3c3;
    }
    .map-inputtips-input input{
     border: 1px solid #ddd;
     border-radius: 5px;
     height: 60rpx;
     line-height: 60rpx;
     width: 100%;
     box-sizing: border-box;
     padding: 0 5px;
     margin-top: 10rpx;
    }
    .map-box{
     margin: 0 10px;
     border-bottom:1px solid #c3c3c3;
     height: 80rpx;
     line-height: 80rpx;
    }
    .map-box:last-child{border: none;}
    .map-search-list{
     position: fixed;
     top: 80rpx;
     left: 0;
     width: 100%;
     z-index: 1000;
     background-color: #fff;
    }
    
    

    JS

    const app = getApp();
    const amap = app.data.amap;
    const key = app.data.key;
    Page({
     data: {
     isShow: false,
     tips: {},
     longitude: '',
     latitude: '',
     markers: []
     },
     onLoad() {
     var _this = this;
     wx.getLocation({
     success: function(res) {
     if (res && res.longitude){
     _this.setData({
     longitude: res.longitude,
     latitude: res.latitude,
     markers:[{
     id:0,
     longitude: res.longitude,
     latitude: res.latitude,
     iconPath: '../../src/images/ding.png',
     width:32,
     height:32
     }]
     })
     }
     }
     })
     },
     bindInput: function (e) {
     var _this = this;
     var keywords = e.detail.value;
     var myAmap = new amap.AMapWX({ key: key });
     myAmap.getInputtips({
     keywords: keywords,
     location: '',
     success: function (res) {
     if (res && res.tips) {
     _this.setData({
     isShow: true,
     tips: res.tips
     });
     }
     }
     })
     },
     bindSearch: function (e) {
     var keywords = e.target.dataset.keywords;
     var location = e.target.dataset.location.split(',');
     this.setData({
     isShow: false,
     longitude: location[0],
     latitude: location[1],
     markers: [{
     id: 0,
     longitude: location[0],
     latitude: location[1],
     iconPath: '../../src/images/ding.png',
     width: 32,
     height: 32,
     anchor: { x: .5, y: 1 },
     label: {
     content: keywords,
     color: 'blue',
     fontSize: 12,
     borderRadius: 5,
     bgColor: '#fff',
     padding: 3,
     x: 0,
     y: -50,
     textAlign: 'center'
     }
     }]
     })
     }
    })
    
    

    總結

    1. 輸入框事件獲取關鍵字,通過關鍵字獲取展示列表;

    2. 列表選擇事件,獲取對應的location,并通過map組件的 markers 屬性標記該坐標。

    希望本文所述對大家微信小程序開發有所幫助。

    聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

    文檔

    微信小程序map組件結合高德地圖API實現wx.chooseLocation功能示例

    微信小程序map組件結合高德地圖API實現wx.chooseLocation功能示例:本文實例講述了微信小程序map組件結合高德地圖API實現wx.chooseLocation功能。分享給大家供大家參考,具體如下: 聲明 bug: 頁面搜索返回的列表在真機測試是會出現不顯示問題? 造成原因:在小程序map組件的同一區域,map組件的視圖層比普通的文本視圖層
    推薦度:
    • 熱門焦點

    最新推薦

    猜你喜歡

    熱門推薦

    專題
    Top
    主站蜘蛛池模板: 国产精品无码a∨精品| 91精品国产品国语在线不卡| 国产精品亚洲精品观看不卡| 久久精品亚洲欧美日韩久久| 热99re久久国超精品首页| 久久亚洲精品国产精品| 欧美日韩精品一区二区三区不卡| 久久久精品一区二区三区| 国产精品无码AV一区二区三区| 亚洲精品一品区二品区三品区| 久久噜噜久久久精品66| 国产精品九九九| 四虎精品8848ys一区二区| 国产精品自拍一区| 国产精品国产三级国产专播 | 亚洲精品国产成人专区| 国产欧美日韩精品a在线观看| 无码精品人妻一区二区三区漫画| 久久久久亚洲精品天堂久久久久久| 国产成人精品午夜福麻豆| 老司机国内精品久久久久| 国产精品久久自在自线观看| AV无码精品一区二区三区| 国产精品视频一区二区三区无码| 亚洲AV无码久久精品色欲| 午夜精品久久久久久99热| 亚洲精品无码久久久久| 最新国产精品无码| 亚洲第一极品精品无码久久| 伊人久久精品无码二区麻豆| 亚洲成网777777国产精品| 亚洲精品乱码久久久久久不卡| 午夜亚洲av永久无码精品| 日韩精品一二三区| 亚洲精品国产精品乱码不卡| 亚洲精品少妇30p| 久久亚洲国产成人精品性色| 久久精品亚洲一区二区三区浴池| 久久精品亚洲一区二区三区浴池 | 三级国产精品| 中文精品人人永久免费|