Google maps api 3 如何通过电报机器人在谷歌地图上添加多个位置?

Google maps api 3 如何通过电报机器人在谷歌地图上添加多个位置?,google-maps-api-3,location,telegram,telegram-bot,Google Maps Api 3,Location,Telegram,Telegram Bot,我想通过使用发送位置功能,将固定在一张地图上的多个位置发送到电报bot。有没有办法向电报机器人发送多个位置?我尝试只向telegram bot发送一个位置。据我所知,您希望向用户发送多个位置,因此不希望在SendLocation方法中输入数字。如果需要发送的位置是一些固定位置,则可以将它们保存在数组或数据库中,并使用循环发送它们 但是如果它们没有被修复,您必须先将它们发送到bot,然后强制bot发送到用户或其他任何地方。(频道或组)下面的代码可能会帮助您: //Send the location

我想通过使用发送位置功能,将固定在一张地图上的多个位置发送到
电报bot
。有没有办法向电报机器人发送多个位置?我尝试只向telegram bot发送一个位置。

据我所知,您希望向用户发送多个位置,因此不希望在SendLocation方法中输入数字。如果需要发送的位置是一些固定位置,则可以将它们保存在数组或数据库中,并使用循环发送它们

但是如果它们没有被修复,您必须先将它们发送到bot,然后强制bot发送到用户或其他任何地方。(频道或组)下面的代码可能会帮助您:

//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);
}
当然,如果位置的数量太多,最好使用数据库并将它们从数据库发送到bot

如果要将位置从用户发送到机器人(而不是从机器人发送到用户),可以使用:

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.
}
我希望这些能帮助你,你的问题不清楚,所以我这样解释。

你不能。
此方法仅发送地图上的点。

检查电报机器人API()

也许您可以提供您当前的代码,显示您如何发送单个位置。然后显示您已尝试发送多个位置的内容,以及输出内容。我发送发送的发送请求代码如下:“wait Bot.SendLocationAsync(message.Chat.Id,43.296482,5.369763);”但我想发送在地图上显示的long&lat列表请阅读此感谢您的回答,但我的问题是在一张地图中发送多个位置。我通过从地图发送照片解决了我的问题,谷歌地图是通过这个url@fatemosleh创建的。这可能是个好主意,但对你的机器人用户来说,这样做会很困难,因为你发送的只是一张照片,而不是地图或位置。我也可以帮你。按照链接中的步骤操作后,您可以轻松地在电报机器人中发送地图链接。您可以为自己的地图命名,并在地图上用您喜爱的名称固定多个位置。