CRUD
CRUD copied to clipboard
[4.1][Feature][Needs testing] Google Maps field type (a.ka. lat_lng)
Summary
Create an input form for location (latitude, longitude)
- Maps
- Search Autocomplete
- Geolocation
- Map click Event Listener
- Require Google API key
Preview
Usage
$this->crud->addField([
'name' => 'latlng',
'label' => "Location",
'type' => 'latlng',
'google_api_key' => env('GOOGLE_API_KEY', null),
'map_style' => 'height: 300px; width:auto',
'default_zoom' => 17,
'geolocate_icon' => 'fa-crosshairs',
'marker_icon' => 'http://example.com/your-own-icon.png'
]);
- google_api_key - get your own key
- map_style - custom map style. The height attribute are required
- default_zoom - map zoom
- geolocate_icon - Font Awesome. p.s : this is not the right icon. Issue on Github
- marker_icon - use null if you want to retain Google default marker icon
Known Issue
- Geolocation only work in "secure origins" (such as HTTPS) or on localhost
- Will not work if you are using tabs unless you put it in the first tab (loading problem)
- I have include the code below to overwrite CRUD submit on Enter
// overwrite BackPack-CRUD submit on Enter
$('#search_address').keydown(function(event){
if(event.keyCode == 13) {
event.preventDefault();
return false;
}
});
This. Looks. AWESOME!!! Great job, @hedyharto . I'll give it a hard test tomorrow and include it in the next build.
Really nice work.
Cheers!
Very very useful, But Any idea how to support mysql column of type POINT, instead of text column?
also would be great if there is a 'default_latlng' option for create blade
@HusamAamer yes it would be nice if we have default field type for latlng e.g. 'type' => 'point', to reflect mysql's POINT column type.
I with the commits were squashed 🙏
really nice
but i want to be able to get the search_address input value too appended to the lat lng value any idea how can i get the place name (location name) with the lat and lng values ?
Closing this in favor of https://github.com/Laravel-Backpack/CRUD/pull/4110
Thanks for the contribution @hedyharto and sorry it didn't get merged, I've had dozens of my PR's closed too, it's just how it is sometimes. 🙃
Cheers