Add option to include marker in permalinks
This commit is contained in:
parent
438e8be102
commit
f898058e76
1 changed files with 33 additions and 25 deletions
|
@ -44,6 +44,23 @@ L.OSM.share = function (options) {
|
||||||
.text(I18n.t('javascripts.share.link'))
|
.text(I18n.t('javascripts.share.link'))
|
||||||
.appendTo($linkSection);
|
.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;
|
var $shortLink, $longLink;
|
||||||
|
|
||||||
$('<ul>')
|
$('<ul>')
|
||||||
|
@ -65,10 +82,8 @@ L.OSM.share = function (options) {
|
||||||
.text(I18n.t('javascripts.share.embed'))
|
.text(I18n.t('javascripts.share.embed'))
|
||||||
.appendTo($embedSection);
|
.appendTo($embedSection);
|
||||||
|
|
||||||
var $form = $('<form>')
|
$form = $('<form>')
|
||||||
.attr('class', 'standard-form')
|
.attr('class', 'standard-form')
|
||||||
.attr('action', '/export/finish')
|
|
||||||
.attr('method', 'post')
|
|
||||||
.appendTo($embedSection);
|
.appendTo($embedSection);
|
||||||
|
|
||||||
$('<div>')
|
$('<div>')
|
||||||
|
@ -82,7 +97,7 @@ L.OSM.share = function (options) {
|
||||||
.attr('id', 'embed_marker')
|
.attr('id', 'embed_marker')
|
||||||
.attr('type', 'checkbox')
|
.attr('type', 'checkbox')
|
||||||
.bind('change', toggleMarker))
|
.bind('change', toggleMarker))
|
||||||
.append(I18n.t('javascripts.share.include_marker')))
|
.append(I18n.t('javascripts.share.include_marker')));
|
||||||
|
|
||||||
$('<div>')
|
$('<div>')
|
||||||
.attr('class', 'form-row')
|
.attr('class', 'form-row')
|
||||||
|
@ -185,6 +200,7 @@ L.OSM.share = function (options) {
|
||||||
.addTo(map);
|
.addTo(map);
|
||||||
|
|
||||||
map.on('moveend layeradd layerremove', update);
|
map.on('moveend layeradd layerremove', update);
|
||||||
|
marker.on('dragend', update);
|
||||||
|
|
||||||
options.sidebar.addPane($ui);
|
options.sidebar.addPane($ui);
|
||||||
|
|
||||||
|
@ -222,40 +238,32 @@ L.OSM.share = function (options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
|
var bounds = map.getBounds();
|
||||||
|
|
||||||
|
$('#link_marker, #embed_marker')
|
||||||
|
.prop('checked', map.hasLayer(marker));
|
||||||
|
|
||||||
// Link
|
// Link
|
||||||
|
|
||||||
$shortLink.attr('href', map.getShortUrl());
|
$shortLink.attr('href', map.getShortUrl(marker));
|
||||||
$longLink.attr('href', map.getUrl());
|
$longLink.attr('href', map.getUrl(marker));
|
||||||
|
|
||||||
// Embed
|
// Embed
|
||||||
|
|
||||||
var bounds = map.getBounds(),
|
var params = {
|
||||||
center = bounds.getCenter(),
|
bbox: bounds.toBBoxString(),
|
||||||
params = {
|
layer: map.getMapBaseLayerId()
|
||||||
bbox: bounds.toBBoxString(),
|
};
|
||||||
layer: map.getMapBaseLayerId()
|
|
||||||
},
|
|
||||||
linkParams = {
|
|
||||||
lat: center.lat,
|
|
||||||
lon: center.lng,
|
|
||||||
zoom: map.getBoundsZoom(bounds),
|
|
||||||
layers: map.getLayersCode()
|
|
||||||
};
|
|
||||||
|
|
||||||
if (map.hasLayer(marker)) {
|
if (map.hasLayer(marker)) {
|
||||||
var m = marker.getLatLng();
|
params.marker = marker.getLatLng().lat + ',' + marker.getLatLng().lng;
|
||||||
params.marker = m.lat + ',' + m.lng;
|
|
||||||
linkParams.mlat = m.lat;
|
|
||||||
linkParams.mlon = m.lng;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#embed_html').val(
|
$('#embed_html').val(
|
||||||
'<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="' +
|
'<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="' +
|
||||||
'http://' + OSM.SERVER_URL + '/export/embed.html?' + $.param(params) +
|
'http://' + OSM.SERVER_URL + '/export/embed.html?' + $.param(params) +
|
||||||
'" style="border: 1px solid black"></iframe><br/>' +
|
'" style="border: 1px solid black"></iframe><br/>' +
|
||||||
'<small><a href="' +
|
'<small><a href="' + map.getUrl(marker) + '</a></small>');
|
||||||
'http://' + OSM.SERVER_URL + '/?' + $.param(linkParams) +
|
|
||||||
'">' + I18n.t('export.start_rjs.view_larger_map') + '</a></small>');
|
|
||||||
|
|
||||||
// Image
|
// Image
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue