makeShortCode(map);
}
+function getUrl(map) {
+ var center = map.getCenter(),
+ zoom = map.getZoom();
+ return (window.location.hostname.match(/^www\.openstreetmap\.org/i) ?
+ 'http://openstreetmap.org/?' : '/?') +
+ querystring.stringify({
+ lat: center.lat,
+ lon: center.lng,
+ zoom: zoom
+ });
+}
+
function minZoomAlert() {
alert(I18n.t("javascripts.site." + name + "_zoom_alert")); return false;
}
map.whenReady(function() {
var miniMap = L.map(div[0], {attributionControl: false, zoomControl: false})
- .addLayer(new layer.constructor);
+ .addLayer(new layer.constructor());
miniMap.dragging.disable();
miniMap.touchZoom.disable();
.text(I18n.t('javascripts.share.title'))
.appendTo($ui);
- var $input = $('<input>')
+ var $share_link = $('<div></div>')
.appendTo($ui);
+ var $title = $('<h3></h3>')
+ .text(I18n.t('javascripts.share.link'))
+ .appendTo($share_link);
+
+ var $short_url_input = $('<input />')
+ .attr('id', 'short_url')
+ .attr('type', 'checkbox')
+ .prop('checked', 'checked')
+ .appendTo($share_link)
+ .bind('change', function() {
+ options.short = $(this).prop('checked');
+ update();
+ });
+
+ var $short_url_label = $('<label></label>')
+ .text(I18n.t('javascripts.share.short_url'))
+ .attr('for', 'short_url')
+ .appendTo($share_link);
+
+ var $input = $('<input />')
+ .appendTo($share_link);
+
map.on('moveend layeradd layerremove', update);
options.sidebar.addPane($ui);
function update() {
var center = map.getCenter().wrap();
var layers = getMapLayers(map);
- $input.val(options.getUrl(map));
+ $input.val(
+ options.short ? options.getShortUrl(map) : options.getUrl(map)
+ );
}
return $container[0];