国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

微信小程序map視野發(fā)生改變時切換定位點

這篇具有很好參考價值的文章主要介紹了微信小程序map視野發(fā)生改變時切換定位點。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

微信小程序地圖視角移動到指定位置,微信小程序,notepad++,小程序

微信小程序地圖視角移動到指定位置,微信小程序,notepad++,小程序

<!--地圖-->
<view>
  <map id="myMap" style="width: 100%; height: 300px;" 
    latitude="{{latitude}}" longitude="{{longitude}}"
    scale="{{scale}}" markers="{{markers}}" controls="{{controls}}" 
    bindmarkertap="markertap" show-location="{{true}}" 
    bindregionchange="regionchange">
  </map>
</view>
<view class="xzwzxx">
  <view class="zcwzbt">您選中的位置:</view>
  <view class="xzwz">{{address}}</view>
</view>
<scroll-view scroll-top="{{scrollTop}}" scroll-y="true" class="dwlist">
  <view class="mapList">
    <block wx:for="{{markersList}}">
      <view class="{{index== iconSY ? 'dianweiList xzico' :'dianweiList'}}" bindtap='XZlist' data-rem="{{item}}"
        data-sy="{{index}}">
        <view class="mark_img">
          <image src="../../images/blue_location.png" class="DWimg"></image>
        </view>
        <view class="dwxq">
          <view>{{item.name}}</view>
          <view>{{item.address}}</view>
        </view>
      </view>
    </block>

  </view>
</scroll-view>
<view class="qrxd">
  <button class="qdbutton" bindtap="rqxd">確認選點</button>
</view>

css

