PaulLeCam / react-leaflet

React components for Leaflet maps
https://react-leaflet.js.org
Other
5.14k stars 885 forks source link

GeoJson Layers rendering old data #758

Closed Bhavi-2 closed 4 years ago

Bhavi-2 commented 4 years ago

Bug report

Before opening an issue, make sure to read the contributing guide and understand this is a bug tracker, not a support platform.

Please make sure to check the following boxes before submitting an issue.\ Issues opened without using this template will be closed unless they have a good reason not to follow this template.

Expected behavior

When Multiple GeoJSON layers are present and particular geojson data is removed, it shouldn't render the data of that geojson object.

Actual behavior

From multiple GeoJson layers, when one geojson is dynamically removed it still renders it's data and instead removes the last layer added (Stack behaviour)

Please describe.

I've used the GeoJson component to dynamically render a set of datasets that are chosen by the user, my custom component is successfully passing this data to the leaflet map's geojson component. However, when I use the code as below:

{props.file && props.file.map((file, index) => ( <> < GeoJSON key={index} data={file} pointToLayer={pointToLayer.bind(this)} style={polystyle(index)} /> </> ))}

It renders the data correctly when adding new datasets, but when the user removes a dataset, the geojson renders all the datasets except the last one that was added. For instance, user selects : Dataset1 , Dataset2 and then Dataset3 (in order), and then removes Dataset2 from the selection, GeoJson renders Dataset1 and Dataset2 , instead of Dataset1 and Dataset3.

When I don't use the file.map, and pass all the datasets as one array of geojson objects, this issue doesn't seem to happen. But I need this mapping since I need to show different colours for each dataset.

I hope I've added all the required details for this issue.

Any help in the interim will be very helpful!!

Thank you!

PaulLeCam commented 4 years ago

Hi, Please only use GitHub issues to report possible bugs in the library. You can use the react-leaflet tag in StackOverflow for questions related to using it.

Bhavi-2 commented 4 years ago

Hi Paul, This was not actually a question regarding the usage. I do think it’s an issue in the library, and hence, reported it.

Please let me know if you think otherwise.

Regards, Bhavi Mehta

Get Outlook for iOShttps://aka.ms/o0ukef


From: Paul Le Cam notifications@github.com Sent: Saturday, October 3, 2020 5:47:22 PM To: PaulLeCam/react-leaflet react-leaflet@noreply.github.com Cc: Bhavi Sanjay Mehta S3811346@student.rmit.edu.au; Author author@noreply.github.com Subject: Re: [PaulLeCam/react-leaflet] GeoJson Layers rendering old data (#758)

Hi, Please only use GitHub issues to report possible bugs in the library. You can use the react-leaflet tag in StackOverflowhttps://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2Ftagged%2Freact-leaflet&data=02%7C01%7Cs3811346%40student.rmit.edu.au%7C94d6d1a6110042ce1a5608d8677091b3%7Cd1323671cdbe4417b4d4bdb24b51316b%7C0%7C0%7C637373081100204021&sdata=dnkkHPArWsR%2FSUZLTPnTQheglh4mjWQOls3Vs3q%2FA2U%3D&reserved=0 for questions related to using it.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FPaulLeCam%2Freact-leaflet%2Fissues%2F758%23issuecomment-703063274&data=02%7C01%7Cs3811346%40student.rmit.edu.au%7C94d6d1a6110042ce1a5608d8677091b3%7Cd1323671cdbe4417b4d4bdb24b51316b%7C0%7C0%7C637373081100204021&sdata=GPj8GK7uwEliVMnQnweK3YNbTwUvTw%2B3eoHNM4DzeY4%3D&reserved=0, or unsubscribehttps://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAQQENIRGABNN44DTQ2LWWU3SI3JIVANCNFSM4RKPBK2A&data=02%7C01%7Cs3811346%40student.rmit.edu.au%7C94d6d1a6110042ce1a5608d8677091b3%7Cd1323671cdbe4417b4d4bdb24b51316b%7C0%7C0%7C637373081100204021&sdata=O86Gl5p7gaEcthLXRIhjYzWjW6L8a2Sd%2BgZk4OA8f9E%3D&reserved=0.