国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 熱點 > 微信 > 正文

微信小程序地圖導航功能實現完整源代碼附效果圖(推薦)

2024-07-22 01:18:41
字體:
來源:轉載
供稿:網友

正文:

一:需求及效果圖展示

從后端API獲取到起始地和目的地的經緯度坐標與地名。用戶點擊起始地便打開地圖展示坐標的附近街景,路線,或者打開外部地圖。

二:源代碼

 <block wx:for="{{data_2}}" wx:key='index' wx:if="{{data_2.length}}">      <view style='margin-left:10rpx;'>訂單號: {{item.order_num}}</view>     <view class='page_row'>      <view class='centent'>       <view style='margin-left:10rpx;' wx:if='{{item.server_info.linkman}}'>下單人: {{item.server_info.linkman}}        <text style='color:#999;margin-left:40rpx;font-size:32rpx;' wx:if='{{item.server_info.tel}}'>聯系電話: {{item.server_info.tel}}</text>       </view>       <view style='color:#999;margin-top:15rpx;' wx:if='{{item.car_info.title}}'>        <view style='color:#999;margin-left:10rpx;font-size:28rpx' bindtap='apen_add'data-name='{{item.server_info.address}}' data-latitude_siji='{{item.server_info.coordinate_start}}'><image style='width:32rpx;height:32rpx' src='../../image/location.png'/> 導航至起始地:{{item.server_info.address}} </view>       </view>       <view style='color:#999;margin-top:15rpx;' wx:if='{{item.car_info.title}}'>        <view style='color:#999;margin-left:10rpx;font-size:28rpx' bindtap='apen_add' data-name='{{item.server_info.address_end_text}}' data-longitude_siji='{{item.server_info.coordinate_end}}'><image style='width:32rpx;height:32rpx' src='/image/location.png'/> 導航至目的地: {{item.server_info.address_end_text}} </view>       </view>       <view style='color:#999;margin-top:15rpx;' wx:if='{{item.car_info.title}}'>        <view style='color:#999;margin-left:10rpx;font-size:28rpx'> 分配時間:{{item.time_tired}}</view>       </view>      </view>     </view>     <view class='xxx'></view>   </block>
 apen_add: function (e) {  var that = this  var latitude, longitude  var name = e.currentTarget.dataset.name  if (e.currentTarget.dataset.latitude_siji) {   var latitude_siji = e.currentTarget.dataset.latitude_siji.split(',')   latitude = Number(latitude_siji[0])   longitude = Number(latitude_siji[1])  }  if (e.currentTarget.dataset.longitude_siji) {   var longitude_siji = e.currentTarget.dataset.longitude_siji.split(',')   latitude = Number(longitude_siji[0])   longitude = Number(longitude_siji[1])  }  wx.getSetting({   success: (res) => {    if (res.authSetting['scope.userLocation'] != undefined && res.authSetting['scope.userLocation'] != true) {     wx.showModal({      title: '是否授權當前位置',      content: '需要獲取您的地理位置,請確認授權,否則地圖定位功能將無法使用',      success: function (res) {       if (res.cancel) {        console.info("1授權失敗返回數據");        } else if (res.confirm) {        //village_LBS(that);        wx.openSetting({         success: function (data) {          if (data.authSetting["scope.userLocation"] == true) {           wx.showToast({            title: '授權成功',            icon: 'success',            duration: 5000           })           wx.openLocation({            latitude: latitude,            longitude: longitude,            name: name,            scale: 28           })           } else {           wx.showToast({            title: '授權失敗',            icon: 'success',            duration: 5000           })          }         }        })       }      }     })    } else {     wx.openLocation({      latitude: latitude,      longitude: longitude,      name: name,      scale: 28     })     }   }  }) },            
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 廉江市| 伊金霍洛旗| 滦南县| 大安市| 江源县| 习水县| 白玉县| 邯郸县| 台安县| 上杭县| 泰和县| 江川县| 宝丰县| 建阳市| 广宗县| 琼中| 长春市| 黑水县| 睢宁县| 佛坪县| 丽水市| 镇远县| 乌拉特前旗| 阳新县| 淳化县| 巴塘县| 瑞金市| 甘谷县| 丰城市| 沁水县| 正镶白旗| 高清| 定结县| 邹城市| 天门市| 宝清县| 茌平县| 保定市| 和林格尔县| 嘉鱼县| 莒南县|