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 OSM.loadSidebarContent(path, page.load);
64 page.load = function () {
66 .addLayer(locationFilter)
67 .on("moveend", update);
69 $("#maxlat, #minlon, #maxlon, #minlat").change(boundsChanged);
70 $("#drag_box").click(enableFilter);
71 $(".export_form").on("submit", checkSubmit);
74 return map.getState();
77 page.unload = function () {
79 .removeLayer(locationFilter)
80 .off("moveend", update);