/// <summary> /// On request Complete /// </summary> /// <param name="response">Response</param> private void OnComplete(string response) { // Log response Debug.Log(response); // You have two options: // 1. Load the result object. It's slower, but you have the entire object. // 2. Load the elevation data into array. It's fast. Supports one-dimensional and two-dimensional arrays. // 1. Load result object OnlineMapsBingMapsElevationResult result = OnlineMapsBingMapsElevation.GetResult(response, OnlineMapsBingMapsElevation.Output.json); // Log elevations length if (result != null) { Debug.Log(result.resourceSets[0].resources[0].elevations.Length); } else { Debug.Log("Result is null"); } // 2. Load the elevation data into two-dimensional array. short[,] elevations = new short[32, 32]; Array ea = elevations; OnlineMapsBingMapsElevation.ParseElevationArray(response, OnlineMapsBingMapsElevation.Output.json, ref ea); // Log first elevation value Debug.Log(elevations[0, 0]); }
/// <summary> /// Converts the response string to response object. /// </summary> /// <param name="response">Response string</param> /// <param name="outputType">Format of response string (JSON or XML)</param> /// <returns>Response object</returns> public static OnlineMapsBingMapsElevationResult GetResult(string response, Output outputType) { try { if (outputType == Output.json) { return(OnlineMapsJSON.Deserialize <OnlineMapsBingMapsElevationResult>(response)); } OnlineMapsXML xml = OnlineMapsXML.Load(response); if (!xml.isNull) { OnlineMapsBingMapsElevationResult result = new OnlineMapsBingMapsElevationResult(xml); return(result); } } catch {} return(null); }