Conversation
…carte maplibre et des controllers de base (fullscreen, navigation, scale)
…a classe d'initialisation
…rement impacté la classé, il est pour l'heure impossible de d'avoir les couches d'objets au niveau du controller
…ObjectsLayer, une fois la tuile changée la distance dessinée est cachée
… voir les couches d'objets qui posent problèmes
…her des données venant de source différent
…s données venant de source différent
…tion entre les overlays et selection de la première couche de base ajouté sur la carte
| _DEFAULT_MAP_STYLES = { | ||
| 'detail': {'weight': 5, 'opacity': 1, 'color': 'yellow', 'arrowColor': '#FF5E00', 'arrowSize': 8}, | ||
| 'others': {'opacity': 0.9, 'fillOpacity': 0.7, 'color': 'yellow'}, | ||
| 'detail': {'weight': 5, 'opacity': 1, 'color': 'mediumpurple', 'arrowColor': '#FF5E00', 'arrowSize': 8}, |
There was a problem hiding this comment.
Is it deliberate to change the color value?
And the opacity? (the line below)
There was a problem hiding this comment.
yes but i forgot to remove it. It was for test purposes.
| const normalizedGeometries = geometries.map(geometry => { | ||
| return geometry; | ||
| }); |
There was a problem hiding this comment.
What is the utility of this map loop?
There was a problem hiding this comment.
I needed to merge all the geometries into a single geometry in order to construct the GeometryCollection object in the FileStore class.
There was a problem hiding this comment.
I don't see any alteration in this Array.map, unless i miss something it seems useless
| class MaplibreDrawControlManager { | ||
| constructor(map, options = {}) { | ||
| this.map = map; | ||
| this.options = {...options}; |
There was a problem hiding this comment.
Why not simply this.options = options?
Immutability issues?
There was a problem hiding this comment.
Well, I had many problems with object references, so I decided to make a copy of each object instead of using references to solve the issue.
| controls: { | ||
| draw: { | ||
| polygon: { | ||
| title: 'Draw Polygon', |
There was a problem hiding this comment.
Is there a way to translate locales from geomanOptions?
There was a problem hiding this comment.
I don't know, I haven't thought much about it. I can take a look and run some tests after I finish working on the view form in Geotrek-admin.
| map.setZoom(context.mapview.zoom); | ||
| return true; | ||
| } else { | ||
| if (map !== null) { |
There was a problem hiding this comment.
Map could be null here, but not above?
There was a problem hiding this comment.
It’s been there since the first version, so I left it as long as the code worked. I can refactor it further if needed
| return true; | ||
| } else { | ||
| if (map !== null) { | ||
| map.fitBounds(this.bounds, {padding : 0, maxZoom : 16}); // Adjust the map to fit the predefined bounds. |
There was a problem hiding this comment.
padding: 0 is necessary? It's not the default value?
There was a problem hiding this comment.
It's the default value. Not necessary. I will remove it from the code.
| function getURLParameter(name) { | ||
| var paramEncoded = (RegExp('[?|&]' + name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1], | ||
| paramDecoded = decodeURIComponent(paramEncoded); | ||
| if (typeof paramDecoded == 'string') { | ||
| try { | ||
| return JSON.parse(paramDecoded); | ||
| } | ||
| catch (e) {} | ||
| } | ||
| return paramDecoded; | ||
| } |
There was a problem hiding this comment.
Maybe you can use URLSearchParams api to get search params?
There was a problem hiding this comment.
At first, I thought about it, but then everything started crashing and I didn’t know why. So I removed the URLSearchParams and reintegrated the old code that was already there and it worked perfectly, so I left it as is.
There was a problem hiding this comment.
var paramEncoded = new URLSearchParams(location.search).get(name) should be fine, to be tested
There was a problem hiding this comment.
I tried it, but it doesn't seem to work properly with the screenshot controller.
| * @private | ||
| */ | ||
| function generateUniqueId() { | ||
| return `${Math.random().toString(36).substring(2, 9)}`; |
There was a problem hiding this comment.
| return `${Math.random().toString(36).substring(2, 9)}`; | |
| return window.crypto.randomUUID() |
There was a problem hiding this comment.
I'm mostly using Chrome for web development. Since window.crypto.randomUUID() wasn't working in my browser
window.crypto.randomUUID();
VM1024:1 Uncaught TypeError: window.crypto.randomUUID is not a function
at <anonymous>:1:15
I added a fallback. I don't know if it's better or not let me know if I should leave it as is or just replace it with the older one.
function generateUniqueId() {
if (window.crypto && typeof window.crypto.randomUUID === 'function') {
return window.crypto.randomUUID();
} else {
// fallback
return generateFallbackUniqueID();
}
}
function generateFallbackUniqueID() {
return `${Math.random().toString(36).substring(2, 9)}`;
}
There was a problem hiding this comment.
oh, this method only works in secure contexts (meaning under https url) so indeed a fallback could be useful for local testing without certificates
return window.crypto.randomUUID?.() || ${Math.random().toString(36).substring(2, 9)}`;| // Unescape a string that was escaped using django.utils.html.escape. | ||
| text = text.replace(/</g, '<'); | ||
| text = text.replace(/>/g, '>'); | ||
| text = text.replace(/"/g, '"'); | ||
| text = text.replace(/'/g, "'"); | ||
| text = text.replace(/&/g, '&'); | ||
| return text; |
There was a problem hiding this comment.
To be tested but something like this is maybe safer
return Object.assign(document.createElement('u'), { innerHTML: text }).textContent;
There was a problem hiding this comment.
I haven’t modified this file, as it’s unrelated to the map functionality I’m currently working on.
1 - Initialisation de la carte
2 - Gestion des controllers (FullScream, Dessin, Reset, Fichier, Navigation, Scale)
3 - Gestion des couches par groupe
4 - Gestion des couches d'objets et surbrillance