微信小程序 - 調用騰訊地圖插件


 

 

 

1. 登錄公眾號平台

https://mp.weixin.qq.com/

 

2. 設置->第三方服務->添加插件->輸入插件名稱->申請

 

3. 項目中使用

3.1 app.json配置

  

 

3.2 項目中配置wxml,json,js

wxml

1 <map-route route-info="{{routeInfo}}"></map-route>

 

json

1 { 2  "usingComponents": { 3  "map-route": "plugin://myPlugin/mapRoute" 4  } 5 }

 

js

 1 Page({  2  data: {  3  routeInfo: {  4       startLat: 0.0,    //起點經度 選填
 5       startLng: 0.0,    //起點緯度 選填
 6       startName: "未獲取到起點",   // 起點名稱 選填
 7       endLat: 0.0,    // 終點經度必傳
 8       endLng: 0.0,  //終點緯度 必傳
 9       endName: "未獲取到終點",  //終點名稱 必傳
10       mode: "car"  //算路方式 選填
11  } 12  }, 13   onLoad: function (options) { 14     let _page = this; 15 
16  console.log(options) 17 
18  _page.setData({ 19 routeInfo: { 20 startLat: parseFloat(options.latStart), //起點經度 選填 21 startLng: parseFloat(options.lngStart), //起點緯度 選填 22 startName: options.get_address, // 起點名稱 選填 23 endLat: parseFloat(options.latEnd), // 終點經度必傳 24 endLng: parseFloat(options.lngEnd), //終點緯度 必傳 25 endName: options.give_address, //終點名稱 必傳 26 mode: "car" //算路方式 選填 27 } 28  }) 29  }, 30   onShow: function () { 31     let plugin = requirePlugin("myPlugin"); 32  } 33 })

 

 關於插件使用說明,請看官方文檔:https://mp.weixin.qq.com/wxopen/plugindevdoc?appid=wx5bc2ac602a747594&token=363067683&lang=zh_CN

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM