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 = 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 "http://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 page.pushstate = page.popstate = function(path) {
57 $("#export_tab").addClass("current");
58 OSM.loadSidebarContent(path, page.load);
61 page.load = function() {
63 .addLayer(locationFilter)
64 .on("moveend", update);
66 $("#maxlat, #minlon, #maxlon, #minlat").change(boundsChanged);
67 $("#drag_box").click(enableFilter);
68 $("#sidebar_content .close").on("click", page.minimizeSidebar);
71 return map.getState();
74 page.unload = function() {
76 .removeLayer(locationFilter)
77 .off("moveend", update);
79 $("#export_tab").removeClass("current");