1 OSM.Export = function(map) {
4 var locationFilter = new L.LocationFilter({
7 }).on("change", update);
10 return L.latLngBounds(
11 L.latLng($("#minlat").val(), $("#minlon").val()),
12 L.latLng($("#maxlat").val(), $("#maxlon").val()));
15 function boundsChanged() {
16 var bounds = getBounds();
18 map.fitBounds(bounds);
19 locationFilter.setBounds(bounds);
25 function enableFilter(e) {
28 $("#drag_box").hide();
30 locationFilter.setBounds(map.getBounds().pad(-0.2));
31 locationFilter.enable();
35 setBounds(locationFilter.isEnabled() ? locationFilter.getBounds() : map.getBounds());
39 function setBounds(bounds) {
40 var precision = zoomPrecision(map.getZoom());
41 $("#minlon").val(bounds.getWest().toFixed(precision));
42 $("#minlat").val(bounds.getSouth().toFixed(precision));
43 $("#maxlon").val(bounds.getEast().toFixed(precision));
44 $("#maxlat").val(bounds.getNorth().toFixed(precision));
47 function validateControls() {
48 $("#export_osm_too_large").toggle(getBounds().getSize() > OSM.MAX_REQUEST_AREA);
51 page.pushstate = page.popstate = function(path) {
52 $("#export_tab").addClass("current");
53 $("#sidebar").removeClass("minimized");
55 $("#sidebar_content").load(path, page.load);
58 page.load = function() {
59 $("#sidebar").removeClass("minimized");
61 .addLayer(locationFilter)
62 .on("moveend", update);
64 $("#maxlat, #minlon, #maxlon, #minlat").change(boundsChanged);
65 $("#drag_box").click(enableFilter);
66 $("#sidebar_content .close").on("click", page.minimizeSidebar);
71 page.unload = function() {
73 .removeLayer(locationFilter)
74 .off("moveend", update);
76 $("#export_tab").removeClass("current");