I have try to get the elevation of site based on latitude and longitude. When i am using the ajax call i am getting error. I have tried both HTTP and HTTPS getting same error message is
"No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access."
But the same URL it gives result in browser (https://maps.googleapis.com/maps/api/elevation/json?locations=36.7391536,-110.9847034).
I have added some header information like ('Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Credentials': true,'Access-Control-Allow-Methods': 'GET,PUT,POST,DELETE'). dataType : 'json' / 'jsonp' / 'application/json' and crossDomain: true, But it doesn't worked.
The ajax call is working for geocode URL but its not working for elevation URL
siteElevationlatLong: function (lat, long) {              
    var deferred = $q.defer();
    $.ajax({
        url: 'https://maps.googleapis.com/maps/api/elevation/json',              
        data: {
            sensor: false,
            locations: lat +',' + long,
        },
        dataType: 'json',
        success: function (data) {                      
            if (data.status == "OK" || data.status == "ZERO_RESULTS") {
                deferred.resolve(data.results);
            } else {
                deferred.resolve([]);
            }
        },
        error: function (jqXHR, textStatus, errorThrown) {                      
            deferred.reject(jqXHR.responseText);
        }
    });
    return deferred.promise;
}
 
    