From: Sarah Hoffmann Date: Sat, 6 Feb 2016 11:50:38 +0000 (+0100) Subject: Merge pull request #362 from mtmail/fix-timeout-on-detail-pages X-Git-Tag: v.2.5.0~8 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/40588482a245902c844631a50befeffa95c03dcb?hp=a73135aebee779e8f2f37e21361498455162cb6b Merge pull request #362 from mtmail/fix-timeout-on-detail-pages fix timeout on detail pages related to distance calculation --- diff --git a/lib/template/address-html.php b/lib/template/address-html.php index dbe982f0..f8d425e2 100644 --- a/lib/template/address-html.php +++ b/lib/template/address-html.php @@ -112,9 +112,11 @@ isset($_GET['zoom'])?htmlspecialchars($_GET['zoom']):NULL, - 'lat' => isset($_GET['lat'] )?htmlspecialchars($_GET['lat']):NULL, - 'lon' => isset($_GET['lon'] )?htmlspecialchars($_GET['lon']):NULL + 'zoom' => isset($_GET['zoom']) ? htmlspecialchars($_GET['zoom']) : CONST_Default_Zoom, + 'lat' => isset($_GET['lat'] ) ? htmlspecialchars($_GET['lat'] ) : CONST_Default_Lat, + 'lon' => isset($_GET['lon'] ) ? htmlspecialchars($_GET['lon'] ) : CONST_Default_Lon, + 'tile_url' => $sTileURL, + 'tile_attribution' => $sTileAttribution ]; echo 'var nominatim_map_init = ' . json_encode($aNominatimMapInit, JSON_PRETTY_PRINT) . ';'; diff --git a/lib/template/details-html.php b/lib/template/details-html.php index 548cee7a..ec4a2108 100644 --- a/lib/template/details-html.php +++ b/lib/template/details-html.php @@ -6,7 +6,6 @@ - +
@@ -261,13 +261,23 @@
diff --git a/lib/template/search-html.php b/lib/template/search-html.php index e523c446..8b995b62 100644 --- a/lib/template/search-html.php +++ b/lib/template/search-html.php @@ -99,7 +99,9 @@ $aNominatimMapInit = [ 'zoom' => $iZoom, 'lat' => $fLat, - 'lon' => $fLon + 'lon' => $fLon, + 'tile_url' => $sTileURL, + 'tile_attribution' => $sTileAttribution ]; echo 'var nominatim_map_init = ' . json_encode($aNominatimMapInit, JSON_PRETTY_PRINT) . ';'; diff --git a/settings/settings.php b/settings/settings.php index cc81e7a9..04ffe162 100644 --- a/settings/settings.php +++ b/settings/settings.php @@ -91,6 +91,8 @@ @define('CONST_Default_Lat', 20.0); @define('CONST_Default_Lon', 0.0); @define('CONST_Default_Zoom', 2); + @define('CONST_Map_Tile_URL', 'http://{s}.tile.osm.org/{z}/{x}/{y}.png'); + @define('CONST_Map_Tile_Attribution', ''); // Set if tile source isn't osm.org @define('CONST_Search_AreaPolygons_Enabled', true); @define('CONST_Search_AreaPolygons', true); @@ -114,3 +116,5 @@ @define('CONST_Log_File_Format', 'TODO'); // Currently hard coded @define('CONST_Log_File_SearchLog', ''); @define('CONST_Log_File_ReverseLog', ''); + + diff --git a/website/details.php b/website/details.php index 654cd7c7..ad753a82 100755 --- a/website/details.php +++ b/website/details.php @@ -159,4 +159,7 @@ logEnd($oDB, $hLog, 1); + $sTileURL = CONST_Map_Tile_URL; + $sTileAttribution = CONST_Map_Tile_Attribution; + include(CONST_BasePath.'/lib/template/details-'.$sOutputFormat.'.php'); diff --git a/website/js/nominatim-ui.js b/website/js/nominatim-ui.js index 1a3ae150..be108074 100644 --- a/website/js/nominatim-ui.js +++ b/website/js/nominatim-ui.js @@ -10,30 +10,23 @@ jQuery(document).on('ready', function(){ $('#q').focus(); map = new L.map('map', { - attributionControl: false, // moved to page footer + attributionControl: (nominatim_map_init.tile_attribution && nominatim_map_init.tile_attribution.length), scrollWheelZoom: !L.Browser.touch, touchZoom: false }); - - - L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { - noWrap: true // otherwise we end up with click coordinates like latitude -728 + L.tileLayer(nominatim_map_init.tile_url, { + noWrap: true, // otherwise we end up with click coordinates like latitude -728 // moved to footer - // attribution: '© OpenStreetMap contributors' + attribution: (nominatim_map_init.tile_attribution || null ) //'© OpenStreetMap contributors' }).addTo(map); - if ( nominatim_map_init.lat ){ - map.setView([nominatim_map_init.lat || 0, nominatim_map_init.lon], nominatim_map_init.zoom); - - if ( is_reverse_search ){ - // not really a market, but the .circle changes radius once you zoom in/out - var cm = L.circleMarker([nominatim_map_init.lat,nominatim_map_init.lon], { radius: 5, weight: 2, fillColor: '#ff7800', color: 'red', opacity: 0.75, clickable: false}); - cm.addTo(map); - } + map.setView([nominatim_map_init.lat, nominatim_map_init.lon], nominatim_map_init.zoom); - } else { - map.setView([0,0],2); + if ( is_reverse_search ){ + // We don't need a marker, but an L.circle instance changes radius once you zoom in/out + var cm = L.circleMarker([nominatim_map_init.lat,nominatim_map_init.lon], { radius: 5, weight: 2, fillColor: '#ff7800', color: 'red', opacity: 0.75, clickable: false}); + cm.addTo(map); } @@ -188,16 +181,18 @@ jQuery(document).on('ready', function(){ map = new L.map('map', { // center: [nominatim_map_init.lat, nominatim_map_init.lon], // zoom: nominatim_map_init.zoom, - attributionControl: false, + attributionControl: (nominatim_map_init.tile_attribution && nominatim_map_init.tile_attribution.length), scrollWheelZoom: false, touchZoom: false, }); - L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { + + L.tileLayer(nominatim_map_init.tile_url, { // moved to footer - // attribution: '© OpenStreetMap contributors' + attribution: (nominatim_map_init.tile_attribution || null ) //'© OpenStreetMap contributors' }).addTo(map); + var layerGroup = new L.layerGroup().addTo(map); var circle = L.circleMarker([nominatim_result.lat,nominatim_result.lon], { radius: 10, weight: 2, fillColor: '#ff7800', color: 'blue', opacity: 0.75}); diff --git a/website/reverse.php b/website/reverse.php index 5217f734..e2dfaef8 100755 --- a/website/reverse.php +++ b/website/reverse.php @@ -76,4 +76,6 @@ exit; } + $sTileURL = CONST_Map_Tile_URL; + $sTileAttribution = CONST_Map_Tile_Attribution; include(CONST_BasePath.'/lib/template/address-'.$sOutputFormat.'.php'); diff --git a/website/search.php b/website/search.php index 9137bead..f2c327c0 100755 --- a/website/search.php +++ b/website/search.php @@ -13,6 +13,8 @@ $fLat = CONST_Default_Lat; $fLon = CONST_Default_Lon; $iZoom = CONST_Default_Zoom; + $sTileURL = CONST_Map_Tile_URL; + $sTileAttribution = CONST_Map_Tile_Attribution; $oGeocode =& new Geocode($oDB);