]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/template/address-html.php
reverse webpage: don't choose zoom level 0 when none is given
[nominatim.git] / lib / template / address-html.php
index 34bf852cacceadb5c5a50766ba485162a05be927..dbe982f0eed1e56a5362c0de5a77d5846942c3ee 100644 (file)
       <input name="format" type="hidden" value="html">
       <input name="lat" type="text" class="form-control input-sm" placeholder="latitude"  value="<?php echo htmlspecialchars($_GET['lat']); ?>" >
       <input name="lon" type="text" class="form-control input-sm" placeholder="longitude" value="<?php echo htmlspecialchars($_GET['lon']); ?>" >
+      max zoom
+
+      <select name="zoom" class="form-control input-sm" value="<?php echo htmlspecialchars($_GET['zoom']); ?>">
+        <option value="" <?php echo $_GET['zoom']==''?'selected':'' ?> >--</option>
+        <?php
+
+          $aZoomLevels = array(
+             0 => "Continent / Sea",
+             1 => "",
+             2 => "",
+             3 => "Country",
+             4 => "",
+             5 => "State",
+             6 => "Region",
+             7 => "",
+             8 => "County",
+             9 => "",
+            10 => "City",
+            11 => "",
+            12 => "Town / Village",
+            13 => "",
+            14 => "Suburb",
+            15 => "",
+            16 => "Street",
+            17 => "",
+            18 => "Building",
+            19 => "",
+            20 => "",
+            21 => "",
+          );
+
+          foreach($aZoomLevels as $iZoomLevel => $sLabel)
+          {
+            $bSel = isset($_GET['zoom']) && ($_GET['zoom'] == (string)$iZoomLevel);
+            echo '<option value="'.$iZoomLevel.'"'.($bSel?'selected':'').'>'.$iZoomLevel.' '.$sLabel.'</option>'."\n";
+          }
+        ?>
+      </select>
     </div>
     <div class="form-group search-button-group">
       <button type="submit" class="btn btn-primary btn-sm">Search</button>
   <?php
 
     $aNominatimMapInit = [
-      'zoom' => (isset($_GET['lat'])||$_GET['lat'])?16:NULL,
-      'lat' => isset($_GET['lat'])?htmlspecialchars($_GET['lat']):NULL,
-      'lon' => isset($_GET['lon'])?htmlspecialchars($_GET['lon']):NULL
+      'zoom' => isset($_GET['zoom'])?htmlspecialchars($_GET['zoom']):NULL,
+      'lat'  => isset($_GET['lat'] )?htmlspecialchars($_GET['lat']):NULL,
+      'lon'  => isset($_GET['lon'] )?htmlspecialchars($_GET['lon']):NULL
     ];
     echo 'var nominatim_map_init = ' . json_encode($aNominatimMapInit, JSON_PRETTY_PRINT) . ';';