microsoft / BingMapsRESTToolkit

This is a portable class library which makes it easy to access the Bing Maps REST services from .NET.

Home Page:https://github.com/Microsoft/BingMapsRESTToolkit/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ElevationRequest returning only one value

smarteez17 opened this issue · comments

Looking at the below code why is are we taking the first value ?

var elevation = elevResult.Elevations[0];

Also I see that from the documents elevation is an array . My question is why am I only getting one value back ?
image

//Create an elevation request for the geocoded coordinates.
var elevRequest = new ElevationRequest()
{
Points = new List() {
coordinate
},
BingMapsKey = BING_MAPS_KEY
};

//Process the request by using the ServiceManager.
var elevResponse = await elevRequest.Execute();

if(elevResponse != null && 
	elevResponse.ResourceSets != null && 
	elevResponse.ResourceSets.Length > 0 && 
	elevResponse.ResourceSets[0].Resources != null && 
	elevResponse.ResourceSets[0].Resources.Length > 0)
{
	var elevResult = elevResponse.ResourceSets[0].Resources[0] as BingMapsRESTToolkit.ElevationData;

	//Extract the elvation information.
	var elevation = elevResult.Elevations[0];
	
	//Do something with the coordinate and elevation information.

} else {
	//Unable to find an elevation for a location. This often happens if the coordinate is over water.
}	

That's just showing how to get the first value out. You can loop through it if you want. In the code sample I provided you in the other thread, where you copied this from, the sample geocoded a single location, and used that to get the elevation, thus there would only be one elevation result.