]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/template/search-html.php
use geometry WKT for highlighting in search view
[nominatim.git] / lib / template / search-html.php
index f701379329a41d17065ebe59b47525c916283997..3fd8096dda390e2b3004969bd09ca2d28ef4daf3 100644 (file)
@@ -208,7 +208,7 @@ form{
                        map.panTo(lonLat, <?php echo $iZoom ?>);
                }
 
-               function panToLatLonZoom(lat,lon, zoom) {
+               function panToLatLonZoom(lat, lon, zoom) {
                        var lonLat = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
                        if (zoom != map.getZoom())
                                map.setCenter(lonLat, zoom);
@@ -216,38 +216,34 @@ form{
                                map.panTo(lonLat, 10);
                }
 
-               function panToLatLonBoundingBox(lat,lon,minlat,maxlat,minlon,maxlon,points) {
-                       var proj_EPSG4326 = new OpenLayers.Projection("EPSG:4326");
-                       var proj_map = map.getProjectionObject();
-                        map.zoomToExtent(new OpenLayers.Bounds(minlon,minlat,maxlon,maxlat).transform(proj_EPSG4326, proj_map));
+               function panToLatLonBoundingBox(lat,lon,minlat,maxlat,minlon,maxlon,wkt) {
+                       vectorLayer.destroyFeatures();
+                       var proj_EPSG4326 = new OpenLayers.Projection("EPSG:4326");
+                       var proj_map = map.getProjectionObject();
+                       map.zoomToExtent(new OpenLayers.Bounds(minlon,minlat,maxlon,maxlat).transform(proj_EPSG4326, proj_map));
+                       var lonLat = new OpenLayers.LonLat(lon, lat).transform(proj_EPSG4326, proj_map);
+                       map.panTo(lonLat, <?php echo $iZoom ?>);
 
-                        var pointList = [];
-                        var style = {
-                                strokeColor: "#75ADFF",
-                                fillColor: "#F0F7FF",
-                                strokeWidth: 2,
-                                strokeOpacity: 0.75,
-                                fillOpacity: 0.75
-                        };
-                        var proj_EPSG4326 = new OpenLayers.Projection("EPSG:4326");
-                        var proj_map = map.getProjectionObject();
-                       if (points)
+                       if (wkt)
                        {
-                               points.each(function(p){
-                                       pointList.push(new OpenLayers.Geometry.Point(p[0],p[1]));
-                                       });
-                               var linearRing = new OpenLayers.Geometry.LinearRing(pointList).transform(proj_EPSG4326, proj_map);;
-                               var polygonFeature = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Polygon([linearRing]),null,style);
-                               vectorLayer.destroyFeatures();
-                               vectorLayer.addFeatures([polygonFeature]);
-                       }
-                       else
-                       {
-                               var lonLat = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
-                               var point = new OpenLayers.Geometry.Point(lonLat.lon, lonLat.lat);
-                               var pointFeature = new OpenLayers.Feature.Vector(point,null,style);
-                               vectorLayer.destroyFeatures();
-                               vectorLayer.addFeatures([pointFeature]);
+                               var freader = new OpenLayers.Format.WKT({
+                                               'internalProjection': proj_map,
+                                               'externalProjection': proj_EPSG4326
+                                               });
+
+                               var feature = freader.read(wkt);
+                               if (feature)
+                               {
+                                       feature.style = {
+                                                       strokeColor: "#75ADFF",
+                                                       fillColor: "#F0F7FF",
+                                                       strokeWidth: 2,
+                                                       strokeOpacity: 0.75,
+                                                       fillOpacity: 0.75,
+                                                       pointRadius: 100
+                    };
+                                       vectorLayer.addFeatures([feature]);
+                               }
                        }
                }
 
@@ -290,10 +286,11 @@ form{
                 projection: new OpenLayers.Projection("EPSG:900913"),
                 displayProjection: new OpenLayers.Projection("EPSG:4326"),
                 eventListeners: {
-                                                                       "moveend": mapEventMove,
+                                                                       "moveend": mapEventMove
                                                                }
                } );
-                       map.addLayer(new OpenLayers.Layer.OSM.<?php echo CONST_Tile_Default;?>("Default"));
+                       map.addLayer(new OpenLayers.Layer.OSM.<?php echo CONST_Tile_Default;?>("Default",
+                         { attribution : '© <a target="_parent" href="http://www.openstreetmap.org">OpenStreetMap</a> and contributors, under an <a target="_parent" href="http://www.openstreetmap.org/copyright">open license</a>'}));
 
                        var layer_style = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);
                        layer_style.fillOpacity = 0.2;
