Adding the elevation API in poi edit form
This commit is contained in:
parent
428ce900f0
commit
1c90c9ddab
|
@ -16,7 +16,7 @@ switch ($controller->splitted_url[1]) {
|
|||
$poi->poi_type = $_POST['poi_type'];
|
||||
$poi->lat = $_POST['lat'];
|
||||
$poi->lon = $_POST['lon'];
|
||||
$poi->alt = $_POST['alt'];
|
||||
$poi->ele = $_POST['ele'];
|
||||
$poi->author = $user->id;
|
||||
if(!$blogArticle->checkPermalink($_POST['permalink'],1)) {
|
||||
$blogArticle->permalink = $_POST['permalink'];
|
||||
|
@ -39,7 +39,7 @@ switch ($controller->splitted_url[1]) {
|
|||
$head['css'] .= ";../third/leaflet/leaflet.css;../third/leaflet-fullscreen/leaflet.fullscreen.css;../third/leaflet-easybutton/easy-button.css";
|
||||
$head['js'] = "d.poi_map.js";
|
||||
|
||||
$poi->lat = ""; $poi->lon = ""; $poi->alt = "";
|
||||
$poi->lat = ""; $poi->lon = ""; $poi->ele = "";
|
||||
|
||||
$new = 1;
|
||||
include ($config['views_folder']."d.poi.edit.html");
|
||||
|
@ -48,6 +48,15 @@ switch ($controller->splitted_url[1]) {
|
|||
else {
|
||||
$notfound = 1;
|
||||
}
|
||||
case "elevation_proxy":
|
||||
if(isset($_GET['location'])) {
|
||||
header("Content-Type: application/json;charset=utf-8");
|
||||
echo(file_get_contents("https://api.opentopodata.org/v1/mapzen?locations=".$_GET['location']));
|
||||
break;
|
||||
}
|
||||
else {
|
||||
$notfound = 1;
|
||||
}
|
||||
default:
|
||||
// // If the page exists
|
||||
// if ($blogArticle->checkPermalink($controller->splitted_url[1],$user->rankIsHigher("premium"))) {
|
||||
|
|
|
@ -230,3 +230,15 @@ form.form input[type=radio]+label img {
|
|||
.leaflet-control-scale {
|
||||
opacity: 0.8 !important;
|
||||
}
|
||||
|
||||
#elevation_icon {
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
top: 18px;
|
||||
right: 34px;
|
||||
}
|
||||
|
||||
#elevation_icon i {
|
||||
position: absolute;
|
||||
}
|
|
@ -36,7 +36,8 @@
|
|||
<div class="flex_line">
|
||||
<input type="text" value="<?=$poi->lat?>" name="lat" id="lat" placeholder="Latitude">
|
||||
<input type="text" value="<?=$poi->lon?>" name="lon" id="lon" placeholder="Longitude">
|
||||
<input type="text" value="<?=$poi->alt?>" name="alt" id="alt" placeholder="Altitude">
|
||||
<input type="text" value="<?=$poi->ele?>" name="ele" id="ele" placeholder="Altitude">
|
||||
<div id="elevation_icon" title="Calculer l'altitude"><i class="fas fa-search-location"></i></div>
|
||||
</div>
|
||||
|
||||
<input name="submit" id="submit" type="submit" value="Ajouter l'hébergement">
|
||||
|
|
|
@ -66,4 +66,12 @@ $( document ).ready(function() {
|
|||
poiicon.options.iconUrl = e.currentTarget.firstChild.currentSrc;
|
||||
poi_layer.setIcon(poiicon);
|
||||
})
|
||||
|
||||
$("#elevation_icon").click(function(e) {
|
||||
$(this).find($(".fas")).removeClass('fa-search-location').addClass('fa-spinner').addClass('fa-spin');
|
||||
$.get("./elevation_proxy", {location:$("#lat").val()+","+$("#lon").val()}, function(result){
|
||||
$("#ele").val(result.results[0].elevation);
|
||||
$("#elevation_icon").find($(".fas")).removeClass('fa-spinner').removeClass('fa-spin').addClass('fa-search-location');
|
||||
});
|
||||
})
|
||||
});
|
Loading…
Reference in New Issue