var button = $('<a>')
.attr('class', 'control-button')
.attr('href', '#')
- .attr('title', 'Share')
+ .attr('title', I18n.t('javascripts.share.title'))
.html('<span class="icon share"></span>')
.on('click', toggle)
.appendTo($container);
.attr('class', 'sidebar_heading')
.appendTo($ui)
.append(
- $('<a>')
+ $('<span>')
.text(I18n.t('javascripts.close'))
- .attr('class', 'sidebar_close')
- .attr('href', '#')
+ .attr('class', 'icon close')
.bind('click', toggle))
.append(
$('<h4>')
.text(I18n.t('javascripts.share.paste_html'))
.appendTo($linkSection));
+ // Geo URI
+
+ var $geoUriSection = $('<div>')
+ .attr('class', 'section share-geo-uri')
+ .appendTo($ui);
+
+ $('<h4>')
+ .text(I18n.t('javascripts.share.geo_uri'))
+ .appendTo($geoUriSection);
+
+ $('<div>')
+ .appendTo($geoUriSection)
+ .append($('<a>')
+ .attr('id', 'geo_uri'));
+
// Image
var $imageSection = $('<div>')
.text(I18n.t('javascripts.share.image'))
.appendTo($imageSection);
+ $('<div>')
+ .attr('id', 'export-warning')
+ .attr('class', 'deemphasize')
+ .text(I18n.t('javascripts.share.only_standard_layer'))
+ .appendTo($imageSection);
+
$form = $('<form>')
+ .attr('id', 'export-image')
.attr('class', 'standard-form')
.attr('action', '/export/finish')
.attr('method', 'post')
.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);
+
$('<p>')
.attr('class', 'deemphasize')
.html(I18n.t('javascripts.share.image_size') + ' <span id="mapnik_image_width"></span> x <span id="mapnik_image_height"></span>')
.on('change', update)
.addTo(map);
+ marker.on('dragend', movedMarker);
+ map.on('move', movedMap);
map.on('moveend layeradd layerremove', update);
- marker.on('dragend', update);
options.sidebar.addPane($ui);
function hidden() {
map.removeLayer(marker);
+ map.options.scrollWheelZoom = map.options.doubleClickZoom = true;
locationFilter.disable();
update();
}
update();
options.sidebar.togglePane($ui, button);
+ $('.leaflet-control .control-button').tooltip('hide');
}
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')) {
- if (!locationFilter.getBounds().isValid()) {
- locationFilter.setBounds(map.getBounds().pad(-0.2));
- }
-
+ locationFilter.setBounds(map.getBounds().pad(-0.2));
locationFilter.enable();
} else {
locationFilter.disable();
update();
}
- function update() {
+ function movedMap() {
+ marker.setLatLng(map.getCenter());
+ update();
+ }
+
+ function movedMarker() {
if (map.hasLayer(marker)) {
+ map.off('move', movedMap);
+ map.on('moveend', updateOnce);
map.panTo(marker.getLatLng());
}
+ }
+
+ function updateOnce() {
+ map.off('moveend', updateOnce);
+ map.on('move', movedMap);
+ update();
+ }
+
+ function escapeHTML(string) {
+ var htmlEscapes = {
+ '&': '&',
+ '<': '<',
+ '>': '>',
+ '"': '"',
+ "'": '''
+ };
+ return string === null ? '' : (string + '').replace(/[&<>"']/g, function(match) {
+ return htmlEscapes[match];
+ });
+ }
+ function update() {
var bounds = map.getBounds();
$('#link_marker')
};
if (map.hasLayer(marker)) {
- params.marker = marker.getLatLng().lat + ',' + marker.getLatLng().lng;
+ var latLng = marker.getLatLng().wrap();
+ params.marker = latLng.lat + ',' + latLng.lng;
}
$('#embed_html').val(
'<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="' +
- escapeHTML('http://' + OSM.SERVER_URL + '/export/embed.html?' + $.param(params)) +
+ escapeHTML(OSM.SERVER_PROTOCOL + '://' + OSM.SERVER_URL + '/export/embed.html?' + $.param(params)) +
'" style="border: 1px solid black"></iframe><br/>' +
- '<small><a href="' + escapeHTML(map.getUrl(marker)) + '</a></small>');
+ '<small><a href="' + escapeHTML(map.getUrl(marker)) + '">' +
+ escapeHTML(I18n.t('javascripts.share.view_larger_map')) + '</a></small>');
+
+ // Geo URI
+
+ $('#geo_uri')
+ .attr('href', map.getGeoUri(marker))
+ .html(map.getGeoUri(marker));
// Image
$("#mapnik_image_width").text(Math.round(size.x / scale / 0.00028));
$("#mapnik_image_height").text(Math.round(size.y / scale / 0.00028));
+
+ if (map.getMapBaseLayerId() === 'mapnik') {
+ $('#export-image').show();
+ $('#export-warning').hide();
+ } else {
+ $('#export-image').hide();
+ $('#export-warning').show();
+ }
}
function select() {