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

The Browser Version of Maps will now use the Label Layer

parent b659fa99
No related branches found
No related tags found
No related merge requests found
...@@ -25,6 +25,9 @@ public function listFiles($minLon, $minLat, $maxLon, $maxLat){ ...@@ -25,6 +25,9 @@ public function listFiles($minLon, $minLat, $maxLon, $maxLat){
} }
socket_close($socket); socket_close($socket);
if($content == "")
abort(404, "File not found");
$response = Response::make($content, 200); $response = Response::make($content, 200);
$response->header('Content-Type', 'application/json'); $response->header('Content-Type', 'application/json');
$response->header('Cache-Control', 'max-age=0, no-cache, no-store, must-revalidate'); $response->header('Cache-Control', 'max-age=0, no-cache, no-store, must-revalidate');
...@@ -53,7 +56,7 @@ public function downloadFiles($minLon, $minLat, $maxLon, $maxLat){ ...@@ -53,7 +56,7 @@ public function downloadFiles($minLon, $minLat, $maxLon, $maxLat){
socket_close($socket); socket_close($socket);
# The result is a path to the Zip File that will get downloaded # The result is a path to the Zip File that will get downloaded
if(file_exists($file)){ if(file_exists($file) && filesize($file) > 0){
return response()->download($file, "offline-data.tar", return response()->download($file, "offline-data.tar",
[ [
"Content-Type" => "application/tar", "Content-Type" => "application/tar",
......
...@@ -41,6 +41,7 @@ InteractiveMap.prototype.initMap = function() { ...@@ -41,6 +41,7 @@ InteractiveMap.prototype.initMap = function() {
return ol.proj.transform(point, 'EPSG:3857', 'EPSG:4326'); return ol.proj.transform(point, 'EPSG:3857', 'EPSG:4326');
} }
var source = null; var source = null;
var labels = null;
if(typeof android === "undefined"){ if(typeof android === "undefined"){
// We are not serving this for the app so we'll use our regular Tile-Serve // We are not serving this for the app so we'll use our regular Tile-Serve
source = new ol.source.OSM({ source = new ol.source.OSM({
...@@ -57,7 +58,23 @@ InteractiveMap.prototype.initMap = function() { ...@@ -57,7 +58,23 @@ InteractiveMap.prototype.initMap = function() {
ol.source.OSM.ATTRIBUTION, ol.source.OSM.ATTRIBUTION,
], ],
//url: 'https://tiles.metager.de/{z}/{x}/{y}.png' //url: 'https://tiles.metager.de/{z}/{x}/{y}.png'
url: '/tile_cache/{z}/{x}/{y}.png' url: '/tiles/tile/{z}/{x}/{y}.png'
});
labels = new ol.source.OSM({
attributions: [
new ol.Attribution({
html: '&copy; ' + '<a href="https://metager.de/">MetaGer.de</a>'
}),
new ol.Attribution({
html: '| <a href="https://metager.de/impressum">Impressum</a>'
}),
new ol.Attribution({
html: '| &copy; ' + '<a href="http://nominatim.openstreetmap.org/">Nominatim</a>'
}),
ol.source.OSM.ATTRIBUTION,
],
//url: 'https://tiles.metager.de/{z}/{x}/{y}.png'
url: '/tiles/label/{z}/{x}/{y}.png'
}); });
}else{ }else{
// This is for our Android App we'll use another Tile-Server that has it's cache Disabled // This is for our Android App we'll use another Tile-Server that has it's cache Disabled
...@@ -88,19 +105,25 @@ InteractiveMap.prototype.initMap = function() { ...@@ -88,19 +105,25 @@ InteractiveMap.prototype.initMap = function() {
zoom = null; zoom = null;
this.updateMapPositionOnGps = false; this.updateMapPositionOnGps = false;
} }
var map = new ol.Map({ var layers = [];
layers: [ if(source != null){
layers.push(
new ol.layer.Tile({ new ol.layer.Tile({
preload: 0, preload: 0,
source: source source: source
}),/* })
)
}
if(labels != null){
layers.push(
new ol.layer.Tile({ new ol.layer.Tile({
source: new ol.source.TileDebug({ preload: 0,
projection: 'EPSG:3857', source: labels
tileGrid: source.getTileGrid() })
}) )
})*/ }
], var map = new ol.Map({
layers: layers,
target: 'map', target: 'map',
controls: ol.control.defaults({ controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({ attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
......
...@@ -27,6 +27,67 @@ Route::group(['prefix' => 'download'], function(){ ...@@ -27,6 +27,67 @@ Route::group(['prefix' => 'download'], function(){
Route::get('{minx}/{miny}/{maxx}/{maxy}/{zoomstart}/{zoomend}', 'DownloadController@downloadArea'); Route::get('{minx}/{miny}/{maxx}/{maxy}/{zoomstart}/{zoomend}', 'DownloadController@downloadArea');
}); });
Route::get('tile_cache/{z}/{x}/{y}.png', function($z, $x, $y){
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_connect($socket, env("TILESERVER_HOST"), env("TILESERVER_PORT"));
socket_write($socket, "generate-tile;$z;$x;$y\n", strlen("generate-tile;$z;$x,$y\n"));
$content = "";
while(true){
$tmp = socket_read($socket, 4096);
if($tmp == "") break;
else $content .= $tmp;
}
$response = Response::make($content, 200);
$response->header('Content-Type', 'image/png');
$response->header('Cache-Control', 'max-age=0, no-cache, no-store, must-revalidate');
$response->header('Pragma', 'no-cache');
$response->header('Expires', 'Wed, 11 Jan 1984 05:00:00 GMT');
return $response;
});
Route::group(['prefix' => 'tiles'], function(){
Route::get('tile/{z}/{x}/{y}.png', function($z, $x, $y){
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_connect($socket, env("TILESERVER_HOST"), env("TILESERVER_PORT"));
socket_write($socket, "tile-tile;$z;$x;$y\n", strlen("generate-tile;$z;$x,$y\n"));
$content = "";
while(true){
$tmp = socket_read($socket, 4096);
if($tmp == "") break;
else $content .= $tmp;
}
$response = Response::make($content, 200);
$response->header('Content-Type', 'image/png');
$response->header('Cache-Control', 'max-age=0, no-cache, no-store, must-revalidate');
$response->header('Pragma', 'no-cache');
$response->header('Expires', 'Wed, 11 Jan 1984 05:00:00 GMT');
return $response;
});
Route::get('label/{z}/{x}/{y}.png', function($z, $x, $y){
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_connect($socket, env("TILESERVER_HOST"), env("TILESERVER_PORT"));
socket_write($socket, "tile-label;$z;$x;$y\n", strlen("generate-tile;$z;$x,$y\n"));
$content = "";
while(true){
$tmp = socket_read($socket, 4096);
if($tmp == "") break;
else $content .= $tmp;
}
$response = Response::make($content, 200);
$response->header('Content-Type', 'image/png');
$response->header('Cache-Control', 'max-age=0, no-cache, no-store, must-revalidate');
$response->header('Pragma', 'no-cache');
$response->header('Expires', 'Wed, 11 Jan 1984 05:00:00 GMT');
return $response;
});
});
Route::group(['prefix' => 'map'], function () { Route::group(['prefix' => 'map'], function () {
Route::get('/', function () { Route::get('/', function () {
return view('map')->with('css', [elixir('css/general.css'), elixir('css/mapSearch.css'), elixir('css/routing.css')]); return view('map')->with('css', [elixir('css/general.css'), elixir('css/mapSearch.css'), elixir('css/routing.css')]);
...@@ -121,24 +182,6 @@ Route::group(['prefix' => 'metager'], function () { ...@@ -121,24 +182,6 @@ Route::group(['prefix' => 'metager'], function () {
Route::get('{search}', 'SearchController@iframeSearch'); Route::get('{search}', 'SearchController@iframeSearch');
}); });
Route::get('tile_cache/{z}/{x}/{y}.png', function($z, $x, $y){
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_connect($socket, env("TILESERVER_HOST"), env("TILESERVER_PORT"));
socket_write($socket, "generate-tile;$z;$x;$y\n", strlen("generate-tile;$z;$x,$y\n"));
$content = "";
while(true){
$tmp = socket_read($socket, 4096);
if($tmp == "") break;
else $content .= $tmp;
}
$response = Response::make($content, 200);
$response->header('Content-Type', 'image/png');
$response->header('Cache-Control', 'max-age=0, no-cache, no-store, must-revalidate');
$response->header('Pragma', 'no-cache');
$response->header('Expires', 'Wed, 11 Jan 1984 05:00:00 GMT');
return $response;
});
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