enhanced location search

pull/1/head
Michael Peter Christen 10 years ago
parent fca11701f0
commit 1269e77dfa

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 33 KiB

@ -26,7 +26,7 @@
// automatically adapt height of map upon window resize
function adaptHeight() {
document.getElementById('map').style.height = (document.documentElement.clientHeight - 130) + "px";
document.getElementById('map').style.height = (document.documentElement.clientHeight - 70) + "px";
}
window.onresize = adaptHeight;
@ -96,6 +96,7 @@
//document.getElementById('apilink').setAttribute('href', 'yacysearch_location.rss?query=' + query);
poisfound = 0;
document.getElementById('resultline').innerHTML = "";
document.getElementById('query').select();
}
function refresh() {
@ -122,11 +123,12 @@
// update map and result line
poisfound = mdcount;
document.getElementById('resultline').innerHTML = (poisfound == 0) ? "searching..." : poisfound + " <a href=\"" + poisxml + "\">POIs</a> found in region";
document.getElementById('resultline').innerHTML = (poisfound == 0) ? "" : poisfound + " <a href=\"" + poisxml + "\">POIs</a> found in region";
// check if any of the markers is visible on the screen.
// this is only necessary if shallZoom = false since this would set shallZoom = true
var bounds = searchLayer_md1.getDataExtent();
if (bounds == null) searchLayer_co1.getDataExtent();
/*
if (!shallZoom) {
// check all markers
@ -141,8 +143,7 @@
}
*/
// zoom to layer bounds
if (shallZoom) {
if (bounds == null) {return;} //bounds = searchLayer_co1.getDataExtent();
if (shallZoom && bounds != null) {
map.panTo(bounds.getCenterLonLat());
map.zoomTo(map.getZoomForExtent(bounds));
}
@ -150,7 +151,7 @@
</script>
</head>
<body id="yacysearch_location" onload="init();">
<body id="yacysearch_location" onload="init(); #(initsearch)#::search();#(/initsearch)#">
#(topmenu)#
#%env/templates/embeddedheader.template%#
::
@ -168,18 +169,23 @@ Click the API icon to see the XML.
To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de/wiki/index.php/Dev:API" target="_blank">API wiki page</a>.</span>
</div>
<form class="search small" onsubmit="return false;" class="search small" accept-charset="UTF-8">
<h2>#[promoteSearchPageGreeting]#</h2>
<div class="yacylogo"><a href="#[promoteSearchPageGreeting.homepage]#" class="yacylogo"><img src="#[promoteSearchPageGreeting.smallImage]#" alt="yacysearch" /></a></div>
<fieldset class="yacys">
<input type="text" value="#(initsearch)#::#[query]##(/initsearch)#" id="query" size="42" autofocus="autofocus" onFocus="this.select()" />
<input type="submit" onclick="search(); return false;" value="search" onsubmit="search(); return false;" />
</fieldset>
<div class="row">
<div class="col-sm-8 col-sm-offset-4 col-md-9 col-md-offset-3 main">
<form class="search small" name="searchform" action="" method="get" accept-charset="UTF-8" style="position:fixed;top:8px;z-index:1052;max-width:500px;">
<div class="input-group">
<input type="text" class="form-control searchinput typeahead" value="#(initsearch)#::#[query]##(/initsearch)#" id="query" size="42" autofocus="autofocus" onFocus="this.select()" />
<div class="input-group-btn">
<button id="Enter" class="btn btn-default" type="submit" onclick="search(); return false;" value="search" onsubmit="search(); return false;">search</button>
</div>
</div>
<div id="resultline"></div>
</form><br/>
</form>
</div> <!-- close sidebar -->
</div> <!-- close row -->
<div id="map" style="clear:both; width:100%; height:720px"></div>
<script type="text/javascript">
adaptHeight();
</script>
</body>
</html>

@ -72,8 +72,12 @@ public class yacysearch_location {
for (final String qp: query.split(" ")) {
locations.addAll(LibraryProvider.geoLoc.find(qp, true));
}
String ip = sb.peers.mySeed().getIP();
for (final GeoLocation location: locations) {
// write for all locations a point to this message
double lo = location.lon();
double la = location.lat();
if (lo == 0.0d && la == 0.0d) continue; // bad location
prop.put("kml_placemark_" + placemarkCounter + "_location", location.getName());
prop.put("kml_placemark_" + placemarkCounter + "_name", location.getName());
prop.put("kml_placemark_" + placemarkCounter + "_author", "");
@ -81,10 +85,10 @@ public class yacysearch_location {
prop.put("kml_placemark_" + placemarkCounter + "_subject", "");
prop.put("kml_placemark_" + placemarkCounter + "_description", "");
prop.put("kml_placemark_" + placemarkCounter + "_date", "");
prop.putXML("kml_placemark_" + placemarkCounter + "_url", "http://" + sb.peers.mySeed().getPublicAddress(sb.peers.mySeed().getIP()) + "/yacysearch.html?query=" + location.getName());
prop.putXML("kml_placemark_" + placemarkCounter + "_url", "http://" + sb.peers.mySeed().getPublicAddress(ip) + "/yacysearch.html?query=" + location.getName());
prop.put("kml_placemark_" + placemarkCounter + "_pointname", location.getName());
prop.put("kml_placemark_" + placemarkCounter + "_lon", location.lon());
prop.put("kml_placemark_" + placemarkCounter + "_lat", location.lat());
prop.put("kml_placemark_" + placemarkCounter + "_lon", lo);
prop.put("kml_placemark_" + placemarkCounter + "_lat", la);
placemarkCounter++;
}
}
@ -99,6 +103,9 @@ public class yacysearch_location {
RSSMessage message;
loop: while ((message = results.poll(maximumTime, TimeUnit.MILLISECONDS)) != RSSMessage.POISON) {
if (message == null) break loop;
double lo = message.getLon();
double la = message.getLat();
if (lo == 0.0d && la == 0.0d) continue; // bad location
prop.put("kml_placemark_" + placemarkCounter + "_location", message.getTitle());
prop.put("kml_placemark_" + placemarkCounter + "_name", message.getTitle());
prop.put("kml_placemark_" + placemarkCounter + "_author", message.getAuthor());
@ -108,8 +115,8 @@ public class yacysearch_location {
prop.put("kml_placemark_" + placemarkCounter + "_date", message.getPubDate());
prop.putXML("kml_placemark_" + placemarkCounter + "_url", message.getLink());
prop.put("kml_placemark_" + placemarkCounter + "_pointname", message.getTitle());
prop.put("kml_placemark_" + placemarkCounter + "_lon", message.getLon());
prop.put("kml_placemark_" + placemarkCounter + "_lat", message.getLat());
prop.put("kml_placemark_" + placemarkCounter + "_lon", lo);
prop.put("kml_placemark_" + placemarkCounter + "_lat", la);
placemarkCounter++;
if (placemarkCounter >= maximumRecords) break loop;
}

@ -74,12 +74,6 @@
</div>
#(/nav-protocols)#
#(cat-location)#::
<a href="yacysearch_location.html?query=#[queryenc]#">
<img src="env/grafics/earthsearch.png" width="215" height="159" alt="earthsearchlogo" /></a>
<a href="yacysearch_location.html?query=#[queryenc]#">Show search results for "#[query]#" on map</a>
#(/cat-location)#
#(nav-topics)#<p>&nbsp;</p>::
<div id="tagcloud" style="text-align:justify">#{element}#
<a rel="#[count]#" href="#[url]#" style="text-decoration:none;font-size:#[size]#px;">#[name]#</a>
@ -88,6 +82,17 @@
</script>
#(/nav-topics)#
#(cat-location)#::
<ul class="nav nav-sidebar menugroup">
<li><h3>Location</h3></li>
<li>
<a href="yacysearch_location.html?query=#[queryenc]#" class="MenuItemLink">
<img src="env/grafics/earthsearch.png" width="100%" height="86" alt="earthsearchlogo" /><br/>
show search results for "#[query]#" on map</a>
</li>
</ul>
#(/cat-location)#
#(nav-domains)#::
<ul class="nav nav-sidebar menugroup">
<li><h3>Provider</h3></li>

Loading…
Cancel
Save