Bing Maps API - mapArea: this parameter value is out of range

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Bing Maps API - mapArea: this parameter value is out of range



I'm using the Bing Maps API to generate images from certain locations using the BotFramework-Location NuGet package. (Which code can be found here)



Sometimes it works, but sometimes the images are not loaded due to an error in the Rest call (which is called by the BotFramework, not by me)



This is my code:


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);
}



Which responds this:
Location HeroCards returned by BotFramework-Location NuGet Package.



The reason not all images are shown is because the Rest call to the Bing Maps API returns this:



mapArea: This parameter value is out of range.



Here is one of the image uris that fail (I removed my key):



https://dev.virtualearth.net/REST/V1/Imagery/Map/Road?form=BTCTRL&mapArea=49.5737,5.53792,49.57348,5.53744&mapSize=500,280&pp=49.5737,5.53744;1;1&dpi=1&logo=always&key=NOT_REAL_12758FDLKJLDKJO8769KLJDLKJF



Anyone know what I've been doing wrong?




1 Answer
1



I think I understood why you got that error. I tried to get this map and got the same result as yours, as you said:



mapArea: This parameter value is out of range.



If you look at the sample url you provided, the mapArea is equal to 49.5737,5.53792,49.57348,5.53744


mapArea


49.5737,5.53792,49.57348,5.53744



So I just inverted the coordinates of the 2 points defining this area, putting the one with the smaller latitude value first, I got a reply:



Image from maps





that's a step in the right direction. Unfortunately, I didn't generate the image URL. It was provided by the Bing Maps API, which would mean it's out of my control. Also, the image should be generated in a way that the blue marker is centered, which means the Bing Maps API did some wrong calculations or something. Thanks anyway!
– Titulum
1 hour ago







as the code is open-sourced, feel free to raise an issue on github and even provide a solution if you can
– Nicolas R
1 min ago






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived