1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| map.on('singleclick',function (e) {
var clickCoord = e.coordinate;
var clickCoordLonLat = ol.proj.transform(clickCoord, map.getView().getProjection(), 'EPSG:4326');
var fo = {type: ["PositionOfInterest"]};
Gp.Services.getAltitude({
apiKey : "5tddd1s4k1a9vr174isjuy2d",
positions : [ // positions pour le calcul alti
{ lon: clickCoordLonLat[0], lat: clickCoordLonLat[1] },
],
onSuccess : function (result) {
//renvoi dans le formulaire de lat et lon arrondies à 6 chiffres et altitude arrondi à l'entier
document.monform.lon.value=Math.round(1000000*clickCoordLonLat[0])/1000000;
document.monform.lat.value=Math.round(1000000*clickCoordLonLat[1])/1000000;
document.monform.alt.value=Math.round(result.elevations[0].z);
document.monform.lat_lon.value=Math.round(1000000*clickCoordLonLat[1])/1000000+','+Math.round(1000000*clickCoordLonLat[0])/1000000;
}
});
Gp.Services.reverseGeocode({
position: {
x: clickCoordLonLat[0],
y: clickCoordLonLat[1]
},
filterOptions: fo,
apiKey: "5tddd1s4k1a9vr174isjuy2d",
onSuccess: function(result) {
document.monform.insee.innerHTML = "<p>" + JSON.stringify(result) + "</p>"
},
onFailure: function(error) {
document.monform.insee.innerHTML = "<p>" + error + "</p>"
}
});
}
); |
Partager