Overview
The Geolocation System provides an interactive map interface using Leaflet and OpenStreetMap for precise location selection. It includes address search, reverse geocoding, current location detection, and a smooth user experience with loading states and error handling.MapSelector Component
The core component for location selection isMapSelector.vue, which provides a full-featured map interface.
Component Props
Usage Example
Core Features
1. Interactive Map
The map uses Leaflet with CartoDB Voyager tiles for a clean, modern appearance:2. Click-to-Select Location
3. Reverse Geocoding
Convert coordinates to human-readable addresses using Nominatim:4. Address Search
Search for locations by name or address:5. Current Location Detection
Get the user’s current location using the Geolocation API:UI Features
Map Controls
- Expand/Collapse
- Fullscreen Modal
- Loading States
Toggle between 320px and 384px height:
Search Bar
Performance Optimization
Tile Loading Strategy
Debouncing
Prevent excessive API calls:Map Invalidation
Ensure proper rendering after DOM changes:Leaflet Configuration
Icon Setup
Best Practices
Rate Limiting
Rate Limiting
Always implement rate limiting for geocoding APIs. Nominatim has a 1 request/second limit. Store lastGeocodeTime and check before making requests.
User-Agent Header
User-Agent Header
Always include a User-Agent header when calling Nominatim to identify your application. This is required by their usage policy.
Fallback Values
Fallback Values
Provide fallback coordinate values when geocoding fails. Use the raw coordinates as the address string.
Map Cleanup
Map Cleanup
Always remove map instances in onUnmounted to prevent memory leaks:
Manta Coordinates
Default coordinates for Manta, Ecuador:Styling
Related Resources
Reports System
Using MapSelector for report location
Leaflet Documentation
Official Leaflet API reference
Nominatim API
Geocoding service documentation
OpenStreetMap
Map data provider
