Skip to content

feat: Add search functionalities to resolve names to geolocation#14

Open
idrismunir15 wants to merge 1 commit into
cartesiancs:mainfrom
idrismunir15:feature/search-location
Open

feat: Add search functionalities to resolve names to geolocation#14
idrismunir15 wants to merge 1 commit into
cartesiancs:mainfrom
idrismunir15:feature/search-location

Conversation

@idrismunir15

Copy link
Copy Markdown

What does this PR do?

This PR introduces a new search feature to the map interface, allowing users to look up locations by name and automatically pan the map to the corresponding geolocation.

Key Changes

  • Search UI: Added a sleek, absolute-positioned search form overlay inside the MapComponent.
  • Geolocation Resolution: Integrated the free OpenStreetMap Nominatim API to convert search queries (like cities or street addresses) into latitude and longitude coordinates.
  • Auto-Panning: Created a custom MapUpdater component utilizing react-leaflet's useMap() hook to seamlessly fly the map viewport (flyTo) to the resolved coordinates when a location is successfully found.
  • Loading State: Implemented a loading spinner inside the search button while the API request is resolving.

How to test

  1. Run the development server (npm run dev).
  2. Open the application.
  3. Locate the new search bar in the top-left area of the map.
  4. Type in a location (e.g., "New York" or "University of Ilorin") and hit Enter or click the Search icon.
  5. Verify that the map automatically flies to the searched location.

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.

1 participant