<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
        主站蜘蛛池模板: 亚洲日韩aⅴ在线视频| 亚洲A丁香五香天堂网| 亚洲色成人网一二三区| a级毛片高清免费视频就| 亚洲宅男天堂在线观看无病毒| 一级视频在线免费观看| 2048亚洲精品国产| baoyu116.永久免费视频| 亚洲国产综合无码一区| 久久国产免费一区二区三区| 91天堂素人精品系列全集亚洲 | 一级毛片无遮挡免费全部| 亚洲第一网站男人都懂| 国产三级在线免费观看| 亚洲AV日韩精品久久久久久久| 成全高清在线观看免费| 亚洲小视频在线播放| 四虎在线视频免费观看| 免费大片黄在线观看| 国产亚洲一区二区精品| 精品熟女少妇av免费久久| 亚洲成a人片在线看| 全部免费a级毛片| 男女一进一出抽搐免费视频| 久久亚洲国产视频| 国产麻豆视频免费观看| 国产精品亚洲色图| 国产国拍亚洲精品mv在线观看| 黄在线观看www免费看| 免费精品国产自产拍在线观看 | 亚洲a级片在线观看| 国产精品va无码免费麻豆| 精品国产污污免费网站入口| 久久久久亚洲AV无码观看| 国产精品美女自在线观看免费| 本道天堂成在人线av无码免费| 亚洲第一页在线观看| 亚洲AV蜜桃永久无码精品| 蜜桃视频在线观看免费视频网站WWW| 亚洲中文无码永久免费| 亚洲精品中文字幕乱码三区 |