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);
49 $("#export_commit").toggle(getBounds().getSize() < OSM.MAX_REQUEST_AREA);
52 page.pushstate = page.popstate = function(path) {
53 $("#export_tab").addClass("current");
54 OSM.loadSidebarContent(path, page.load);
57 page.load = function() {
59 .addLayer(locationFilter)
60 .on("moveend", update);
62 $("#maxlat, #minlon, #maxlon, #minlat").change(boundsChanged);
63 $("#drag_box").click(enableFilter);
64 $("#sidebar_content .close").on("click", page.minimizeSidebar);
69 page.unload = function() {
71 .removeLayer(locationFilter)
72 .off("moveend", update);
74 $("#export_tab").removeClass("current");