1 function initializeExport(map) {
2 if (window.location.pathname == "/export") {
6 function startExport() {
7 var locationFilter = new L.LocationFilter({
14 locationFilter.on("change", update);
16 map.on("moveend", update);
18 $("#maxlat,#minlon,#maxlon,#minlat").change(boundsChanged);
20 $("#drag_box").click(enableFilter);
22 setBounds(map.getBounds());
24 $("#sidebar").one("closed", function () {
25 map.removeLayer(locationFilter);
26 map.off("moveend", update);
27 locationFilter.off("change", update);
30 function getBounds() {
31 return L.latLngBounds(L.latLng($("#minlat").val(), $("#minlon").val()),
32 L.latLng($("#maxlat").val(), $("#maxlon").val()));
35 function boundsChanged() {
36 var bounds = getBounds();
38 map.fitBounds(bounds);
39 locationFilter.setBounds(bounds);
45 function enableFilter() {
46 if (!locationFilter.getBounds().isValid()) {
47 locationFilter.setBounds(map.getBounds().pad(-0.2));
50 $("#drag_box").hide();
51 locationFilter.enable();
55 setBounds(locationFilter.isEnabled() ? locationFilter.getBounds() : map.getBounds());
59 function setBounds(bounds) {
60 var precision = zoomPrecision(map.getZoom());
61 $("#minlon").val(bounds.getWest().toFixed(precision));
62 $("#minlat").val(bounds.getSouth().toFixed(precision));
63 $("#maxlon").val(bounds.getEast().toFixed(precision));
64 $("#maxlat").val(bounds.getNorth().toFixed(precision));
67 function validateControls() {
68 $("#export_osm_too_large").toggle(getBounds().getSize() > OSM.MAX_REQUEST_AREA);