Manual Address Entry Feature
Overview
This feature allows users to manually enter venue addresses when Google Maps autocomplete doesn’t find the desired location. It provides a toggle between automatic (Google Maps autocomplete) and manual address entry modes.Features
Toggle Functionality
- Button Text: “No encuentras la dirección, agrégalo manualmente” (default)
- Toggle Text: “Buscar con Google” (when in manual mode)
- Visual Indicator: Button changes color from secondary to primary when in manual mode
Manual Mode
When activated, the following fields become editable:- Country (
pais) - City (
ciudad) - District (
district)
Interactive Map
- Location: Displayed below the address fields
- Visibility: Only shown in manual mode
- Features:
- Draggable marker for precise location selection
- Automatic geocoding when country/city fields are filled
- Real-time coordinate updates
- Default zoom level: 15
Coordinate Management
- Always Saved: Latitude and longitude are always saved regardless of mode
- Hidden Fields:
create_latitude,create_longitude,create_json_maps - Auto-update: Coordinates update automatically when:
- Using Google Maps autocomplete
- Dragging the marker in manual mode
- Typing in country/city fields (with geocoding)
Technical Implementation
Files Modified
-
resources/views/eventos/create_steps/step_1.blade.php- Added toggle button
- Added interactive map container
- Added CSS styles
-
public/assets/theme_assets/dany/js/autocomplete.js- Added toggle functionality
- Added interactive map initialization
- Added geocoding functions
- Enhanced coordinate management
Key Functions
initializeToggleFunctionality(): Sets up the toggle button and event listenerstoggleToManualMode(): Switches to manual entry modetoggleToAutomaticMode(): Switches to autocomplete modeinitializeInteractiveMap(): Creates the interactive mapupdateMapFromManualFields(): Updates map when manual fields changegeocodeAddress(): Converts address to coordinates
Dependencies
- Google Maps JavaScript API (Places and Geocoding libraries)
- Bootstrap CSS classes for styling
Usage Flow
Automatic Mode (Default)
- User types in address field
- Google Maps autocomplete suggests locations
- User selects from suggestions
- Fields are auto-populated and coordinates saved
Manual Mode
- User clicks toggle button
- Country, city, district fields become editable
- Interactive map appears
- User can:
- Type in country/city to auto-center map
- Drag marker to precise location
- Manually enter district information
- Coordinates are automatically saved from marker position
Error Handling
- Graceful fallback if geocoding fails
- Console logging for debugging
- Maintains existing coordinate values if new geocoding fails
Browser Compatibility
- Modern browsers with Google Maps API support
- Mobile-responsive design
- Touch-friendly marker dragging