@@ -317,20 +314,20 @@ form{
        <div id="seachheaderfade1"></div><div id="seachheaderfade2"></div><div id="seachheaderfade3"></div><div id="seachheaderfade4"></div>
 
        <div id="seachheader">
-               <form action="<?php echo CONST_Website_BaseURL; ?>search.php" method="get">
+               <form accept-charset="UTF-8" action="<?php echo CONST_Website_BaseURL; ?>search.php" method="get">
                        <table border="0" width="100%">
                                <tr>
                                        <td valign="center" style="width:30px;"><img src="images/logo.gif"></td>
                                        <td valign="center" style="width:400px;"><input id="q" name="q" value="<?php echo htmlspecialchars($sQuery); 
 ?>" style="width:270px;"><input type="text" id="viewbox" style="width:130px;" name="viewbox"></td>
                                        <td style="width:80px;"><input type="submit" value="Search"></td>
-<?php if (CONST_Search_AreaPolygons) { ?>                                      <td style="width:100px;"><input type="checkbox" value="1" name="polygon" <?php if ($bShowPolygons) echo "checked"; ?>> Highlight</td>
+<?php if (CONST_Search_AreaPolygons) { ?>                                      <td style="width:100px;"><input type="checkbox" value="1" name="polygon" <?php if ($bAsText) echo "checked"; ?>> Highlight</td>
 <td style="text-align:right;">Data: <?php echo $sDataDate; ?></td>
 <td style="text-align:right;">
 <a href="http://wiki.openstreetmap.org/wiki/Nominatim" target="_blank">Documentation</a> | <a href="http://wiki.openstreetmap.org/wiki/Nominatim/FAQ" 
 target="_blank">FAQ</a></td>
 
-<?php } ?>                                     <td style="text-align:right;"><?php if ($sQuery) { if ($sReportDescription) {?><div style="text-align:center;"><b>Thank you for your problem report</b></div><?php } else { ?><input type="button" value="Report Problem With Results" onclick="$('report').style.visibility=($('report').style.visibility=='hidden'?'visible':'hidden')"><?php }} ?></td>
+<?php } ?>                                     <td style="text-align:right;"><?php if ($sQuery) { ?><input type="button" value="Report Problem With Results" onclick="$('report').style.visibility=($('report').style.visibility=='hidden'?'visible':'hidden')"><?php } ?></td>
                                </tr>
                        </table>
                </form>
@@ -356,8 +353,8 @@ target="_blank">FAQ</a></td>
                        echo ', '.$aResult['aBoundingBox'][1];
                        echo ', '.$aResult['aBoundingBox'][2];
                        echo ', '.$aResult['aBoundingBox'][3];
-                       echo ', '.javascript_renderData($aResult['aPolyPoints']);
-                       echo ');\'>';
+                       if (isset($aResult['astext'])) echo ', "'.$aResult['astext'].'"';
+                       echo ");'>\n";
                }
                elseif (isset($aResult['zoom']))
                {
@@ -368,9 +365,9 @@ target="_blank">FAQ</a></td>
                        echo '<div class="result" onClick="panToLatLon('.$aResult['lat'].', '.$aResult['lon'].');">';
                }
 
-               echo ($aResult['icon']?'<img src="'.$aResult['icon'].'">':'');
+               echo (isset($aResult['icon'])?'<img src="'.$aResult['icon'].'">':'');
                echo ' <span class="name">'.$aResult['name'].'</span>';
-               echo ' <span class="latlon">'.round($aResult['lat'],3).','.round($aResult['lat'],3).'</span>';
+               echo ' <span class="latlon">'.round($aResult['lat'],3).','.round($aResult['lon'],3).'</span>';
                echo ' <span class="place_id">'.$aResult['place_id'].'</span>';
                if (isset($aResult['label']))
                        echo ' <span class="type">('.$aResult['label'].')</span>';
@@ -448,7 +445,7 @@ init();
                        echo ', '.$aResult['aBoundingBox'][1];
                        echo ', '.$aResult['aBoundingBox'][2];
                        echo ', '.$aResult['aBoundingBox'][3];
-                       echo ', '.javascript_renderData($aResult['aPolyPoints']);
+                       if (isset($aResult['astext'])) echo ", '".$aResult['astext']."'";
                        echo ');'."\n";
                }
                else