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();
17 map.fitBounds(bounds);
18 locationFilter.setBounds(bounds);
19 locationFilter.enable();
23 function enableFilter(e) {
26 $("#drag_box").hide();
28 locationFilter.setBounds(map.getBounds().pad(-0.2));
29 locationFilter.enable();
34 setBounds(locationFilter.isEnabled() ? locationFilter.getBounds() : map.getBounds());
38 function setBounds(bounds) {
39 var precision = zoomPrecision(map.getZoom());
40 $("#minlon").val(bounds.getWest().toFixed(precision));
41 $("#minlat").val(bounds.getSouth().toFixed(precision));
42 $("#maxlon").val(bounds.getEast().toFixed(precision));
43 $("#maxlat").val(bounds.getNorth().toFixed(precision));
46 function validateControls() {
47 $("#export_osm_too_large").toggle(getBounds().getSize() > OSM.MAX_REQUEST_AREA);
48 $("#export_commit").toggle(getBounds().getSize() < OSM.MAX_REQUEST_AREA);
51 page.pushstate = page.popstate = function(path) {
52 $("#export_tab").addClass("current");
53 OSM.loadSidebarContent(path, page.load);
56 page.load = function() {
58 .addLayer(locationFilter)
59 .on("moveend", update);
61 $("#maxlat, #minlon, #maxlon, #minlat").change(boundsChanged);
62 $("#drag_box").click(enableFilter);
63 $("#sidebar_content .close").on("click", page.minimizeSidebar);
66 return map.getState();
69 page.unload = function() {
71 .removeLayer(locationFilter)
72 .off("moveend", update);
74 $("#export_tab").removeClass("current");