欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

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

這篇“微信小程序中怎么實現(xiàn)map地圖”文章的知識點大部分人都不太理解,所以小編給大家總結了以下內(nèi)容,內(nèi)容詳細,步驟清晰,具有一定的借鑒價值,希望大家閱讀完這篇文章能有所收獲,下面我們一起來看看這篇“微信小程序中怎么實現(xiàn)map地圖”文章吧。

目前創(chuàng)新互聯(lián)已為近1000家的企業(yè)提供了網(wǎng)站建設、域名、網(wǎng)站空間綿陽服務器托管、企業(yè)網(wǎng)站設計、邊壩網(wǎng)站維護等服務,公司將堅持客戶導向、應用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。

前言

微信小程序地圖操作比較簡單,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可自行看官網(wǎng)。

接下來看看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地圖”這篇文章的內(nèi)容,相信大家都有了一定的了解,希望小編分享的內(nèi)容對大家有幫助,若想了解更多相關的知識內(nèi)容,請關注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

網(wǎng)頁題目:微信小程序中怎么實現(xiàn)map地圖
當前鏈接:http://chinadenli.net/article36/gpccpg.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供軟件開發(fā)、外貿(mào)建站、、網(wǎng)站改版、定制開發(fā)、App設計

廣告

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

成都網(wǎng)站建設
人妻一区二区三区在线| 91精品欧美综合在ⅹ| 日韩夫妻午夜性生活视频| 在线一区二区免费的视频| 亚洲日本韩国一区二区三区 | 亚洲精品有码中文字幕在线观看 | 国产精品久久精品毛片| 国产成人精品在线播放| 99久久人妻中文字幕| 五月婷婷欧美中文字幕| 青青操日老女人的穴穴| 日本高清视频在线观看不卡| 欧美日韩在线观看自拍| 东京热加勒比一区二区| 欧美一区二区三区99| 国产日韩熟女中文字幕| 亚洲欧美天堂精品在线| 中文字幕日韩一区二区不卡| 麻豆一区二区三区在线免费| 亚洲一区二区欧美在线| 国产一级不卡视频在线观看| 高清亚洲精品中文字幕乱码| 日本在线高清精品人妻| 午夜精品国产精品久久久| 性欧美唯美尤物另类视频| 丰满人妻熟妇乱又伦精另类视频| 欧美日韩国产一级91| 日韩精品中文字幕亚洲| 国产欧美日韩一级小黄片| 欧美日韩综合免费视频| 国产精品一区二区日韩新区| 青草草在线视频免费视频| 黄色污污在线免费观看| 国产又粗又长又大高潮视频| 91香蕉视频精品在线看| 国产不卡免费高清视频| 精品午夜福利无人区乱码| 69精品一区二区蜜桃视频| 不卡中文字幕在线视频| 久久国内午夜福利直播| 国产在线不卡中文字幕|