- if (data.type && data.id) {
- map.addObject(data, { zoom: false, style: { opacity: 0.2, fill: false } });
- }
- }
-}
+ var page = {};
+
+ page.pushstate = page.popstate = function(path) {
+ var params = querystring.parse(path.substring(path.indexOf('?') + 1));
+ $(".search_form input[name=query]").val(params.query);
+ OSM.loadSidebarContent(path, page.load);
+ };
+
+ page.load = function() {
+ $(".search_results_entry").each(function() {
+ var entry = $(this);
+ $.ajax({
+ url: entry.data("href"),
+ method: 'GET',
+ data: {
+ zoom: map.getZoom(),
+ minlon: map.getBounds().getWest(),
+ minlat: map.getBounds().getSouth(),
+ maxlon: map.getBounds().getEast(),
+ maxlat: map.getBounds().getNorth()
+ },
+ success: function(html) {
+ entry.html(html);
+ }
+ });
+ });
+
+ return map.getState();
+ };
+
+ page.unload = function() {
+ map.removeLayer(marker);
+ map.removeObject();
+ $(".search_form input[name=query]").val("");
+ };
+
+ return page;
+};