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() {
26 if (!locationFilter.getBounds().isValid()) {
27 locationFilter.setBounds(map.getBounds().pad(-0.2));
30 $("#drag_box").hide();
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);
51 page.pushstate = page.popstate = function(path) {
52 $("#export_tab").addClass("current");
53 $("#sidebar").removeClass("minimized");
55 $('#sidebar_content').load(path, page.load);
58 page.load = function() {
60 .addLayer(locationFilter)
61 .on("moveend", update);
63 $("#maxlat, #minlon, #maxlon, #minlat").change(boundsChanged);
64 $("#drag_box").click(enableFilter);
69 page.unload = function() {
71 .removeLayer(locationFilter)
72 .off("moveend", update);
74 $("#export_tab").removeClass("current");