hypejunction / google_maps_autocomplete
Replaces location input with Google Maps Autocomplete
Installs: 48
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Language:JavaScript
Type:elgg-plugin
Requires
- php: >=5.5
- composer/installers: ~1.0
- hypejunction/google_client: ~2.0
This package is auto-updated.
Last update: 2024-10-29 03:48:23 UTC
README
Features
- Replaces location input with Google Maps Autocomplete
API Key
Make sure your Google API key supports:
- Google Maps JavaScript API
- Google Places API Web Service
Notes
Autocomplete options
You can pass options to google.maps.places.Autocomplete
component using data-
attributes of the input field.
echo elgg_view_input('location', [ 'name' => 'city_in_france', 'data-types' => json_encode(['(cities)']), 'data-component-restrictions' => json_encode(['country' => 'fr']), ]);
You can further filter options for each input using 'options', 'input/location'
JavaScript plugin hook.
Accessing address parts
You can access address parts, UTC offset and lat/long of the location in your action:
$location = get_input('my_input_name'); $extended = get_input('__location'); $index = array_search($location, $extended['location']); $street_address = $extended['street_address'][$index]; $postal_code = $extended['postal_code'][$index]; ...