Compare commits

...

4 commits

Author SHA1 Message Date
Yohan Boniface
1b058ce862
fixup: hide home button in edit mode (#2562)
Some checks are pending
Test & Docs / tests (postgresql, 3.10) (push) Waiting to run
Test & Docs / tests (postgresql, 3.12) (push) Waiting to run
Test & Docs / lint (push) Waiting to run
The button is already on the edit bar.

Would be nicer to have a css transition (like for the bar itself), but
at least with this change it is not duplicated.
2025-03-13 16:52:41 +01:00
Yohan Boniface
a46430c420
fix: import iconUrl as absolute when possible (#2563)
This will only cover the cases where the icon is set at the map or at
the layer level, not the one of the marker itself.

cf #2552
2025-03-13 16:52:19 +01:00
Yohan Boniface
003b25d5e0 fix: import iconUrl as absolute when possible
This will only cover the cases where the icon is set at the map or
at the layer level, not the one of the marker itself.

cf #2552
2025-03-11 16:20:58 +01:00
Yohan Boniface
ef80396784 fixup: hide home button in edit mode
The button is already on the edit bar.

Would be nicer to have a css transition, but at least with this
change it is not duplicated.
2025-03-11 15:32:01 +01:00
4 changed files with 155 additions and 1 deletions

View file

@ -1634,7 +1634,16 @@ export default class Umap extends ServerStored {
importRaw(rawData) {
const importedData = JSON.parse(rawData)
let remoteOrigin = ''
if (importedData.uri) {
const uri = new URL(importedData.uri)
if (uri.origin !== window.location.origin) {
remoteOrigin = uri.origin
}
}
if (importedData.properties?.iconUrl?.startsWith('/')) {
importedData.properties.iconUrl = remoteOrigin + importedData.properties.iconUrl
}
this.setProperties(importedData.properties)
if (importedData.geometry) {
@ -1646,6 +1655,9 @@ export default class Umap extends ServerStored {
delete geojson._storage
}
delete geojson._umap_options?.id // Never trust an id at this stage
if (geojson._umap_options?.iconUrl?.startsWith('/')) {
geojson._umap_options.iconUrl = remoteOrigin + geojson._umap_options.iconUrl
}
const dataLayer = this.createDirtyDataLayer(geojson._umap_options)
dataLayer.fromUmapGeoJSON(geojson)
}

View file

@ -257,6 +257,9 @@ html[dir="rtl"] .leaflet-tooltip-pane > * {
.home-button:hover {
background-color: var(--color-lighterGray);
}
.umap-edit-enabled .home-button {
display: none;
}

View file

@ -0,0 +1,122 @@
{
"type": "umap",
"uri": "https://umap.incubateur.anct.gouv.fr/fr/map/aires-de-covoiturage-du-departement-de-la-nievre_42",
"properties": {
"easing": false,
"embedControl": true,
"fullscreenControl": true,
"searchControl": true,
"datalayersControl": true,
"zoomControl": true,
"permanentCreditBackground": true,
"sortKey": "com_lieu",
"slideshow": {},
"captionMenus": true,
"captionBar": false,
"limitBounds": {},
"overlay": {},
"tilelayer": {
"tms": false,
"name": "OpenStreetMap",
"maxZoom": 19,
"minZoom": 0,
"attribution": "map data © [[http://osm.org/copyright|OpenStreetMap contributors]] under ODbL",
"url_template": "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
},
"licence": "",
"description": "",
"name": "Aires de covoiturage du département de la Nièvre",
"defaultView": "data",
"onLoadPanel": "none",
"displayPopupFooter": false,
"miniMap": false,
"moreControl": true,
"scaleControl": true,
"scrollWheelZoom": true,
"zoom": 9
},
"geometry": {
"type": "Point",
"coordinates": [
3.4552001953125004,
47.12527904224337
]
},
"layers": [
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"id_lieu": "58004-C-001",
"id_local": "",
"nom_lieu": "Maison du Bazois",
"ad_lieu": "Bois de Seigne",
"com_lieu": "ALLUY",
"insee": "58004",
"type": "Parking",
"date_maj": "29/08/2019",
"ouvert": "true",
"source": "225800010",
"nbre_pl": "4",
"nbre_pmr": "",
"duree": "",
"horaires": "",
"proprio": "",
"lumiere": "",
"comm": ""
},
"geometry": {
"type": "Point",
"coordinates": [
3.634832,
47.043123
]
}
},
{
"type": "Feature",
"properties": {
"id_lieu": "58012-C-001",
"id_local": "",
"nom_lieu": "Mairie",
"ad_lieu": "28 route de Saint-Amand",
"com_lieu": "ARQUIAN",
"insee": "58012",
"type": "Auto-stop",
"date_maj": "19/05/2021",
"ouvert": "true",
"source": "810157982",
"nbre_pl": "",
"nbre_pmr": "",
"duree": "",
"horaires": "",
"proprio": "",
"lumiere": "true",
"comm": ""
},
"geometry": {
"type": "Point",
"coordinates": [
2.99163,
47.5407
]
}
}
],
"_umap_options": {
"displayOnLoad": true,
"browsable": false,
"editMode": "disabled",
"remoteData": {},
"popupContentTemplate": "# {nom_lieu}\nAdresse : {ad_lieu} {com_lieu}\nType : {type}\nNombre de places : {nbre_pl}\n",
"color": "SpringGreen",
"iconUrl": "/uploads/pictogram/car-24.png",
"labelKey": "com_lieu",
"id": 73,
"name": "Liste des aires de covoiturage"
}
}
]
}

View file

@ -870,3 +870,20 @@ def test_import_from_multiple_files(live_server, page, tilelayer):
page.get_by_role("button", name="Import data", exact=True).click()
# Two in one file, one in the other
expect(markers).to_have_count(3)
def test_umap_import_with_iconurl(live_server, tilelayer, page):
page.goto(f"{live_server.url}/map/new/")
page.get_by_title("Import data").click()
file_input = page.locator("input[type='file']")
with page.expect_file_chooser() as fc_info:
file_input.click()
file_chooser = fc_info.value
path = Path(__file__).parent.parent / "fixtures/test_upload_data_with_iconurl.umap"
file_chooser.set_files(path)
page.get_by_role("button", name="Import data", exact=True).click()
expect(
page.locator(
'img[src="https://umap.incubateur.anct.gouv.fr/uploads/pictogram/car-24.png"]'
)
).to_have_count(2)