<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答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
        主站蜘蛛池模板: 一级毛片免费全部播放| 久久er国产精品免费观看2| 一边摸一边爽一边叫床免费视频| 免费无码午夜福利片69| 色猫咪免费人成网站在线观看| 九九精品免费视频| 亚洲综合网站色欲色欲| 亚洲国产综合人成综合网站00| 爱情岛亚洲论坛在线观看| 永久免费视频网站在线观看| 国产乱辈通伦影片在线播放亚洲| 久久亚洲春色中文字幕久久久| 黄色网址免费在线| 色窝窝免费一区二区三区| 亚洲精品456播放| 亚洲乱妇熟女爽到高潮的片| 久99久精品免费视频热77| 亚洲自偷自偷精品| 久久精品网站免费观看| 亚洲久热无码av中文字幕| 免费观看国产小粉嫩喷水| 亚洲一区精彩视频| 美女内射无套日韩免费播放| 亚洲一级Av无码毛片久久精品| 美女视频黄免费亚洲| **真实毛片免费观看| 亚洲色成人网站WWW永久四虎| 一个人免费日韩不卡视频| 亚洲国产精品日韩在线| 国产在线观看免费完整版中文版 | 亚洲最大的视频网站| 日本妇人成熟免费中文字幕| 国产精品亚洲一区二区无码 | 亚洲国产精品无码av| 一级毛片成人免费看a| 亚洲国产一二三精品无码| 中文毛片无遮挡高清免费| 亚洲色图综合在线| 日本免费一区二区在线观看| 亚洲国产精品成人久久久| 四虎永久精品免费观看|