我正在使用 Bing Maps API 使用 BotFramework-Location NuGet 包从某些位置生成图像。(可以在这里找到哪些代码)
有时它可以工作,但有时由于 Rest 调用(由 BotFramework 调用,而不是我调用)中的错误而未加载图像
这是我的代码:
IGeoSpatialService geoService = new AzureMapsSpatialService(this.azureApiKey);
List < Location > concreteLocations = new List < Location > ();
foreach(String location in locations) {
LocationSet locationSet = await geoService.GetLocationsByQueryAsync(location);
concreteLocations.AddRange(locationSet ? .Locations);
}
// Filter out duplicates
var seenKeys = new HashSet < String > ();
var uniqueLocations = new List < Location > ();
foreach(Location location in concreteLocations) {
if (seenKeys.Add(location.Address.AddressLine)) {
uniqueLocations.Add(location);
}
}
concreteLocations = new List < Location > (uniqueLocations.Take(5));
if (concreteLocations.Count == 0) {
await context.PostAsync("No dealers found.");
context.Done(true);
} else {
var locationsCardReply = context.MakeMessage();
locationsCardReply.Attachments = new LocationCardBuilder(this.bingApiKey, new LocationResourceManager()).CreateHeroCards(concreteLocations).Select(card => card.ToAttachment()).ToList();
locationsCardReply.AttachmentLayout = AttachmentLayoutTypes.Carousel;
await context.PostAsync(locationsCardReply);
}
未显示所有图像的原因是对 Bing 地图 API 的 Rest 调用返回以下内容:
mapArea:此参数值超出范围。
这是失败的图像uri之一(我删除了我的密钥):
有谁知道我做错了什么?