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

[Frontend] Implementing the component for rectangular area search #224

Closed
berkaydoner opened this issue Dec 10, 2021 · 3 comments · Fixed by #227
Closed

[Frontend] Implementing the component for rectangular area search #224

berkaydoner opened this issue Dec 10, 2021 · 3 comments · Fixed by #227

Comments

@berkaydoner
Copy link
Collaborator

We have to implement a map for search functionality where users can select a rectangular area to filter the events in the given area. Similar to the location functionality in the create event page, we can use leaflet library for this task.

@berkaydoner berkaydoner self-assigned this Dec 10, 2021
@berkaydoner berkaydoner linked a pull request Dec 11, 2021 that will close this issue
@berkaydoner
Copy link
Collaborator Author

I tried implementing this task with two draggable markers representing the bottom left and top right corners. I put event listener on the marker movements to draw the rectangle with the correct boundary. This works; however, it does not look that good because markers and rectangle corners do not overlap on the display properly, due to the icon design of the leaflet library.

Also, dragging two markers does not lead to a good user experience since when user try to choose another rectangle, they have to drag two markers all the way from the previous location. To fix this, I tried adding a center marker, which user can move to drag the corners together. However, this did not work properly because the changes in the corners are not read when the center is dragged. It resets the width and the height to the initial state when the center is dragged since it does not have access to the current position of corners, which are set using the asycn method setState.

I could not solve this async issue and I think dragging the rectangle without dragging two corners is crucial. So, I will check if I can use any libraries for drawing the rectangle.

@berkaydoner
Copy link
Collaborator Author

I decided to use the leaflet-draw and react-leaflet-draw libraries for this task since they allow drawing many shapes with simple UI. I enabled only the rectangle drawing option and integrated this to the map:
image
Users can select the rectangle from the right to start drawing.

Pull request of this task is #227

@berkaydoner
Copy link
Collaborator Author

Pull request of this issue is merged and closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant