]> git.openstreetmap.org Git - nominatim.git/commitdiff
make map tile layer configurable
authorMarc Tobias Metten <mtmail@gmx.net>
Wed, 27 Jan 2016 18:42:49 +0000 (19:42 +0100)
committerMarc Tobias Metten <mtmail@gmx.net>
Wed, 27 Jan 2016 18:42:49 +0000 (19:42 +0100)
lib/template/address-html.php
lib/template/details-html.php
lib/template/search-html.php
settings/settings.php
website/details.php
website/js/nominatim-ui.js
website/reverse.php
website/search.php

index dbe982f0eed1e56a5362c0de5a77d5846942c3ee..f8d425e20808f93e2e10d789f42fe9507eb4aa08 100644 (file)
   <?php
 
     $aNominatimMapInit = [
-      'zoom' => 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) . ';';
 
index 548cee7a6bf03def144ffed669f1cc388ea4babf..ec4a21086c67ec855e54a7c1f1fb351dfd350652 100644 (file)
@@ -6,7 +6,6 @@
        <link href="css/details.css" rel="stylesheet" type="text/css" />
 </head>
 
-<?php include(CONST_BasePath.'/lib/template/includes/html-top-navigation.php'); ?>
 
 
 <?php
 
 
 <body id="details-page">
+       <?php include(CONST_BasePath.'/lib/template/includes/html-top-navigation.php'); ?>
        <div class="container">
                <div class="row">
                        <div class="col-sm-10">
        </div>
 
        <script type="text/javascript">
+       <?php
 
-               var nominatim_result = {
-                       outlinestring: '<?php echo $aPointDetails['outlinestring'];?>',
-                       lon: <?php echo $aPointDetails['lon'];?>,
-                       lat: <?php echo $aPointDetails['lat'];?>,
-               };
+    $aNominatimMapInit = [
+      'tile_url' => $sTileURL,
+      'tile_attribution' => $sTileAttribution
+    ];
+    echo 'var nominatim_map_init = ' . json_encode($aNominatimMapInit, JSON_PRETTY_PRINT) . ';';
 
+    $aPlace = [
+                       'outlinestring' => $aPointDetails['outlinestring'],
+                       'lon' => $aPointDetails['lon'],
+                       'lat' => $aPointDetails['lat'],
+    ];
+         echo 'var nominatim_result = ' . json_encode($aPlace, JSON_PRETTY_PRINT) . ';'; 
+
+
+  ?>
        </script>
 
 
index e523c44680e9b268db9c1e39ee88ecfc87b1c5b2..8b995b626faa70832b2bd4a2848a38866408e03c 100644 (file)
@@ -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) . ';';
 
index cc81e7a90967f1b6c73a084bdab7b15c85439324..04ffe1621caa785362c4a6d55aa69875029b9b43 100644 (file)
@@ -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);
        @define('CONST_Log_File_Format', 'TODO'); // Currently hard coded
        @define('CONST_Log_File_SearchLog', '');
        @define('CONST_Log_File_ReverseLog', '');
+
+
index 54d8015ead9de33023a3016164780746a2ff872d..7cbb17ef29a6460880ab00f41b19419f68778fa1 100755 (executable)
 
        logEnd($oDB, $hLog, 1);
 
+       $sTileURL = CONST_Map_Tile_URL;
+       $sTileAttribution = CONST_Map_Tile_Attribution;
+       
        include(CONST_BasePath.'/lib/template/details-'.$sOutputFormat.'.php');
index 1a3ae15043df2d77fa7d7a1710e75e1d91be8a53..be10807453161cd96e4c1dcd516bf9bf44ebaf59 100644 (file)
@@ -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: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
+               attribution: (nominatim_map_init.tile_attribution || null ) //'&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> 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: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
+                       attribution: (nominatim_map_init.tile_attribution || null ) //'&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> 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});
index 5217f7348f58714f0061ddfcdb711842ba299987..e2dfaef80eeccdadae886f0611ba575e8a789584 100755 (executable)
@@ -76,4 +76,6 @@
                exit;
        }
 
+       $sTileURL = CONST_Map_Tile_URL;
+       $sTileAttribution = CONST_Map_Tile_Attribution;
        include(CONST_BasePath.'/lib/template/address-'.$sOutputFormat.'.php');
index 9137beade1921d8ab619b19f80f04d24978476b7..f2c327c07fefe6760d5c51426d588c0c214c4c56 100755 (executable)
@@ -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);