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_content").load(path + "?xhr=1", function(a, b, xhr) {
55 if (xhr.getResponseHeader('X-Page-Title')) {
56 document.title = xhr.getResponseHeader('X-Page-Title');
62 page.load = function() {
64 .addLayer(locationFilter)
65 .on("moveend", update);
67 $("#maxlat, #minlon, #maxlon, #minlat").change(boundsChanged);
68 $("#drag_box").click(enableFilter);
69 $("#sidebar_content .close").on("click", page.minimizeSidebar);
74 page.unload = function() {
76 .removeLayer(locationFilter)
77 .off("moveend", update);
79 $("#export_tab").removeClass("current");