.map_container{width:100%;overflow:hidden;height: 50vh; width: 100%;}
.map{width:100%;height:100%}
.mapList{background:#fff;padding:2.5%;}
.dianweiList{ min-height: 80rpx; display: flex; align-items: center; margin-bottom: 15rpx;}
.mark_img{ width: 60rpx; text-align: center;}
.DWimg{ width:32rpx; height: 42rpx;}
.dwxq{ border-bottom: 1px #f0f1f3 solid; min-height: 80rpx; width: 100%; padding-bottom: 10rpx;}
.xzico{ color: #3370ff;}
.xzwzxx{padding-bottom: 20rpx; width: 95%; margin: 0 auto;}
.zcwzbt{ color: #333; font-weight: 600; line-height: 60rpx;}
.xzwz{ color: #666;}
.dwlist{ height: 30vh;}
.qrxd{ position: fixed; bottom: 0px;height:80rpx; background: #fff; z-index: 100; width: 100%;}
.qdbutton{border:0px;height: 70rpx; line-height:70rpx;border-radius: 70rpx;  background: #4c8cee;width:500rpx;color: #fff; font-size: 24rpx;}
.qdbutton::after{border: 0px !important;}

js文章來源地址http://www.zghlxwxcb.cn/news/detail-776238.html

 var amapFile = require('../../utils/amap-wx.130');
 var key = "4f56f0e40338315d0f383f17637f5896";
 var markersData = [];
 var myAmapFun = new amapFile.AMapWX({
   key: key
 });
 Page({
   data: {
     latitude: 38.02604953342014, // 初始緯度
     longitude: 114.39047607421875, // 初始經(jīng)度
     scale: 16, // 初始縮放級別
     markers: [{
       id: 0,
       latitude: 38.02604953342014,
       longitude: 114.39047607421875,
       width: 20,
       height: 30
     }], // 標記點
     controls: [], // 地圖控件
   },

   onLoad: function (options) {
     var that = this;
     //獲取當前位置  
     this.setData({
      //  latitude: options.lat,
      //  longitude: options.lon,
      latitude: 38.02604953342014,
      longitude: 114.39047607421875,
     });
     that.showMap(that.data.longitude, that.data.latitude);
   },
   //顯示地圖
   showMap: function (longitude, latitude) {
     var that = this;
     let markers = [{
       id: 0,
       latitude: latitude,
       longitude: longitude,
       width: 20,
       height: 30
     }]
     this.setData({
       markers: markers,
     });
     var location = `${longitude},${latitude}`   
     myAmapFun.getRegeo({
       //如果經(jīng)緯度有問題會導致不進入回調(diào)方法,從而報錯
       location: location,
       success: function (e) {
         let csdz = e[0].regeocodeData.addressComponent
         let shencz = csdz.province + csdz.city + csdz.district
         //成功回調(diào)
         that.setData({
           address: e[0].name, //詳細地址,
           markersList: e[0].regeocodeData.pois,
           shenName: shencz
         });
       },
       fail: function (info) {
         //失敗回調(diào)
         console.log(info)
       }
     })
   },

   markertap: function (e) {
     // 標記點被點擊時觸發(fā)的事件
     console.log(e.markerId);
   },
   regionchange: function (e) {
     let that = this
     console.log(e)
     if (e.causedBy == 'drag') {
       let nmarkers = [{
         id: 1001,
         latitude: e.detail.centerLocation.latitude,
         longitude: e.detail.centerLocation.longitude,
         width: 20,
         height: 30
       }]
       that.setData({
         latitude: e.detail.centerLocation.latitude,
         longitude: e.detail.centerLocation.longitude,
         markers: nmarkers,
       })
       //解析經(jīng)緯度
       that.location = `${e.detail.centerLocation.longitude},${e.detail.centerLocation.latitude}`
       myAmapFun.getRegeo({
         //如果經(jīng)緯度有問題會導致不進入回調(diào)方法,從而報錯
         location: that.location,
         success: function (e) {
           console.log(e[0])
           that.setData({
             address: e[0].regeocodeData.formatted_address, //詳細地址,           
             iconSY: null,
             markersList: e[0].regeocodeData.pois
           });
         },
         fail: function (info) {
           //失敗回調(diào)
           console.log(info)
         }
       })
     }
   }
 })

到了這里,關(guān)于微信小程序map視野發(fā)生改變時切換定位點的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔相關(guān)法律責任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • 微信小程序選項卡切換(滑動切換,點擊切換)

    微信小程序選項卡切換(滑動切換,點擊切換)

    效果如下:可點擊切換,滑動切換 代碼如下 這個可以在項目用 index.wxml index.wxss index.js

    2024年02月14日
    瀏覽(88)
  • 微信小程序 map地圖(軌跡)

    微信小程序 map地圖(軌跡)

    allMarkers效果圖 ? 廢話少說直接上馬(最后是我遇到的問題) cover-view是氣泡彈窗,可以自定義彈窗,要配合js:customCallout,如果是非自定義的話:callout(可以修改顏色、邊框?qū)挾?、圓角、邊距等)有些屬性我沒加,還是看官方文檔(雖然寫的。。) 字段說明: allMarkers:模

    2024年02月13日
    瀏覽(21)
  • 微信小程序使用swiper改變導航小圓點的樣式與位置

    微信小程序使用swiper改變導航小圓點的樣式與位置

    ????????小程序中很多都會使用到輪播圖,swiper 插件簡單又好用。但是默認的導航點樣式可能不符合日常開發(fā)的需求,所以很多項目中就需要修改導航點的樣式。以下是修改前和修改后樣式。 ?以下是WXML做的修改 下面是wxss樣式修改 以下為JS部分

    2024年02月13日
    瀏覽(25)
  • 微信小程序使用地圖map (詳細)

    微信小程序使用地圖map (詳細)

    直接看代碼: 可直接賦值實現(xiàn),圖標可根據(jù)自己需要更改 小程序地理定位qqmap-wx-jssdk.js:qqmap-wx-jssdk.js 點擊可進行下載里邊的 :下載微信小程序JavaScriptSDK

    2024年02月11日
    瀏覽(21)
  • 【微信小程序入門到精通】— 微信小程序?qū)崿F(xiàn)多頁面切換(tabBar)

    【微信小程序入門到精通】— 微信小程序?qū)崿F(xiàn)多頁面切換(tabBar)

    對于目前形式,微信小程序是一個熱門,那么我們該如何去學習并且掌握之后去做實際項目呢? 為此我特意開設(shè)此專欄,在我學習的同時也將其分享給大家! 本篇文章將給大家?guī)砣绾翁砑禹撁媲袚Q效果,我們前面所講解的都是停留在某一頁面上面進行預(yù)覽,接下來我們將

    2024年02月03日
    瀏覽(166)
  • 微信小程序切換云環(huán)境

    微信小程序切換云環(huán)境

    在開發(fā)微信小程序的時候,我們可能需要開發(fā)環(huán)境和測試環(huán)境,或者其他環(huán)境,下面是切換環(huán)境的方法。 首先需要明確的是:前端的頁面代碼是不區(qū)分環(huán)境的,環(huán)境的區(qū)分指的是云函數(shù)、云數(shù)據(jù)庫、云存儲這些。 1、更改云函數(shù)的使用云環(huán)境 這里我們從cloud1更改為test-cloud,

    2024年02月09日
    瀏覽(23)
  • 微信小程序選項卡頁面切換

    微信小程序選項卡頁面切換

    選項卡效果切換如下:滑動即可對應(yīng)切換 wxml代碼 ?wxss代碼: js代碼:

    2024年02月16日
    瀏覽(91)
  • 微信小程序?qū)崿F(xiàn)tab切換

    微信小程序?qū)崿F(xiàn)tab切換

    循環(huán)一個數(shù)組,切換數(shù)據(jù)的時候根據(jù)index索引來動態(tài)的設(shè)置選中項,設(shè)置fixed定位,固定在頂部。

    2024年02月16日
    瀏覽(30)
  • uni微信小程序 map 添加padding

    uni微信小程序 map 添加padding

    規(guī)劃駕車線路的時候,使用uni的 include-points 指定可視范圍的時候,會很極限。導致marker不能完全顯示。 給地圖顯示范圍添加padding (推薦) 或者獲取并修改縮放地圖(記得設(shè)置中心點) uni文檔:點擊這里 1的效果圖:

    2024年02月04日
    瀏覽(13)
  • 微信小程序map自定義氣泡customCallout

    微信小程序map自定義氣泡customCallout

    案例效果圖: map地圖氣泡有兩種方式: ? ?一種是在marker上的,這種不能夠自定義樣式,如果需要展示花里胡哨的,采用第一種方式,進行cover-view布局 ?一、首先customCallout 是作為一個屬性存在的,需要在marker中存在,我開發(fā)實例: 二、在map上添加對應(yīng)組件 在這里需要強調(diào)

    2024年02月11日
    瀏覽(17)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包