Skip to content
Snippets Groups Projects
Commit 187afb99 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Erster Schritt für eine Anzeige im Iframe

parent 67e0ecaa
No related branches found
No related tags found
No related merge requests found
......@@ -13,12 +13,12 @@ public function boundingBoxSearch($search, $latMin, $lonMin, $latMax, $lonMax, $
// Gibt an, ob die Suche im angezeigten Bereich erfolgreich war:
$boundingSuccess = true;
# Get The Search Results
$link = "https://maps.metager.de/nominatim/search.php?q=" . urlencode($search) . "&limit=1000&bounded=1&polygon_geojson=1&viewbox=$latMin,$lonMin,$latMax,$lonMax&format=json&extratags=1&addressdetails=1";
$link = "https://maps.metager.de/nominatim/search.php?q=" . urlencode($search) . "&limit=50&bounded=1&polygon_geojson=1&viewbox=$latMin,$lonMin,$latMax,$lonMax&format=json&extratags=1&addressdetails=1";
$results = json_decode(file_get_contents($link), true);
if (!$results && $latMin && $lonMin && $latMax && $lonMax) {
$boundingSuccess = false;
$link = "https://maps.metager.de/nominatim/search.php?q=" . urlencode($search) . "&limit=1000&polygon_geojson=1&format=json&extratags=1&addressdetails=1";
$link = "https://maps.metager.de/nominatim/search.php?q=" . urlencode($search) . "&limit=50&polygon_geojson=1&format=json&extratags=1&addressdetails=1";
$results = json_decode(file_get_contents($link), true);
}
......@@ -42,9 +42,38 @@ public function boundingBoxSearch($search, $latMin, $lonMin, $latMax, $lonMax, $
$searchResults[] = $tmp;
}
}
# Wir erstellen die Ergebnisseite (JavaScipr)
# Wir erstellen die Ergebnisseite (JavaScipt)
$response = Response::make(view('searchResults')->with("results", json_encode($searchResults))->with('adjustView', $adjustView)->with('boundingSuccess', $boundingSuccess), 200);
$response->header('Content-Type', 'application/javascript');
return $response;
}
public function iframeSearch($search)
{
# Bei der Iframe Suche begrenzen wir die Ergebniszahl auf 3
$link = "https://maps.metager.de/nominatim/search.php?q=" . urlencode($search) . "&limit=3&polygon_geojson=1&format=json&extratags=1&addressdetails=1";
$results = json_decode(file_get_contents($link), true);
$searchResults = [];
if ($results) {
foreach ($results as $result) {
$tmp = [];
# Marker
$tmp["lon"] = $result["lon"];
$tmp["lat"] = $result["lat"];
$tmp["title"] = substr($result["display_name"], 0, strpos($result["display_name"], ","));
$tmp["type"] = $result["type"];
$tmp["address"] = $result["address"];
$tmp["extratags"] = $result["extratags"];
$tmp["boundingbox"] = $result["boundingbox"];
$tmp["geojson"] = $result["geojson"];
$tmp["huerotate"] = hexdec(substr(md5(serialize($result)), 0, 5)) % 360;
$tmp["place_id"] = $result["place_id"];
$searchResults[] = $tmp;
}
}
# Wir erstellen die Ergebnisseite (JavaScipt)
return view('mapIframe')->with("results", json_encode($searchResults))->with('adjustView', true);
}
}
This diff is collapsed.
This diff is collapsed.
......@@ -229,4 +229,22 @@ function clearPOIS(){
$("#results > h4").remove();
overlays = [];
}
/**
* Fügt einen Marker auf die Karte hinzu
* Parameter:
* el: HTML-Code für das Element, welches den Marker definiert
* pos: Position, auf der sich der Marker befinden soll int[2] (Lat, Long)
**/
function addMarker(el, pos){
var overlay = new ol.Overlay({
position: pos,
element: el,
offset: [-12, -45],
stopEvent: false,
});
map.addOverlay(overlay);
overlays.push(overlay);
}
\ No newline at end of file
......@@ -14,15 +14,8 @@ $("#showResults").click(function(){
$.each(searchResults, function(index, value) {
var el = $('<span id="index" class="marker" style="filter: hue-rotate('+value["huerotate"]+'deg);">'+index+'</span>');
var pos = ol.proj.transform([parseFloat(value["lon"]), parseFloat(value["lat"])], 'EPSG:4326', 'EPSG:3857');
var overlay = new ol.Overlay({
position: pos,
element: el,
offset: [-12, -45],
stopEvent: false,
});
map.addOverlay(overlay);
overlays.push(overlay);
addMarker(el, pos);
// Push Resultlist
var type = typeof value["type"] !== 'undefined' ? value["type"] : "";
......
......@@ -16,3 +16,5 @@ Route::get('/', function () {
});
Route::get('{search}/{latMin}/{lonMin}/{latMax}/{lonMax}/{adjustView?}', 'SearchController@boundingBoxSearch');
Route::get('metager/{search}', 'SearchController@iframeSearch');
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment