+ $("<h4>")
+ .text(I18n.t("javascripts.share.image"))
+ .appendTo($imageSection);
+
+ $("<div>")
+ .attr("id", "export-warning")
+ .attr("class", "text-muted")
+ .text(I18n.t("javascripts.share.only_standard_layer"))
+ .appendTo($imageSection);
+
+ $form = $("<form>")
+ .attr("id", "export-image")
+ .attr("action", "/export/finish")
+ .attr("method", "post")
+ .appendTo($imageSection);
+
+ $("<div>")
+ .attr("class", "mb-3 form-check")
+ .appendTo($form)
+ .append(
+ $("<label>")
+ .attr("for", "image_filter")
+ .attr("class", "form-check-label")
+ .append(
+ $("<input>")
+ .attr("id", "image_filter")
+ .attr("type", "checkbox")
+ .attr("class", "form-check-input")
+ .bind("change", toggleFilter))
+ .append(I18n.t("javascripts.share.custom_dimensions")));
+
+ $("<div>")
+ .appendTo($form)
+ .append(
+ $("<label>")
+ .attr("for", "mapnik_format")
+ .text(I18n.t("javascripts.share.format")))
+ .append($("<select>")
+ .attr("name", "mapnik_format")
+ .attr("id", "mapnik_format")
+ .append($("<option>").val("png").text("PNG").prop("selected", true))
+ .append($("<option>").val("jpeg").text("JPEG"))
+ .append($("<option>").val("svg").text("SVG"))
+ .append($("<option>").val("pdf").text("PDF")));
+
+ $("<div>")
+ .appendTo($form)
+ .append($("<label>")
+ .attr("for", "mapnik_scale")
+ .text(I18n.t("javascripts.share.scale")))
+ .append("1 : ")
+ .append($("<input>")
+ .attr("name", "mapnik_scale")
+ .attr("id", "mapnik_scale")
+ .attr("type", "text")
+ .on("change", update));
+
+ ["minlon", "minlat", "maxlon", "maxlat"].forEach(function (name) {
+ $("<input>")
+ .attr("id", "mapnik_" + name)
+ .attr("name", name)
+ .attr("type", "hidden")
+ .appendTo($form);
+ });
+
+ $("<input>")
+ .attr("name", "format")
+ .attr("value", "mapnik")
+ .attr("type", "hidden")
+ .appendTo($form);
+
+ var csrf_param = $("meta[name=csrf-param]").attr("content"),
+ csrf_token = $("meta[name=csrf-token]").attr("content");
+
+ $("<input>")
+ .attr("name", csrf_param)
+ .attr("value", csrf_token)
+ .attr("type", "hidden")
+ .appendTo($form);
+
+ var args = {
+ width: "<span id=\"mapnik_image_width\"></span>",
+ height: "<span id=\"mapnik_image_height\"></span>"
+ };
+
+ $("<p>")
+ .attr("class", "text-muted")
+ .html(I18n.t("javascripts.share.image_dimensions", args))
+ .appendTo($form);
+
+ $("<input>")
+ .attr("type", "submit")
+ .attr("class", "btn btn-primary")
+ .attr("value", I18n.t("javascripts.share.download"))
+ .appendTo($form);
+
+ locationFilter
+ .on("change", update)
+ .addTo(map);
+
+ marker.on("dragend", movedMarker);
+ map.on("move", movedMap);
+ map.on("moveend layeradd layerremove", update);
+
+ $ui
+ .on("show", shown)
+ .on("hide", hidden);
+
+ function shown() {
+ $("#mapnik_scale").val(getScale());
+ update();
+ }
+
+ function hidden() {
+ map.removeLayer(marker);
+ map.options.scrollWheelZoom = map.options.doubleClickZoom = true;
+ locationFilter.disable();
+ update();
+ }
+
+ function toggleMarker() {
+ if ($(this).is(":checked")) {
+ marker.setLatLng(map.getCenter());
+ map.addLayer(marker);
+ map.options.scrollWheelZoom = map.options.doubleClickZoom = "center";
+ } else {
+ map.removeLayer(marker);
+ map.options.scrollWheelZoom = map.options.doubleClickZoom = true;
+ }
+ update();
+ }
+
+ function toggleFilter() {
+ if ($(this).is(":checked")) {
+ locationFilter.setBounds(map.getBounds().pad(-0.2));
+ locationFilter.enable();
+ } else {
+ locationFilter.disable();
+ }
+ update();
+ }
+
+ function movedMap() {
+ marker.setLatLng(map.getCenter());
+ update();
+ }