Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GeoJSON overlay #27

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open

GeoJSON overlay #27

wants to merge 44 commits into from

Conversation

micamur
Copy link

@micamur micamur commented Apr 30, 2020

We added the ability to add multiple overlays to the map: either by pasting the GeoJSON code in a textarea or by importing a file. This can be useful to add context to the paths drawn on the map from the data source. Once added, an overlay can be downloaded and deleted; this allows a good flexibility. When the user clicks on a layer on the map, there is a popup which shows all the informations in the properties of the overlay.

micamur and others added 30 commits February 28, 2020 12:06
This is a first test to add a textarea in which a user can copy-paste GeoJSOn code.
It is not finished, the style may be not great but more importantly the overlay
is not erased if the code is erased. Overlays are only added and never removed.

The next step is to add the import button functionnality.
Now when you click on the button "Import GeoJSON" it opens a file
browser in which you can only select json file.
Changed "code" to "text" to better represent the fact that it contains
the text from the textarea and not the parsed text.
The user can upload a GeoJson file and the content of the file
will be display on the map.
Now when you remove the overlay code from the text area, the previous
overlay disappears from the map and the new one appears. This means
that you can at the moment only have one overlay at a time using the
text area.
We gave the browse button the same style than the other buttons on the
panel.
When you hit the "Save" button, the current overlay is saved so that
later it will be possible to manage different overlays (edit, delete...)
If the default value is '' (empty), then the parsing will throw an
error, so we changed it to '{}'.
Now when the user hits the "Save" button, the content of the textarea is
saved as a new element of the overlay list and the textarea is cleared.
This list is displayed on the right side and for each element is
displayed: its name (for the moment its Leaflet id) and three buttons.
These three buttons are: download (to download the overlay as a file),
edit (to make the content of the overlay appear in the text area) and
delete (to delete the overlay from the list and from the map). These
buttons don't do anything for the moment.
Now the delete button deletes the overlay from the map and from the
overlay list.
Merge the two previous button into one.
After a click on the button "Import GeoJson", the user can chose a file
then the file's name is displayed and the overlay is added.
When the user clicks on the download button, a browser download popup
appears and asks if they want to download a file named "overlay.json".
An improvement would be to use a custom name for each overlay for the
downloaded file name.
If the overlay textarea is empty the corresponding object is null and
it cannot be saved in the overlay list.
When a file is added through the Import file button
the geoJson object of this file is add to the
list of overlays.
When you click on an object on the map, the properties content of the
json object is displayed in a popup.
Claire548 and others added 13 commits April 16, 2020 15:16
Created a function called addOverlayToMap that can be called whenever a 
JSON text needs to be added to the map. Also created a function 
jsonToString to get the same kind of result (indentation, etc.) whenever 
it is called.
One is jsonToString and the other is overlayToString, which makes more sense with the arguments than before.
Now if the text in argument is empty, the function will throw an error, as this should never happen.
Moved the code that didn't need to be in the try/catch after, and added a "return" in the catch in order to get out of the function there.
One is to add the overlay to the map and the other is to add the overlay to the list displayed to the user.
The edit function does not work correctly, so the button is hidden to the user until it is fixed.
There should be less confusion about which kind of object we are using and why between pure text, parsed geojson and the corrsponding Leaflet object.
When the dashboard was saved, an error occured because not all the objects could be serialized: now what is saved is the parsed geojson list. Because we want to keep the ability to download and delete an overlay, we need to have a correspondance between the parsed geojson and the Leaflet overlays, that's why we need auxiliary lists and object which are declared in the constructor and filled in setupMap.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants