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 = OSM.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));
45 $("#export_overpass").attr("href",
46 "https://overpass-api.de/api/map?bbox=" +
47 $("#minlon").val() + "," + $("#minlat").val() + "," +
48 $("#maxlon").val() + "," + $("#maxlat").val());
51 function validateControls() {
52 $("#export_osm_too_large").toggle(getBounds().getSize() > OSM.MAX_REQUEST_AREA);
53 $("#export_commit").toggle(getBounds().getSize() < OSM.MAX_REQUEST_AREA);
56 function checkSubmit(e) {
57 if (getBounds().getSize() > OSM.MAX_REQUEST_AREA) e.preventDefault();
60 page.pushstate = page.popstate = function (path) {
61 $("#export_tab").addClass("current");
62 OSM.loadSidebarContent(path, page.load);
65 page.load = function () {
67 .addLayer(locationFilter)
68 .on("moveend", update);
70 $("#maxlat, #minlon, #maxlon, #minlat").change(boundsChanged);
71 $("#drag_box").click(enableFilter);
72 $(".export_form").on("submit", checkSubmit);
75 return map.getState();
78 page.unload = function () {
80 .removeLayer(locationFilter)
81 .off("moveend", update);
83 $("#export_tab").removeClass("current");