mirror of
https://github.com/umap-project/umap.git
synced 2025-04-28 19:42:36 +02:00
feat: add new "Back to home" icon
Co-authored-by: David Larlet <david@larlet.fr>
This commit is contained in:
parent
4ccd1e6799
commit
beae551367
5 changed files with 42 additions and 4 deletions
7
umap/static/umap/img/home.svg
Normal file
7
umap/static/umap/img/home.svg
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg width="38" height="38" viewBox="0 0 38 38" fill="none" version="1.1" id="svg3" sodipodi:docname="home.svg" inkscape:version="1.4 (e7c3feb100, 2024-10-09)" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
|
||||||
|
<defs id="defs3" />
|
||||||
|
<sodipodi:namedview id="namedview3" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:showpageshadow="2" inkscape:pageopacity="0.0" inkscape:pagecheckerboard="0" inkscape:deskcolor="#d1d1d1" inkscape:zoom="18.394737" inkscape:cx="19" inkscape:cy="19.027182" inkscape:window-width="1920" inkscape:window-height="1011" inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="1" inkscape:current-layer="svg3" />
|
||||||
|
<path d="M14.2749 9C12.0205 10.0243 10.1979 11.7511 9.10659 13.8966C8.01529 16.042 7.72026 18.4785 8.27002 20.8054C8.81977 23.1324 10.1816 25.2114 12.1316 26.7006C14.0816 28.1898 16.5038 29.0007 19 29C10.4948 21.4138 8.53607 12.0542 14.2749 9ZM19 29C21.4962 29.0007 23.9184 28.1898 25.8684 26.7006C27.8184 25.2114 29.1802 23.1324 29.73 20.8054C30.2797 18.4785 29.9847 16.042 28.8934 13.8966C27.8021 11.7511 25.9795 10.0243 23.7251 9C29.4639 12.0542 27.5052 21.4138 19 29Z" fill="#263B58" id="path2" />
|
||||||
|
<path d="M23.072 13.532C23.072 14.0431 22.9666 14.5491 22.762 15.0213C22.5574 15.4934 22.2574 15.9224 21.8793 16.2838C21.5011 16.6452 21.0522 16.9318 20.5582 17.1274C20.0641 17.323 19.5346 17.4236 18.9998 17.4236C18.465 17.4236 17.9355 17.323 17.4415 17.1274C16.9474 16.9318 16.4985 16.6452 16.1203 16.2838C15.7422 15.9224 15.4423 15.4934 15.2376 15.0213C15.033 14.5491 14.9276 14.0431 14.9276 13.532C14.9276 12.4999 15.3567 11.51 16.1203 10.7802C16.884 10.0504 17.9198 9.64039 18.9998 9.64039C20.0798 9.64039 21.1156 10.0504 21.8793 10.7802C22.6429 11.51 23.072 12.4999 23.072 13.532Z" fill="#263B58" id="path3" />
|
||||||
|
</svg>
|
After Width: | Height: | Size: 2 KiB |
|
@ -91,6 +91,10 @@ const ControlsMixin = {
|
||||||
}
|
}
|
||||||
if (this.options.noControl) return
|
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)
|
this._controls.attribution = new U.AttributionControl().addTo(this)
|
||||||
if (this.options.miniMap) {
|
if (this.options.miniMap) {
|
||||||
this.whenReady(function () {
|
this.whenReady(function () {
|
||||||
|
|
|
@ -101,10 +101,10 @@ export default class Umap extends ServerStored {
|
||||||
this.urls = new URLs(this.properties.urls)
|
this.urls = new URLs(this.properties.urls)
|
||||||
this.slideshow = new Slideshow(this, this._leafletMap)
|
this.slideshow = new Slideshow(this, this._leafletMap)
|
||||||
|
|
||||||
this._leafletMap.setup()
|
|
||||||
|
|
||||||
if (geojson.properties.schema) this.overrideSchema(geojson.properties.schema)
|
if (geojson.properties.schema) this.overrideSchema(geojson.properties.schema)
|
||||||
|
|
||||||
|
this._leafletMap.setup()
|
||||||
|
|
||||||
this.panel = new Panel(this, this._leafletMap)
|
this.panel = new Panel(this, this._leafletMap)
|
||||||
this.dialog = new Dialog({ className: 'dark' })
|
this.dialog = new Dialog({ className: 'dark' })
|
||||||
this.topBar = new TopBar(this, this._leafletMap._controlContainer)
|
this.topBar = new TopBar(this, this._leafletMap._controlContainer)
|
||||||
|
@ -1757,4 +1757,8 @@ export default class Umap extends ServerStored {
|
||||||
this.isDirty = true
|
this.isDirty = true
|
||||||
this._defaultExtent = false
|
this._defaultExtent = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getStaticPathFor(name) {
|
||||||
|
return SCHEMA.iconUrl.default.replace('marker.svg', name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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(
|
||||||
|
`<a href="/" class="home-button" title="${L._('Back to home')}"><img src="${path}" alt="${L._('Home logo')}" width="38px" height="38px" /></a>`
|
||||||
|
)
|
||||||
|
return container
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
U.EditControl = L.Control.extend({
|
U.EditControl = L.Control.extend({
|
||||||
options: {
|
options: {
|
||||||
position: 'topright',
|
position: 'topright',
|
||||||
|
@ -468,7 +482,7 @@ U.Search = L.PhotonSearch.extend({
|
||||||
})
|
})
|
||||||
el.appendChild(tools)
|
el.appendChild(tools)
|
||||||
this._formatResult(feature, el)
|
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({
|
const icon = L.icon({
|
||||||
iconUrl: path,
|
iconUrl: path,
|
||||||
iconSize: [24, 24],
|
iconSize: [24, 24],
|
||||||
|
|
|
@ -247,7 +247,16 @@ html[dir="rtl"] .leaflet-tooltip-pane > * {
|
||||||
.leaflet-iconLayers:hover .leaflet-iconLayers-layerCell-plus {
|
.leaflet-iconLayers:hover .leaflet-iconLayers-layerCell-plus {
|
||||||
display: block;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue