<thead id="jxdzp"><address id="jxdzp"><pre id="jxdzp"></pre></address></thead>

<em id="jxdzp"><span id="jxdzp"></span></em>

    <listing id="jxdzp"><nobr id="jxdzp"><meter id="jxdzp"></meter></nobr></listing>

      <address id="jxdzp"></address>
      <noframes id="jxdzp"><form id="jxdzp"><th id="jxdzp"></th></form>
      <noframes id="jxdzp"><form id="jxdzp"><th id="jxdzp"></th></form>

          訂閱本欄目 RSS您所在的位置: 深山工作室 > uni-app > 正文

          uni-app用map組件建立微信小程序顯示商家地圖位置并且打上標志然后點標志進行調用手機地圖導航到對應的地址

          2021/3/17 0:30:25 字體: 瀏覽 4270





          <map
          id="map"
          :longitude="map_longitude"
          :latitude="map_latitude"
          :markers="map_alllist"
          @markertap="markertap"
          @regionchange="regionchange"
          scale="14"
          show-location
          class="map_cont"
          style="width:100%;height:500rpx;"></map>


          01. 請看一下這個下面是map_alldata的數據:
          "mapdian_arrdata": [{
              "data_state": "success",
              "data_list": [{
                      "id": 0,
                      "latitude": "34.719604",
                      "longitude": "119.346886",
                      "width": "50",
                      "height": "50",
                      "iconPath": "http://192.168.0.108/images/pub/location.png",
                      "title": "深山工作室",
                  },
                  {
                      "id": 1,
                      "latitude": "34.728070",
                      "longitude": "119.334869",
                      "width": "50",
                      "height": "50",
                      "iconPath": "http://192.168.0.108/images/pub/location.png",
                      "title": "深山游有限公司",
                  }
              ]
          }],
             

          02. 多個地圖切換
          <scroll-view class="list_daomenu" scroll-x="true">
              <view class="l_li" v-for="(item, index) in map_alldata.data_list" :key="index">
                  <view @tap="gotonewmap('index',item.id)" :class="['l_text',dizi_id == item.id?'hover':'']">{{item.mcomname}}</view>
              </view>
          </scroll-view>


          <!-- 這下面代碼是為了當上面代碼切換公司名稱時,跳出相應的地址與聯系電話 -->
          <view class="com_data" v-if="gs_phone || gs_home">
              <view class="l_li l_phone"><text class="l_sub" @tap="call_phone('' + gs_phone)">點擊撥打電話</text><text @tap="call_phone('' + gs_phone)">{{gs_phone}}</text></view>
              <view class="l_li l_home"><text class="l_sub" @tap="navigate()">點擊導航到</text><text>{{gs_home}}</text></view>
          </view>



          03. 請看一下data里面的數據

          data() {
                return {
                    map_alldata: '',
                    map_alllist: [{"id": 0,"latitude": "34.719604","longitude": "119.346886","width": "50","height": "50","iconPath": "http://192.168.0.108/images/pub/location.png","title": "深山工作室"},{"id": 1,"latitude": "34.728070","longitude": "119.334869","width": "50","height": "50","iconPath": "http://192.168.0.108/images/pub/location.png","title": "深山有限公司",}],
                    map_latitude: '',
                    map_longitude: '',
                    go_latitude: '',
                    go_longitude: '',
                    dizi_id: 0,
                    gs_title: '',
                    gs_phone: '',
                    gs_home: '',
                }
            },


          04. 這里是處理方式


          methods: {
            //打電話
            call_phone: function(bphone) {
                uni.makePhoneCall({
                    phoneNumber: '' + bphone, // 手機號
                });
            },
            //解析對應的地址信息,電話,信息
            map_jiexi: function(dt_id) {
                _self.map_latitude = _self.map_alllist[dt_id].latitude;
                _self.map_longitude = _self.map_alllist[dt_id].longitude;
                _self.go_latitude = _self.map_latitude;
                _self.go_longitude = _self.map_longitude;
                _self.gs_title = _self.map_alllist[dt_id].mcomname;
                _self.gs_phone = _self.map_alllist[dt_id].mcomphone;
                _self.gs_phone1 = _self.map_alllist[dt_id].mcomphone1;
                _self.gs_phone2 = _self.map_alllist[dt_id].mcomphone2;
                _self.gs_phone3 = _self.map_alllist[dt_id].mcomphone3;
                _self.gs_phone4 = _self.map_alllist[dt_id].mcomphone4;
                _self.gs_home = _self.map_alllist[dt_id].mcomhome;
            },

            //點擊地圖標點時觸發事件
            markertap: function(res) {
                let ditu_id = res.detail.markerId;
                _self.dizi_id = ditu_id;
                this.map_jiexi(ditu_id);
            },
            //點擊地圖轉到導航
            navigate: function() {
                uni.openLocation({
                    latitude: Number(_self.go_latitude), //要去的緯度-地址-如果放字符型會出錯,必須要用Number
                    longitude: Number(_self.go_longitude), //要去的經度-地址
                    name: '' + _self.gs_title,
                    address: '' + _self.gs_home,
                    success: function() {
                        console.log('success');
                    }
                })
            },

            //多個地址切換時,更新地圖信息
            gotonewmap: function(fansi, ditu_id) {
                _self.dizi_id = ditu_id;
                this.map_jiexi(ditu_id);
            },
           
           
           

          相關閱讀
          html表單里面的label詳細
          js指定日期加n天加n月加n年
          uni-app開發的微信小程序在線支付
          針對table,div隔行變色的JS方法
          uni-app跨端開發微信小程序時頁面棧超過10層時小程序像卡死一樣假性不能點擊無法跳轉的解決方案
          Html中的Frame詳解
          游戲-植物大戰僵尸留言板模板
          asp實現獲得當前文章的上一篇信息與下一篇信息功能及代碼
          共有0條關于《uni-app用map組件建立微信小程序顯示商家地圖位置并且打上標志然后點標志進行調用手機地圖導航到對應的地址》的評論
          發表評論
          正在加載評論......
          返回頂部發表評論
          呢 稱:
          表 情:
          內 容:
          評論內容:不能超過 1000 字,需審核,請自覺遵守互聯網相關政策法規。
          驗證碼: 驗證碼 
          網友評論聲明,請自覺遵守互聯網相關政策法規。

          您發布的評論即表示同意遵守以下條款:
          一、不得利用本站危害國家安全、泄露國家秘密,不得侵犯國家、社會、集體和公民的合法權益;
          二、不得發布國家法律、法規明令禁止的內容;互相尊重,對自己在本站的言論和行為負責;
          三、本站對您所發布內容擁有處置權。

          更多信息>>欄目類別選擇
          百度小程序開發
          微信小程序開發
          微信公眾號開發
          uni-app
          asp函數庫
          ASP
          DIV+CSS
          HTML
          python
          更多>>同類信息
          uni-app開發表單input組件的一些規則說明自己預留使用
          uni-app:使用uni.downloadFile下載word或pdf文件并保存到手機
          小程序中利用addPhoneContact將聯系人的信息添加到手機通訊錄支持保存聯系人頭像
          微信小程序打開客服提示:該小程序提供的服務出現故障,請稍后重試
          微信小程序客服會話只能過button讓用戶主動觸發
          uni-app開發微信小程序使用button的open-type為contact調用微信客服不能用view或者js調用
          更多>>最新添加文章
          dw里面查找替換使用正則刪除sqlserver里面的CONSTRAINT
          Android移動端自動化測試:使用UIAutomatorViewer與Selenium定位元素
          抖音直播音掛載小雪花 懂車帝小程序
          javascript獲取瀏覽器指紋可以用來做投票
          火狐Mozilla Firefox出現:無法載入您的Firefox配置文件 它可能已經丟失 或是無法訪問 問題解決集合處理辦法
          在Android、iOS、Windows、MacOS中微信小程序的文件存放路徑
          python通過代碼修改pip下載源讓下載庫飛起
          python里面requests.post返回的res.text還有其它的嗎
          更多>>隨機抽取信息
          css優先級的例子
          asp采用access數據庫搜索信息時因為日文片假名問題提示“Microsoft JET Database Engine 錯誤80040e14”的解決方法
          這個可以做為論壇,也可以做留言板
          仿百度知道寬度高度自適應的圓角邊框
          連云港旅游協會
          網頁制作中注意應用HTML標簽的問題
          88国产精品视频一区二区三区