Also expose direct map URL in the export panel

cf #699
This commit is contained in:
Yohan Boniface 2023-05-30 11:04:10 +02:00
parent 50091ec0fa
commit c52e093db8
2 changed files with 20 additions and 13 deletions

View file

@ -1231,7 +1231,7 @@ L.U.IframeExporter = L.Evented.extend({
return this.map return this.map
}, },
build: function () { buildUrl: function () {
var datalayers = [] var datalayers = []
if (this.options.viewCurrentFeature && this.map.currentFeature) { if (this.options.viewCurrentFeature && this.map.currentFeature) {
this.queryString.feature = this.map.currentFeature.getSlug() this.queryString.feature = this.map.currentFeature.getSlug()
@ -1246,17 +1246,20 @@ L.U.IframeExporter = L.Evented.extend({
} else { } else {
delete this.queryString.datalayers delete this.queryString.datalayers
} }
var currentView = this.options.currentView ? window.location.hash : '', var currentView = this.options.currentView ? window.location.hash : ''
iframeUrl = return this.baseUrl + '?' + L.Util.buildQueryString(this.queryString) + currentView
this.baseUrl + '?' + L.Util.buildQueryString(this.queryString) + currentView, },
code =
'<iframe width="' + build: function () {
this.dimensions.width + var iframeUrl = this.buildUrl()
'" height="' + var code =
this.dimensions.height + '<iframe width="' +
'" frameborder="0" allowfullscreen allow="geolocation" src="' + this.dimensions.width +
iframeUrl + '" height="' +
'"></iframe>' this.dimensions.height +
'" frameborder="0" allowfullscreen allow="geolocation" src="' +
iframeUrl +
'"></iframe>'
if (this.options.includeFullScreenLink) { if (this.options.includeFullScreenLink) {
code += '<p><a href="' + this.baseUrl + '">' + L._('See full screen') + '</a></p>' code += '<p><a href="' + this.baseUrl + '">' + L._('See full screen') + '</a></p>'
} }

View file

@ -732,7 +732,10 @@ L.U.Map.include({
var container = L.DomUtil.create('div', 'umap-share'), var container = L.DomUtil.create('div', 'umap-share'),
embedTitle = L.DomUtil.add('h4', '', container, L._('Embed the map')), embedTitle = L.DomUtil.add('h4', '', container, L._('Embed the map')),
iframe = L.DomUtil.create('textarea', 'umap-share-iframe', container), iframe = L.DomUtil.create('textarea', 'umap-share-iframe', container),
urlTitle = L.DomUtil.add('h4', '', container, L._('Direct link')),
exportUrl = L.DomUtil.create('input', 'umap-share-url', container),
option option
exportUrl.type = 'text'
var UIFields = [ var UIFields = [
['dimensions.width', { handler: 'Input', label: L._('width') }], ['dimensions.width', { handler: 'Input', label: L._('width') }],
['dimensions.height', { handler: 'Input', label: L._('height') }], ['dimensions.height', { handler: 'Input', label: L._('height') }],
@ -766,6 +769,7 @@ L.U.Map.include({
var iframeExporter = new L.U.IframeExporter(this) var iframeExporter = new L.U.IframeExporter(this)
var buildIframeCode = () => { var buildIframeCode = () => {
iframe.innerHTML = iframeExporter.build() iframe.innerHTML = iframeExporter.build()
exportUrl.value = window.location.protocol + iframeExporter.buildUrl()
} }
buildIframeCode() buildIframeCode()
var builder = new L.U.FormBuilder(iframeExporter, UIFields, { var builder = new L.U.FormBuilder(iframeExporter, UIFields, {
@ -773,7 +777,7 @@ L.U.Map.include({
}) })
var iframeOptions = L.DomUtil.createFieldset( var iframeOptions = L.DomUtil.createFieldset(
container, container,
L._('Iframe export options') L._('Export options')
) )
iframeOptions.appendChild(builder.build()) iframeOptions.appendChild(builder.build())
if (this.options.shortUrl) { if (this.options.shortUrl) {