Back

Elevation Service

Note: This service requires your project to have an associated billing information.

Make sure to ENABLE this Elevation API in your google map console dashboard.
The Elevation API provides elevation data for all locations on the surface of the earth, including depth locations on the ocean floor (which return negative values).

You can get the elevation of a place by calling the GetElevation method of the map object like this:

 map.GetElevation(lat, lng, callback)

lat Number
Required. The latitude of the location
lng Number
Required. The longitude of the location
callback Function
Required. The function to be called when the result for elevation is done. It will pass an error, elevation and resolution.

Return. None

Check first whether there is an error. If there is an error the second argument of the callback (elevation) will be the error message.

Get Elevation Example

app.LoadPlugin("MapView");

function OnStart() {
    lay = app.CreateLayout("Linear", "VCenter, FillXY");
        
        var apiKey = "AIzaSyD2eHntKEmh272p3ac6YjWPbPkwo3m2mck";
        
        map = app.CreateMapView(apiKey, 0.9, 0.65, 7.0689323, 125.6114588, 13);
        map.SetOnReady(MapOnReady);
        lay.AddChild(map);

    app.AddLayout(lay);
}
function MapOnReady() {
    map.GetElevation(7.0689323, 125.6114588, OnResult);
}
function OnResult(error, el, res) {
    if(error) app.ShowPopup("Error: "+error);
    else {
        app.ShowPopup("Elevation: "+ el +" Resolution: "+res);
    }
}
Copy    Run