Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Botframework Bing Maps API-mapArea:此参数值超出范围_Botframework_Bing Maps_Bing Api_Azure Maps - Fatal编程技术网

Botframework Bing Maps API-mapArea:此参数值超出范围

Botframework Bing Maps API-mapArea:此参数值超出范围,botframework,bing-maps,bing-api,azure-maps,Botframework,Bing Maps,Bing Api,Azure Maps,我正在使用Bing Maps API使用BotFramework Location NuGet包从特定位置生成图像。(可以找到哪个代码) 有时它可以工作,但有时由于Rest调用中的错误(由BotFramework调用,而不是由我调用)而无法加载图像 这是我的代码: IGeoSpatialService geoService = new AzureMapsSpatialService(this.azureApiKey); List < Location > concreteLocati

我正在使用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);
}
IGeoSpatialService geoService=new azuremapspatialservice(this.azureapiekey);
列表<位置>具体位置=新列表<位置>();
foreach(位置中的字符串位置){
LocationSet LocationSet=await geoService.GetLocationsByQueryAsync(位置);
混凝土位置。添加范围(位置集?位置);
}
//滤除重复项
var seenKeys=newhashset();
var uniqueLocations=新列表();
foreach(混凝土位置中的位置){
if(seenKeys.Add(location.Address.AddressLine)){
唯一位置。添加(位置);
}
}
concreteLocations=新列表(uniqueLocations.Take(5));
if(concreteLocations.Count==0){
等待上下文。PostAsync(“未找到经销商”);
上下文。完成(true);
}否则{
var locationsCardReply=context.MakeMessage();
locationsCardReply.Attachments=new LocationCardBuilder(this.bingApiKey,new LocationResourceManager()).CreateRocards(concreteLocations)。选择(card=>card.ToAttachment()).ToList();
locationsCardReply.AttachmentLayout=AttachmentLayoutTypes.Carousel;
wait context.PostAsync(locationsCardReply);
}
对此作出回应:

未显示所有图像的原因是,对Bing Maps API的Rest调用返回以下结果:

mapArea:此参数值超出范围

以下是一个失败的图像URI(我删除了密钥):


有人知道我做错了什么吗?

我想我明白你为什么会犯这样的错误。我试图得到这张地图,结果和你的一样,正如你所说:

mapArea:此参数值超出范围

如果查看您提供的示例url,
mapArea
等于
49.5737,5.53792,49.57348,5.53744

所以我把定义这个区域的两个点的坐标倒过来,把纬度值较小的那个放在前面,我得到了一个回答:

编辑:

正如您所评论的,此调用是在
BotBuilder位置
code中进行的,而不是在您的位置上。我看了一下,这是生成地图的方法,名为inside
LocationCardBuilder
类,您正在实例化该类:

public string GetLocationMapImageUrl(Location location, int? index = null)
{
    if (location == null)
    {
        throw new ArgumentNullException(nameof(location));
    }

    var point = location.Point;
    if (point == null)
    {
        throw new ArgumentNullException(nameof(point));
    }

    if (location.BoundaryBox != null && location.BoundaryBox.Count >= 4)
    {
        return string.Format(
            CultureInfo.InvariantCulture,
            ImageUrlByBBox,
            location.BoundaryBox[0],
            location.BoundaryBox[1],
            location.BoundaryBox[2],
            location.BoundaryBox[3],
            point.Coordinates[0],
            point.Coordinates[1], 
            index, 
            this.apiKey);
    }
    else
    {
        return string.Format(
            CultureInfo.InvariantCulture, 
            ImageUrlByPoint, 
            point.Coordinates[0], 
            point.Coordinates[1], 
            index, 
            apiKey);
    }
}
如您所见,BoundaryBox项的格式没有限制。但如果您查看有关位置数据的文档:

边界框:包含位置的地理区域。边界框包含以度为单位的南纬、西经、北纬和东经值

您可能知道,在代码中,南纬比北纬小(因为代码中的正负值取决于与厄瓜多尔相比的位置:43N为43,43S为-43)。所以问题似乎就在这里


我做了一个快速测试,看看是否根据您之前所做的调用(to
GetLocationsByQueryAsync
)得到了错误,我无法重现这种情况。您能分享您所做的与此问题相关的查询吗?

这是朝着正确方向迈出的一步。不幸的是,我没有生成图像URL。它是由Bing地图API提供的,这意味着它超出了我的控制范围。此外,生成图像的方式应确保蓝色标记居中,这意味着Bing Maps API进行了一些错误的计算或其他操作。无论如何谢谢你!由于代码是开源的,如果您可以编辑我的答案以提供更多细节,可以在github上提出问题,甚至提供解决方案。我看了一下回购协议上的代码,似乎还可以。你能分享你正在查询的
位置
内容吗?这些查询是卡片底部的地址。你能提供你传递的信息来获取你展示的这个工作示例吗?我想调查一下回购协议,看看这方面是否有问题。我认为,对于您的第一个项目,它是使用另一种方法生成图像,因此存在问题