欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

微信小程序中如何實現(xiàn)map地圖

小編給大家分享一下微信小程序中如何實現(xiàn)map地圖,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

創(chuàng)新互聯(lián)成立于2013年,是專業(yè)互聯(lián)網技術服務公司,擁有項目成都網站建設、網站設計網站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元南部做網站,已為上家服務,為南部各地企業(yè)和個人服務,聯(lián)系電話:13518219792

前言

微信小程序地圖操作比較簡單,api也很少,使用map組件來展示。說到地圖,那就先來看基礎定位:

定位用到wx.getLocation(OBJECT)函數(shù),代碼如下:

wx.getLocation({
 type: 'wgs84',
 success: function(res) {
 var latitude = res.latitude
 var longitude = res.longitude
 var speed = res.speed
 var accuracy = res.accuracy
 }
})

定位成功會返回四個參數(shù)值,如下:

微信小程序中如何實現(xiàn)map地圖

map屬性太多,先看一下:

微信小程序中如何實現(xiàn)map地圖

如果用到地圖,基本上所有屬性都會用到。

下面一一看一下,我們先看效果圖吧,先看真相:

微信小程序中如何實現(xiàn)map地圖

這里我只用了一個markers,就是定位當前位置的紅色markers,用法如下:

 wx.getLocation({
  type: 'wgs84', // 默認為 wgs84 返回 gps 坐標,gcj02 返回可用于 wx.openLocation 的坐標
  success: function (res) {

  _this.setData({
   latitude: res.latitude,
   longitude: res.longitude,
   markers: [{
   id: "1",
   latitude: res.latitude,
   longitude: res.longitude,
   width: 50,
   height: 50,
   iconPath: "/assests/imgs/my.png",
   title: "哪里"

   }],
   circles: [{
   latitude: res.latitude,
   longitude: res.longitude,
   color: '#FF0000DD',
   fillColor: '#7cb5ec88',
   radius: 3000,
   strokeWidth: 1
   }]

  })
  }

 })

這里加了circles,半徑是3000米,具體的api可自行看官網。

接下來看看controls,控制層,在地圖上顯示控件,控件不隨著地圖移動,看API:

微信小程序中如何實現(xiàn)map地圖

注意看示例圖的右上角,有兩個按鈕,加減號,是控制地圖scale的數(shù)值變化,動態(tài)縮放地圖的,controls用法也很簡單:

 controls: [{
  id: 1,
  iconPath: '/assests/imgs/jian.png',
  position: {
  left: 320,
  top: 100 - 50,
  width: 20,
  height: 20
  },
  clickable: true
 },
 {
  id: 2,
  iconPath: '/assests/imgs/jia.png',
  position: {
  left: 340,
  top: 100 - 50,
  width: 20,
  height: 20
  },
  clickable: true
 }
 ]

最后我們看一張gif圖:

微信小程序中如何實現(xiàn)map地圖

最后上一下具體代碼:

wxml:

 <map id="map" longitude="{{longitude}}" latitude="{{latitude}}" scale="{{scale}}" controls="{{controls}}" bindcontroltap="controltap" markers="{{markers}}" circles="{{circles}}" bindmarkertap="markertap" polyline="{{polyline}}" bindregionchange="regionchange" show-location ></map>

js:

Page({
 data: {
 Height: 0,
 scale: 13,
 latitude: "",
 longitude: "",
 markers: [],
 controls: [{
  id: 1,
  iconPath: '/assests/imgs/jian.png',
  position: {
  left: 320,
  top: 100 - 50,
  width: 20,
  height: 20
  },
  clickable: true
 },
 {
  id: 2,
  iconPath: '/assests/imgs/jia.png',
  position: {
  left: 340,
  top: 100 - 50,
  width: 20,
  height: 20
  },
  clickable: true
 }
 ],
 circles: []

 },

 onLoad: function () {
 var _this = this;

 wx.getSystemInfo({
  success: function (res) {
  //設置map高度,根據(jù)當前設備寬高滿屏顯示
  _this.setData({
   view: {
   Height: res.windowHeight
   }

  })



  }
 })

 wx.getLocation({
  type: 'wgs84', // 默認為 wgs84 返回 gps 坐標,gcj02 返回可用于 wx.openLocation 的坐標
  success: function (res) {

  _this.setData({
   latitude: res.latitude,
   longitude: res.longitude,
   markers: [{
   id: "1",
   latitude: res.latitude,
   longitude: res.longitude,
   width: 50,
   height: 50,
   iconPath: "/assests/imgs/my.png",
   title: "哪里"

   }],
   circles: [{
   latitude: res.latitude,
   longitude: res.longitude,
   color: '#FF0000DD',
   fillColor: '#7cb5ec88',
   radius: 3000,
   strokeWidth: 1
   }]

  })
  }

 })

 },

 regionchange(e) {
 console.log("regionchange===" + e.type)
 },

 //點擊merkers
 markertap(e) {
 console.log(e.markerId)

 wx.showActionSheet({
  itemList: ["A"],
  success: function (res) {
  console.log(res.tapIndex)
  },
  fail: function (res) {
  console.log(res.errMsg)
  }
 })
 },

 //點擊縮放按鈕動態(tài)請求數(shù)據(jù)
 controltap(e) {
 var that = this;
 console.log("scale===" + this.data.scale)
 if (e.controlId === 1) {
  // if (this.data.scale === 13) {
  that.setData({
  scale: --this.data.scale
  })
  // }
 } else {
  // if (this.data.scale !== 13) {
  that.setData({
  scale: ++this.data.scale
  })
  // }
 }


 },


})

以上是“微信小程序中如何實現(xiàn)map地圖”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

當前標題:微信小程序中如何實現(xiàn)map地圖
文章URL:http://aaarwkj.com/article44/ijpjee.html

成都網站建設公司_創(chuàng)新互聯(lián),為您提供全網營銷推廣商城網站、網站收錄、網站建設、ChatGPT網站內鏈

廣告

聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

成都網頁設計公司
日韩黄色资源在线观看| 欧美日韩加勒比综合在线| 亚洲黄色艳情视频录像| 在线高清视频无卡不码| 色日韩在线观看视频| 日本一级a级黄免视频| 国产又粗又长又大无遮挡| 丝袜美腿亚洲欧美日韩| 欧美日本午夜福利在线观看| 熟妇人妻精品一区二区三区颏| 黄片色呦呦视频免费看| 国产剧情av在线资源| 亚洲桃色一区二区三区四区| 俩小伙探花专约老熟女| 手机不卡在线观看av| 青青成线在人线免费啪| 九九有点热以前的视频| 午夜性生活免费在线观看| 少妇人妻偷人精品系列| 国产亚洲精品一区二区三在线观看| 91色九色吧在线观看| 亚洲av久久一区二区| 国产成人色污在线观看| 黄色18禁网站在线看| 特级艳片在线观看免费| 黄色午夜福利在线观看| 亚洲熟乱熟女一区二区| 日韩精品激情视频在线| 色婷婷区二区三区四区| 日韩一级精品电影网| 成年人收看黄色一二级片 | 国产丝袜肉丝在线播放| 白嫩少妇情久久密月久久| 国产午夜视频成人无遮挡| 日本一区二区三区免费精品| 欧美香蕉高清视频免费| 黄片视频免费在线播放大全| 麻豆乱淫一区二区三爱免费| 日韩精品一区二区三区夜色| 麻豆人妻少妇精品系列| 蜜臀人妻四季av一区二区不卡|