1 function initializeExport(map) {
2 if (window.location.pathname == "/export") {
6 function startExport() {
7 var locationFilter = new L.LocationFilter({
12 locationFilter.on("change", update);
14 map.on("moveend", update);
16 $("#sidebar_title").html(I18n.t('export.start_rjs.export'));
18 $("#maxlat,#minlon,#maxlon,#minlat").change(boundsChanged);
20 $("#drag_box").click(enableFilter);
24 setBounds(map.getBounds());
26 $("#sidebar").one("closed", function () {
27 map.removeLayer(locationFilter);
28 map.off("moveend", update);
29 locationFilter.off("change", update);
32 function getBounds() {
33 return L.latLngBounds(L.latLng($("#minlat").val(), $("#minlon").val()),
34 L.latLng($("#maxlat").val(), $("#maxlon").val()));
37 function boundsChanged() {
38 var bounds = getBounds();
40 map.fitBounds(bounds);
41 locationFilter.setBounds(bounds);
47 function enableFilter() {
48 if (!locationFilter.getBounds().isValid()) {
49 locationFilter.setBounds(map.getBounds().pad(-0.2));
52 $("#drag_box").hide();
53 locationFilter.enable();
57 setBounds(locationFilter.isEnabled() ? locationFilter.getBounds() : map.getBounds());
61 function setBounds(bounds) {
62 var precision = zoomPrecision(map.getZoom());
63 $("#minlon").val(bounds.getWest().toFixed(precision));
64 $("#minlat").val(bounds.getSouth().toFixed(precision));
65 $("#maxlon").val(bounds.getEast().toFixed(precision));
66 $("#maxlat").val(bounds.getNorth().toFixed(precision));
69 function validateControls() {
70 $("#export_osm_too_large").toggle(getBounds().getSize() > OSM.MAX_REQUEST_AREA);