Interception request to download elevation data

Back
Tags:
Elevation
Tileset
Intercept Request
Example of how to intercept the request to the elevation data, and send elevation value to Online Maps.
Requirement: Tileset Control, Bing Maps Elevation Manager
Usage instructions:
This is just example. To make it work you need to add code of loading elevation data (line 31).
Elevation map must be 32x32.
Add this script to map GameObject.
InterceptElevationRequestExample.cs
/*         INFINITY CODE         */
/*   https://infinity-code.com   */

using UnityEngine;

namespace InfinityCode.OnlineMapsExamples
{
    /// <summary>
    /// Example of how to intercept the request to the elevation data, and send elevation value to Online Maps.
    /// </summary>
    [AddComponentMenu("Infinity Code/Online Maps/Examples (API Usage)/InterceptElevationRequestExample")]
    public class InterceptElevationRequestExample : MonoBehaviour
    {
        /// <summary>
        /// Reference to the Bing Maps Elevation Manager. If not specified, the current instance will be used.
        /// </summary>
        public OnlineMapsBingMapsElevationManager elevationManager;

        private void Start()
        {
            // If the elevation manager is not specified, get the current instance.
            if (elevationManager == null) elevationManager = OnlineMapsBingMapsElevationManager.instance;

            // Intercept elevation request
            elevationManager.OnGetElevation += OnGetElevation;
        }

        private void OnGetElevation(double leftLongitude, double topLatitude, double rightLongitude, double bottomLatitude)
        {
            // Elevation map must be 32x32
            short[,] elevation = new short[32, 32];

            // Here you get the elevation from own sources.

            // Set elevation map
            elevationManager.SetElevationData(elevation);
        }
    }
}