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

微信小程序,高德地圖

這篇具有很好參考價值的文章主要介紹了微信小程序,高德地圖。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

微信小程序使用高德地圖

效果圖預(yù)覽

微信小程序,高德地圖

高德內(nèi)操作

  • 高德開放平臺:

    • 注冊賬號(https://lbs.amap.com/)

    • 去高德地圖平臺申請小程序應(yīng)用的 key
      微信小程序,高德地圖

    • 應(yīng)用管理(https://console.amap.com/dev/key/app) -> 我的應(yīng)用 -> 創(chuàng)建新應(yīng)用

      • 生成的 key 即可用在程序中
        微信小程序,高德地圖
  • 下載相關(guān) sdk 文件,導(dǎo)入 amap-wx.js 到項目中:https://lbs.amap.com/api/wx/download文章來源地址http://www.zghlxwxcb.cn/news/detail-483385.html

小程序內(nèi)

創(chuàng)建 AMapWX 對象

import amap from "@/static/amap-wx.130.js";

this.amapPlugin = new amap.AMapWX({
  key: this.mapKey, // 對應(yīng)高德里申請的key
});

api

  • getRegeo
// 獲取位置
this.amapPlugin.getRegeo({
  success: (data) => {
    console.log('當(dāng)前定位', data)
    ...
  },
  // 獲取位置失敗
  fail: (err) => {
    uni.showToast({
      title: "獲取位置失敗,請重啟小程序",
      icon: "error",
    });
  },
});

獲取路線

  • 公交:getTransitRoute
  • 步行:getWalkingRoute
getTransitRouteData() {
  // 注意格式,'23.18139, 113.48067'此格式無效, 經(jīng)緯度小數(shù)點不超過6位
  const cur_des = {
    origin: "113.48067" + "," + "23.18139",
    destination: "113.30997" + "," + "23.08277",
  };
  this.amapPlugin.getTransitRoute({
    ...cur_des,
    city: this.city,
    strategy: 2,
    success: (data) => {
      console.log("getTransitRouteData", data);
    },
    // 獲取位置失敗
    fail: (err) => {
      ...
    },
  });
}

微信小程序地圖

實用功能

  • includePoints: 縮放視野以包含所有給定的坐標(biāo)點
let mapc = uni.createMapContext("maps", this);
mapc.includePoints({
  points: cur_points,
  padding: [100, 100, 100, 100], // 設(shè)置上右下左的間距(px)
  success: function (e) {
    console.log("includePoints", e);
  },
});

map 組件

<map
  id="maps"
  style="width: 100%; height: 100vh"
  show-location
  show-compass
  enable-poi
  :latitude="curLocation.latitude"
  :longitude="curLocation.longitude"
  :scale="scale" // 縮放
  :markers="markers" // 顯示對應(yīng)標(biāo)記點
  :polyline="polyline" // 路線點
  @markertap="func" // 點擊標(biāo)記點觸發(fā)
>
</map>

js

<script>
import { api } from "@/utils/api.js";
import amap from "@/static/amap-wx.130.js";

export default {
  data() {
    return {
      city: "廣州",
      transitno: "", // 車次 B16
      result: [],
      amapPlugin: null,
      mapKey: "xxxxx9",
      curLocation: {}, // 地理位置

      scale: 16,
      markers: [
        //  {
        // iconPath: require("./imgs/start.png"),
        // id: 0,
        // latitude: 23.18139,
        // longitude: 113.48067,
        // width: 32,
        // height: 32
        //  },{
        // iconPath: require("./imgs/end.png"),
        // id: 0,
        // latitude: 23.08277,
        // longitude: 113.30997,
        // width: 32,
        // height: 32
        //  },
      ],
      polyline: [
        // {
        //   points: [
        // 	{ latitude: 23.18139, longitude: 113.48067 },
        // 	{ latitude: 23.08277, longitude: 113.30997 },
        //   ], //路線的存放做標(biāo)數(shù)組
        //   color: "#42b983", //路線顏色 #42b983 #E74C3C
        //   width: 3, //線的寬度
        // },
      ],
    };
  },
  onLoad() {
    this.getLocations();
  },
  onShow() {},
  methods: {
    func(e) {
      let map = uni.createMapContext("maps", this);
      map.moveToLocation() // 移動到當(dāng)前位置點
    },
    // 獲取地理位置
    getLocations() {
      const _self = this;
      uni.getLocation({
        type: "wgs84",
        geocode: true,
        success: function (res) {
          console.log(res);
          _self.curLocation = {
            latitude: res?.latitude,
            longitude: res?.longitude,
          };
        },
        fail: function (res) {
          console.log(res);
        },
      });
    },

    // 查詢公交線路
    async getRouteData(city, transitno) {
      const data = await api.routeInquiry(city, transitno);
      if (data && data.status === 0) {
        console.log(data.result);
        this.result = [...data.result];

        const cur_points = data?.result[0]?.list.map((item) => {
          return {
            latitude: item?.lat,
            longitude: item?.lng,
            station: item?.station,
          };
        });
        console.log("cur_points", cur_points);

        const maxLen = cur_points.length - 1;
        const cur_markers = [
          {
            iconPath: require("./imgs/start.png"),
            id: 0,
            latitude: cur_points[0]?.latitude,
            longitude: cur_points[0]?.longitude,
            width: 32,
            height: 32,
          },
          {
            iconPath: require("./imgs/end.png"),
            id: 1,
            latitude: cur_points[maxLen]?.latitude,
            longitude: cur_points[maxLen]?.longitude,
            width: 32,
            height: 32,
          },
        ];

        this.markers = cur_markers;
        this.polyline = [
          {
            points: cur_points, // 根據(jù)多個點形成線路, 只有兩個點那就是直線
            color: "#42b983", //路線顏色 #42b983 #E74C3C
            width: 5, //線的寬度
            dottedLine: true,
            arrowLine: true,
          },
        ];
        this.scale = 14;
      }
    },
    onChange(event) {
      this.transitno = event.detail.value;
    },
    onSerach(event) {
      console.log("onSerach", event.detail.value);
      this.getRouteData(this.city, event.detail.value);
    },
  },
};
</script>

到了這里,關(guān)于微信小程序,高德地圖的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

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

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

相關(guān)文章

  • 微信小程序騰訊地圖定位轉(zhuǎn)高德地圖定位

    微信小程序獲取到了當(dāng)前用戶的定位,需要在高德地圖上進行渲染。 發(fā)現(xiàn)正常渲染后,偏差幾百米。 這里圖方便,直接丟到window上了 這里演示“騰訊地圖”轉(zhuǎn)“高德地圖”

    2024年01月25日
    瀏覽(122)
  • 微信小程序引入高德地圖Demo 快速上手

    微信小程序引入高德地圖Demo 快速上手

    本文參照官方文檔進行編寫 最后引入官方實例 最終效果 ` 注冊賬號 https://lbs.amap.com/?ref=http%3A%2F%2Flbs.amap.com%2Fdev%2F#/ 獲取Key教程 https://lbs.amap.com/api/wx/guide/create-project/get-key/ 訪問網(wǎng)址 https://github.com/amap-demo/wx-regeo-poiaround-weather 下載微信小程序?qū)嵗?用微信開發(fā)者工具打開 打開

    2024年02月11日
    瀏覽(109)
  • 微信小程序---- 外賣小程序查看實時地圖路線(騎手端&用戶端)【高德地圖】

    微信小程序---- 外賣小程序查看實時地圖路線(騎手端&用戶端)【高德地圖】

    前言:1. 在小程序中需要使用map組件,文檔鏈接:https://developers.weixin.qq.com/miniprogram/dev/component/map.html 2.使用的是高德地圖,所以需要引進相關(guān)的js,下載鏈接:https://lbs.amap.com/api/wx/download 3.去往高德官方申請需要用的key,操作鏈接:https://lbs.amap.com/api/wx/guide/create-project/get-key

    2024年02月16日
    瀏覽(94)
  • 【微信小程序】微信小程序集成高德衛(wèi)星地圖完成多邊形繪制與截圖保存

    【微信小程序】微信小程序集成高德衛(wèi)星地圖完成多邊形繪制與截圖保存

    目錄 功能需求 使用的技術(shù)點 注意點 實現(xiàn)步驟 代碼 微信小程序-地圖所在的wxml 微信小程序-地圖所在的js 微信小程序-展示截圖結(jié)果的wxml 微信小程序-展示截圖結(jié)果的js H5-地圖所在的html 完成效果? 參考文檔 感謝閱讀,歡迎討論 打開頁面展示衛(wèi)星地圖,用戶自行在地圖上繪制

    2024年02月06日
    瀏覽(965)
  • uni微信小程序跳入外鏈(以高德地圖為例)

    uni微信小程序跳入外鏈(以高德地圖為例)

    前瞻:vue項目在跳轉(zhuǎn)外部鏈接時一般使用:window.open 或者 href 都離不開window這一屬性,但總所周知 微信小程序并不存在 window這一屬性,所以在這個時候我們需要加以變通 方法1: 1:跳入外部鏈接,此鏈接應(yīng)該是 https加域名的鏈接,如果不是https的 那不可以 2:配置 將你所需

    2024年02月20日
    瀏覽(87)
  • uniapp---- 微信小程序中獲取當(dāng)前地理位置(高德地圖)

    uniapp---- 微信小程序中獲取當(dāng)前地理位置(高德地圖)

    1.在manifest.json中選擇微信小程序配置,勾選上位置接口。 2.在manifest.json中選擇源碼視圖,添加permission和requiredPrivateInfos 3.進入微信公眾平臺添加合法域名(不能少但是可以放在最后添加,調(diào)試期間可以打開開發(fā)者工具的不校驗合法域名) 4.下載amap-wx.130.js,并且進行引用,

    2024年02月12日
    瀏覽(100)
  • 微信小程序?qū)W習(xí)實錄3(環(huán)境部署、百度地圖微信小程序、單擊更換圖標(biāo)、彈窗信息、導(dǎo)航、支持騰訊百度高德地圖調(diào)起)

    微信小程序?qū)W習(xí)實錄3(環(huán)境部署、百度地圖微信小程序、單擊更換圖標(biāo)、彈窗信息、導(dǎo)航、支持騰訊百度高德地圖調(diào)起)

    百度地圖微信小程序JavaScript API(簡稱小程序JSAPI),支持在微信小程序中使用百度數(shù)據(jù)資源。小程序JSAPI是對百度地圖Web服務(wù)API中的部分接口按照微信小程序的規(guī)范進行了前端JS封裝,方便了微信小程序開發(fā)者的調(diào)用。部分接口對返回的POI等數(shù)據(jù)按照微信小程序的數(shù)據(jù)格式進

    2024年02月02日
    瀏覽(98)
  • 【微信小程序】免費的高德地圖api——獲取天氣(全過程)

    【微信小程序】免費的高德地圖api——獲取天氣(全過程)

    介紹 這里是小編成長之路的歷程,也是小編的學(xué)習(xí)之路。希望和各位大佬們一起成長! 以下為小編最喜歡的兩句話: 要有最樸素的生活和最遙遠的夢想,即使明天天寒地凍,山高水遠,路遠馬亡。 一個人為什么要努力? 我見過最好的答案就是:因為我喜歡的東西都很貴,

    2024年02月02日
    瀏覽(102)
  • 基于微信小程序Map標(biāo)簽及高德地圖開源方法實現(xiàn)路徑導(dǎo)航

    基于微信小程序Map標(biāo)簽及高德地圖開源方法實現(xiàn)路徑導(dǎo)航

    ????????微信小程序自帶地圖map標(biāo)簽,他是基于canvas畫圖功能進行的地圖渲染,同時依賴微信的getlocation獲取經(jīng)緯度,繪制周邊地圖。地圖上可以標(biāo)點,畫線,查看當(dāng)?shù)氐乩硇畔ⅰ5亲詭У膶?dǎo)航功能模塊不能對個人開發(fā)者公開。 ????????高德地圖提供了基于微信小程

    2024年02月09日
    瀏覽(90)
  • uniapp開發(fā)微信小程序使用高德地圖

    uniapp? 官方文檔?地圖組件控制??地圖組件 高德地圖key需要公司去申請,之后自己在下載高德地圖微信小程序插件 下好的js文件放在項目中,之后在vue項目中的main.js文件中全局注入 頁面引入并使用

    2024年02月15日
    瀏覽(88)

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

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

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

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

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包