diff --git a/umap/static/umap/img/home.svg b/umap/static/umap/img/home.svg
new file mode 100644
index 00000000..43f0bbae
--- /dev/null
+++ b/umap/static/umap/img/home.svg
@@ -0,0 +1,7 @@
+
+
diff --git a/umap/static/umap/js/modules/rendering/map.js b/umap/static/umap/js/modules/rendering/map.js
index dfb52ada..1a7c01a4 100644
--- a/umap/static/umap/js/modules/rendering/map.js
+++ b/umap/static/umap/js/modules/rendering/map.js
@@ -91,6 +91,10 @@ const ControlsMixin = {
}
if (this.options.noControl) return
+ // Do not display in an iframe.
+ if (window.self === window.top) {
+ this._controls.home = new U.HomeControl().addTo(this)
+ }
this._controls.attribution = new U.AttributionControl().addTo(this)
if (this.options.miniMap) {
this.whenReady(function () {
diff --git a/umap/static/umap/js/modules/umap.js b/umap/static/umap/js/modules/umap.js
index 4b7f9792..1648f1fe 100644
--- a/umap/static/umap/js/modules/umap.js
+++ b/umap/static/umap/js/modules/umap.js
@@ -101,10 +101,10 @@ export default class Umap extends ServerStored {
this.urls = new URLs(this.properties.urls)
this.slideshow = new Slideshow(this, this._leafletMap)
- this._leafletMap.setup()
-
if (geojson.properties.schema) this.overrideSchema(geojson.properties.schema)
+ this._leafletMap.setup()
+
this.panel = new Panel(this, this._leafletMap)
this.dialog = new Dialog({ className: 'dark' })
this.topBar = new TopBar(this, this._leafletMap._controlContainer)
@@ -1757,4 +1757,8 @@ export default class Umap extends ServerStored {
this.isDirty = true
this._defaultExtent = false
}
+
+ getStaticPathFor(name) {
+ return SCHEMA.iconUrl.default.replace('marker.svg', name)
+ }
}
diff --git a/umap/static/umap/js/umap.controls.js b/umap/static/umap/js/umap.controls.js
index 61c130db..3819715a 100644
--- a/umap/static/umap/js/umap.controls.js
+++ b/umap/static/umap/js/umap.controls.js
@@ -1,3 +1,17 @@
+U.HomeControl = L.Control.extend({
+ options: {
+ position: 'topleft',
+ },
+
+ onAdd: (map) => {
+ const path = map._umap.getStaticPathFor('home.svg')
+ const container = U.Utils.loadTemplate(
+ `
`
+ )
+ return container
+ },
+})
+
U.EditControl = L.Control.extend({
options: {
position: 'topright',
@@ -462,7 +476,7 @@ U.Search = L.PhotonSearch.extend({
})
el.appendChild(tools)
this._formatResult(feature, el)
- const path = U.SCHEMA.iconUrl.default.replace('marker.svg', 'target.svg')
+ const path = this.map._umap.getStaticPathFor('target.svg')
const icon = L.icon({
iconUrl: path,
iconSize: [24, 24],
diff --git a/umap/static/umap/map.css b/umap/static/umap/map.css
index 1ca2c291..a54b1a14 100644
--- a/umap/static/umap/map.css
+++ b/umap/static/umap/map.css
@@ -247,7 +247,16 @@ html[dir="rtl"] .leaflet-tooltip-pane > * {
.leaflet-iconLayers:hover .leaflet-iconLayers-layerCell-plus {
display: block;
}
-
+.home-button {
+ cursor: pointer;
+ line-height: 0;
+ border: 1px solid var(--color-darkBlue);
+ border-radius: 50%;
+ background-color: var(--background-color);
+}
+.home-button:hover {
+ background-color: var(--color-lighterGray);
+}