我想通過使用發送位置功能將固定在單個地圖上的多個位置發送到telegram-bot
。有沒有辦法將多個位置發送到電報機器人?我嘗試只能發送一個位置到電報機器人。如何通過Telegram Bot在Google地圖上添加多個地點?
回答
據我所知,你想發送多個位置給用戶,所以你不想把數字放在SendLocation方法中。如果需要發送的位置是一些固定的位置,您可以將它們保存在數組或數據庫中,並使用循環發送它們。
但如果他們不固定,你必須將它們先發送機器人,然後強制機器人發送給用戶或其他任何地方(通道或一組),下面的代碼可以幫助你:
//Send the location like: latitude=xxx&longtitude=yyy;
if(update.Message.Text.Contains("latitude") && update.Message.Text.Contains("longtitude"))
{
string latitude = text.Split('&').First();
string longtitude = text.Split('&').Last();
//splites the input text into two parts first part is latitude=xxx and second or last part is longtitude=yyy. because the string is splited based on & sign
float latitue_num = float.Parse(latitude.Split('=').Last());
float longtitude_num = float.Parse(longtitude.Split('=').Last());
//does the same action for "latitude=xxx" and "longtitude=yyy" after that the number xxx is stored in latitude_num and yyy is stored in longtitude_num
var req = new SendLocation(update.Message.Chat.Id, latitue_num, longtitude_num);
await bot.MakeRequestAsync(req);
}
當然,如果位置數量太大,最好使用數據庫並將它們從數據庫發送到機器人。
如果你想從一個用戶的位置發送給機器人(而不是從機器人到用戶),您可以使用:
if(update.Message.Location != null)
{
.
.
.
//here you can do whatever you want every time bot receives a location. no matter how many locations are sent to the bot the bot will receive them one by one and do the action(s) listed in this method.
}
我希望這會幫助你,你的問題並不清楚,因此我這樣解釋。
謝謝你從你的答案,但我的問題是關於在單個地圖發送多個位置。我通過發送來自地圖的照片解決了我的問題,該地圖從此網址創建谷歌地圖https://maps.googleapis.com/maps/api/staticmap?center=tehran,ir&zoom=13&size=600x300&maptype=roadmap&markers=color:blue%7Clabel: S%7C40.702147,-74.015794&markers = color = green:green%7Clabel:G%7C40.711614,-74.&markers = color = red%7Clabel:C%7C40.718217,-73.998284&key = AIzaSyC1iKAPcxTPoTFzRcIlJjw9Qj-NSSokipE –
@fatememosleh This can這是一個好主意,但這樣對你的機器人用戶來說很難,因爲你只發送照片,而不是地圖或位置。 [此鏈接](https://www.create.net/support/218-how-to-pin-point-multiple-locations-on-google-maps.html)也可能對您有所幫助。按照鏈接中的步驟進行操作後,您可以輕鬆地在電報機器人中發送地圖鏈接。你可以用自己喜歡的名字命名你自己的地圖並在其上標上多個位置。 –
你不行。
此方法只需在地圖上發送點。
Check Telegram Bot API(https://core.telegram.org/bots/api#sendlocation)
- 1. 如何通過Google Spreadsheet在Google Maps API上添加多個地點?
- 2. GOOGLE Place Api:如何通過Google地點操作添加更多地名對單個地點
- 3. 如何在Google地圖上顯示多個地點?
- 4. 如何在默認Google地圖上添加疊加地圖?
- 5. Telegram Bot SDK添加命令
- 6. 通過點擊地圖添加標記
- 7. 如何在Google地圖上添加本地搜索?
- 8. Google地圖上的30,000個地點
- 9. 如何在Google地圖中顯示多個地點?
- 10. SQlite在Google地圖上添加多個標記
- 11. 如何在Google地圖中添加多個標記?
- 12. iOS [iPhone]在Google地圖上繪製2000多個地點
- 13. 通過地址而不是座標添加Google地圖標記?
- 14. Telegram Bot如何在鍵盤上附加圖像
- 15. 在標記上添加infoWindow Google地圖
- 16. 在已發佈的Google地圖上添加一個過濾器
- 17. 在Android上添加Google地圖對象
- 18. 在Google地圖上添加標記
- 19. 如何通過點擊Google地圖在一個頁面上選擇兩個地理點?
- 20. Android在Google地圖中添加地點圖標
- 21. 添加多個航點時的Google地圖路線url錯誤
- 22. 在Google地圖上通過手指自由地繪圖
- 23. 如何通過點擊谷歌地圖添加標記
- 24. 如何在Google地圖上添加監聽器到多個形狀?
- 25. Android在Google地圖上添加延遲地圖
- 26. 無法在一個頁面中添加多個Google地圖?
- 27. 通過內聯鍵盤啓動Telegram Bot
- 28. Telegram Bot通過Node.js發送PDF文件
- 29. 在多邊形中添加多個AddListener google地圖
- 30. 如何使用android在Google地圖上添加可點擊圖標?
也許您可以提供您當前的代碼,顯示您如何發送單個位置。然後顯示您已經嘗試發送多個位置的內容,以及輸出的內容。 – feedMe
我發送我的發送請求代碼像這樣 「await Bot.SendLocationAsync(message.Chat.Id,43.296482,5.369763);」 但我想發送長和經緯度列表在地圖上顯示 –
請閱讀此http://stackoverflow.com/help/how-to-ask – feedMe