]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/search-html.php
simplify getNearestRoadFeature function
[nominatim.git] / lib / template / search-html.php
1 <?php
2     header("content-type: text/html; charset=UTF-8");
3 ?>
4 <?php include(CONST_BasePath.'/lib/template/includes/html-header.php'); ?>
5     <link href="css/common.css" rel="stylesheet" type="text/css" />
6     <link href="css/search.css" rel="stylesheet" type="text/css" />
7 </head>
8
9 <body id="search-page">
10
11     <?php include(CONST_BasePath.'/lib/template/includes/html-top-navigation.php'); ?>
12
13     <form class="form-inline" role="search" accept-charset="UTF-8" action="<?php echo CONST_Website_BaseURL; ?>search.php">
14         <div class="form-group">
15             <input id="q" name="q" type="text" class="form-control input-sm" placeholder="Search" value="<?php echo htmlspecialchars($sQuery); ?>" >
16         </div>
17         <div class="form-group search-button-group">
18             <button type="submit" class="btn btn-primary btn-sm">Search</button>
19             <?php if (CONST_Search_AreaPolygons) { ?>
20                 <input type="hidden" value="1" name="polygon_geojson" />
21             <?php } ?>
22             <input type="hidden" name="viewbox" value="<?php if (isset($aMoreParams['viewbox'])) echo ($aMoreParams['viewbox']); ?>" />
23             <div class="checkbox-inline">
24                 <input type="checkbox" id="use_viewbox" <?php if (isset($aMoreParams['viewbox'])) echo "checked='checked'"; ?>>
25                 <label for="use_viewbox">apply viewbox</label>
26             </div>
27         </div>
28         <div class="search-type-link">
29             <a id="switch-to-reverse" href="<?php echo CONST_Website_BaseURL; ?>reverse.php?format=html">reverse search</a>
30         </div>
31     </form>
32
33
34     <div id="content">
35
36 <?php if ($sQuery) { ?>
37
38         <div id="searchresults" class="sidebar">
39         <?php
40             $i = 0;
41             foreach($aSearchResults as $iResNum => $aResult)
42             {
43
44                 echo '<div class="result" data-position=' . $i . '>';
45
46                 echo (isset($aResult['icon'])?'<img alt="icon" src="'.$aResult['icon'].'"/>':'');
47                 echo ' <span class="name">'.htmlspecialchars($aResult['name']).'</span>';
48                 // echo ' <span class="latlon">'.round($aResult['lat'],3).','.round($aResult['lon'],3).'</span>';
49                 // echo ' <span class="place_id">'.$aResult['place_id'].'</span>';
50                 if (isset($aResult['label']))
51                     echo ' <span class="type">('.$aResult['label'].')</span>';
52                 else if ($aResult['type'] == 'yes')
53                     echo ' <span class="type">('.ucwords(str_replace('_',' ',$aResult['class'])).')</span>';
54                 else
55                     echo ' <span class="type">('.ucwords(str_replace('_',' ',$aResult['type'])).')</span>';
56                 echo detailsPermaLink($aResult, 'details', 'class="btn btn-default btn-xs details"');
57                 echo '</div>';
58                 $i = $i+1;
59             }
60             if (!empty($aSearchResults) && $sMoreURL)
61             {
62                 echo '<div class="more"><a class="btn btn-primary" href="'.htmlentities($sMoreURL).'">Search for more results</a></div>';
63             }
64             else
65             {
66                 echo '<div class="noresults">No search results found</div>';
67             }
68
69         ?>
70         </div>
71
72 <?php } else { ?>
73
74         <div id="intro" class="sidebar">
75             <?php include(CONST_BasePath.'/lib/template/includes/introduction.php'); ?>
76         </div>
77
78 <?php } ?>
79
80         <div id="map-wrapper">
81             <div id="map-position">
82                 <div id="map-position-inner"></div>
83                 <div id="map-position-close"><a href="#">hide</a></div>
84             </div>
85             <div id="map"></div>
86         </div>
87
88     </div> <!-- /content -->
89
90
91
92
93
94
95
96     <script type="text/javascript">
97     <?php
98
99         $aNominatimMapInit = array(
100             'zoom' => CONST_Default_Zoom,
101             'lat' => CONST_Default_Lat,
102             'lon' => CONST_Default_Lon,
103             'tile_url' => CONST_Map_Tile_URL,
104             'tile_attribution' => CONST_Map_Tile_Attribution
105         );
106         echo 'var nominatim_map_init = ' . json_encode($aNominatimMapInit, JSON_PRETTY_PRINT) . ';';
107
108         echo 'var nominatim_results = ' . json_encode($aSearchResults, JSON_PRETTY_PRINT) . ';'; 
109     ?>
110     </script>
111     <?php include(CONST_BasePath.'/lib/template/includes/html-footer.php'); ?>
112
113 </body>
114 </html>