1 function initializeSearch(map) {
2 $("#search_form").submit(submitSearch);
3 $("#describe_location").click(describeLocation);
5 if ($("#query").val()) {
6 $("#search_form").submit();
10 .on("focus", function() {
11 $("#describe_location").fadeOut(100);
13 .on("blur", function() {
14 $("#describe_location").fadeIn(100);
17 $("#sidebar_content").on("click", ".search_results_entry a.set_position", clickSearchResult);
19 var marker = L.marker([0, 0], {icon: getUserIcon()});
21 function submitSearch(e) {
24 var bounds = map.getBounds();
26 $("#sidebar_content").load($(this).attr("action"), {
27 query: $("#query").val(),
29 minlon: bounds.getWest(),
30 minlat: bounds.getSouth(),
31 maxlon: bounds.getEast(),
32 maxlat: bounds.getNorth()
35 $("#sidebar").one("closed", function () {
36 map.removeLayer(marker);
41 function clickSearchResult(e) {
44 var data = $(this).data(),
45 center = L.latLng(data.lat, data.lon);
47 if (data.minLon && data.minLat && data.maxLon && data.maxLat) {
48 map.fitBounds([[data.minLat, data.minLon],
49 [data.maxLat, data.maxLon]]);
51 map.setView(center, data.zoom);
58 if (data.type && data.id) {
59 map.addObject(data, { zoom: false, style: { opacity: 0.2, fill: false } });
63 function describeLocation(e) {
66 var center = map.getCenter(),
69 $("#sidebar_content").load($(this).attr("href"), {