1 OSM.Search = function(map) {
3 .on("focus", function() {
4 $("#describe_location").fadeOut(100);
6 .on("blur", function() {
7 $("#describe_location").fadeIn(100);
11 .on("click", ".search_more a", clickSearchMore)
12 .on("click", ".search_results_entry a.set_position", clickSearchResult);
14 function clickSearchMore(e) {
18 var div = $(this).parents(".search_more");
20 div.find(".search_results_entry").hide();
21 div.find(".search_searching").show();
23 $.get($(this).attr("href"), function(data) {
24 div.replaceWith(data);
28 function clickSearchResult(e) {
32 var data = $(this).data(),
33 center = L.latLng(data.lat, data.lon);
35 if (data.minLon && data.minLat && data.maxLon && data.maxLat) {
36 map.fitBounds([[data.minLat, data.minLon],
37 [data.maxLat, data.maxLon]]);
39 map.setView(center, data.zoom);
46 if (data.type && data.id) {
47 map.addObject(data, { zoom: false, style: { opacity: 0.2, fill: false } });
51 var marker = L.marker([0, 0], {icon: getUserIcon()});
55 page.pushstate = page.popstate = function(path) {
56 var params = querystring.parse(path.substring(path.indexOf('?') + 1));
57 $("#query").val(params.query);
58 $("#sidebar").removeClass("minimized");
60 $("#sidebar_content").load(path, page.load);
63 page.load = function() {
64 $(".search_results_entry").each(function() {
67 url: entry.data("href"),
71 minlon: map.getBounds().getWest(),
72 minlat: map.getBounds().getSouth(),
73 maxlon: map.getBounds().getEast(),
74 maxlat: map.getBounds().getNorth()
76 success: function(html) {
83 page.unload = function() {
84 map.removeLayer(marker);