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 $("#sidebar").removeClass("minimized");
56 $("#sidebar_content").load(path, page.load);
59 page.load = function() {
60 $("#sidebar").removeClass("minimized");
62 .addLayer(locationFilter)
63 .on("moveend", update);
65 $("#maxlat, #minlon, #maxlon, #minlat").change(boundsChanged);
66 $("#drag_box").click(enableFilter);
67 $("#sidebar_content .close").on("click", page.minimizeSidebar);
72 page.unload = function() {
74 .removeLayer(locationFilter)
75 .off("moveend", update);
77 $("#export_tab").removeClass("current");