.text(I18n.t('javascripts.share.link'))
.appendTo($linkSection);
+ var $form = $('<form>')
+ .attr('class', 'standard-form')
+ .appendTo($linkSection);
+
+ $('<div>')
+ .attr('class', 'form-row')
+ .appendTo($form)
+ .append(
+ $('<label>')
+ .attr('for', 'link_marker')
+ .append(
+ $('<input>')
+ .attr('id', 'link_marker')
+ .attr('type', 'checkbox')
+ .bind('change', toggleMarker))
+ .append(I18n.t('javascripts.share.include_marker')));
+
var $shortLink, $longLink;
$('<ul>')
.text(I18n.t('javascripts.share.embed'))
.appendTo($embedSection);
- var $form = $('<form>')
+ $form = $('<form>')
.attr('class', 'standard-form')
- .attr('action', '/export/finish')
- .attr('method', 'post')
.appendTo($embedSection);
$('<div>')
.attr('id', 'embed_marker')
.attr('type', 'checkbox')
.bind('change', toggleMarker))
- .append(I18n.t('javascripts.share.include_marker')))
+ .append(I18n.t('javascripts.share.include_marker')));
$('<div>')
.attr('class', 'form-row')
.addTo(map);
map.on('moveend layeradd layerremove', update);
+ marker.on('dragend', update);
options.sidebar.addPane($ui);
+ $ui
+ .on('hide', hidden);
+
+ function hidden() {
+ map.removeLayer(marker);
+ locationFilter.disable();
+ update();
+ }
+
function toggle(e) {
e.stopPropagation();
e.preventDefault();
function toggleMarker() {
if ($(this).is(':checked')) {
+ marker.setLatLng(map.getCenter());
map.addLayer(marker);
} else {
map.removeLayer(marker);
}
function update() {
+ var bounds = map.getBounds();
+
+ $('#link_marker, #embed_marker')
+ .prop('checked', map.hasLayer(marker));
+
+ $('#image_filter')
+ .prop('checked', locationFilter.isEnabled());
+
// Link
- $shortLink.attr('href', map.getShortUrl());
- $longLink.attr('href', map.getUrl());
+ $shortLink.attr('href', map.getShortUrl(marker));
+ $longLink.attr('href', map.getUrl(marker));
// Embed
- var bounds = map.getBounds(),
- center = bounds.getCenter(),
- params = {
- bbox: bounds.toBBoxString(),
- layer: map.getMapBaseLayerId()
- },
- linkParams = {
- lat: center.lat,
- lon: center.lng,
- zoom: map.getBoundsZoom(bounds),
- layers: map.getLayersCode()
- };
+ var params = {
+ bbox: bounds.toBBoxString(),
+ layer: map.getMapBaseLayerId()
+ };
if (map.hasLayer(marker)) {
- var m = marker.getLatLng();
- params.marker = m.lat + ',' + m.lng;
- linkParams.mlat = m.lat;
- linkParams.mlon = m.lng;
+ params.marker = marker.getLatLng().lat + ',' + marker.getLatLng().lng;
}
$('#embed_html').val(
'<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="' +
'http://' + OSM.SERVER_URL + '/export/embed.html?' + $.param(params) +
'" style="border: 1px solid black"></iframe><br/>' +
- '<small><a href="' +
- 'http://' + OSM.SERVER_URL + '/?' + $.param(linkParams) +
- '">' + I18n.t('export.start_rjs.view_larger_map') + '</a></small>');
+ '<small><a href="' + map.getUrl(marker) + '</a></small>');
// Image