Hi, all!
First of all, I want to acknowledge the Geolocation field from @lekkerduidelijk, which prompted me to create this one. Much appreciated!
There were a few things that Rutger’s plugin dictated that I had to work around, so I went ahead and wrote a new one with the primary goal of increasing flexibility and reliability.
You can read about the plugin on Github.
Features
- Familiar Google Maps UI
- Discrete storage of location name, latitude and longitude
- Geocoding of place names and addresses
- Repositionable marker (in case search doesn’t nail it)
- Support for multiple
place
fields per form - Support for
place
fields withinstructure
fields. - Easy to implement (See “Getting Started”, below)
- Customizable default position and zoom— globally and on a per-field basis
Usage
The field can be used as many times as you like in a form, and can even be nested inside a structure
field.
fields:
location:
label: Location
type: place
center:
lat: 45.5230622
lng: -122.67648159999999
zoom: 9
help: >
Move the pin wherever you'd like, or search for a location!
Be sure to check out the Readme on GitHub for additional notes on configuration.
At the moment, I’m saving data as JSON. You can use PHP’s native json_decode()
function to extract the address
, lat
and lng
members of the object. Alternatively, you might implement your own custom field method, to decode and grab a single member, like $page->place()->location('lat')
or $page->place()->location('address')
.
I’ve planned to release this functionality in a separate and optional field method plugin, but wanted to wrap up or freeze development on the field, first.
So: I’d love your feedback. This is one of my first contributions to Kirby, and I’m interested to see what you can do with it!
Happy programming!