Google Elevation API

Used to visualize and figure out how to output elevations in a certain area.

by garviand

HTML

<script src="http://maps.google.com/maps/api/js"></script>
<script src="https://getfirebug.com/firebug-lite-debug.js"></script>
<div id="map"></div>

CSS

#map{
    width: 450px;
    height: 300px;
}

JavaScript

function initMap() {
  // The following path marks a path from Mt. Whitney, the highest point in the
  // continental United States to Badwater, Death Valley, the lowest point.
  var path = [
      {lat: 36.579, lng: -118.292},  // Mt. Whitney
      {lat: 36.606, lng: -118.0638},  // Lone Pine
      {lat: 36.433, lng: -117.951},  // Owens Lake
      {lat: 36.588, lng: -116.943},  // Beatty Junction
      {lat: 36.34, lng: -117.468},  // Panama Mint Springs
      {lat: 36.24, lng: -116.832}];  // Badwater, Death Valley

  var map = new google.maps.Map(document.getElementById('map'), {
    zoom: 8,
    center: path[1],
    mapTypeId: 'terrain'
  });

  // Create an ElevationService.
  var elevator = new google.maps.ElevationService;

  // Draw the path, using the Visualization API and the Elevation service.
  displayPathElevation(path, elevator, map);
}

function displayPathElevation(path, elevator, map) {
  // Display a polyline of the elevation path.
  new google.maps.Polyline({
    path: path,
    strokeColor: '#0000CC',
    opacity: 0.4,
    map: map
  });

  elevator.getElevationAlongPath({
    'path': path,
    'samples': 256
  }, plotElevation);
}

function plotElevation(elevations, status) {
  
}

initMap();