I am trying to display a point locator on polygon path, when onclick of elevation profile graph.I tried the following code with google api in openlayers library, the graph is showing but pointer is not displaying. Please suggest me how to add a pointer on polygon path.

var elevator = new google.maps.ElevationService; displayPathElevation(path, elevator, map);

function displayPathElevation(path, elevator, map) {

    // Display a polyline of the elevation path.
   /* new google.maps.Polyline({
      path: path,
      strokeColor: '#0000CC',
      strokeOpacity: 0.4,
      map: map

    // Create a PathElevationRequest object using this array.
    // Ask for 256 samples along that path.
    // Initiate the path request.
      'path': path,
      'samples': 150
    }, plotElevation);

  function plotElevation(elevations, status) {
    var chartDiv = document.getElementById('elevation_chart');
    if (status !== 'OK') {
      // Show the error code inside the chartDiv.
      chartDiv.innerHTML = 'Cannot show elevation: request failed because ' +
    // Create a new chart in the elevation_chart DIV.
    var chart = new google.visualization.ColumnChart(chartDiv);

    // Extract the data from which to populate the chart.
    // Because the samples are equidistant, the 'Sample'
    // column here does double duty as distance along the
    // X axis.
    var data = new google.visualization.DataTable();
    data.addColumn('string', 'Sample');
    data.addColumn('number', 'Elevation');
    for (var i = 0; i < elevations.length; i++) {
      data.addRow(['', elevations[i].elevation]);

    // Draw the chart using the data within its DIV.
    chart.draw(data, {
      height: 150,
      legend: 'none',
      titleY: 'Elevation (m)'



To add a profile graph control in an ol.Map you can have a look at http://viglino.github.io/ol-ext/examples/control/map.control.profil.html It will handle the location of the click on the graph.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.