From 1c90c9ddab42463d999d69060b8a0a5b5c1b0d85 Mon Sep 17 00:00:00 2001 From: leosw Date: Wed, 19 May 2021 22:44:52 +0200 Subject: [PATCH] Adding the elevation API in poi edit form --- controllers/d.poi.php | 13 +++++++++++-- views/css/d.poi.css | 12 ++++++++++++ views/d.poi.edit.html | 3 ++- views/js/d.poi_map.js | 8 ++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/controllers/d.poi.php b/controllers/d.poi.php index b088fc1..08d9ab1 100755 --- a/controllers/d.poi.php +++ b/controllers/d.poi.php @@ -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"))) { diff --git a/views/css/d.poi.css b/views/css/d.poi.css index de04844..4b6eee4 100755 --- a/views/css/d.poi.css +++ b/views/css/d.poi.css @@ -229,4 +229,16 @@ 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; } \ No newline at end of file diff --git a/views/d.poi.edit.html b/views/d.poi.edit.html index 04523b8..52f391f 100755 --- a/views/d.poi.edit.html +++ b/views/d.poi.edit.html @@ -36,7 +36,8 @@
- + +
diff --git a/views/js/d.poi_map.js b/views/js/d.poi_map.js index a53d43f..08ed3e1 100755 --- a/views/js/d.poi_map.js +++ b/views/js/d.poi_map.js @@ -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'); + }); + }) }); \ No newline at end of file