Imagine you have to enter information for a shop or a location, you’d probably need various fields: address, state, suburb, post code, latitude, longitude… Each time you add or edit a post, you must enter and check all these fields manually. That could be a nightmare if you have many posts because it’s slow, time-consuming and sometimes, inaccurate. You’d need a better way to enter this data which can help you automatically fill in all the fields with proper values. That’s when Meta Box Geolocation comes to rescue.
Meta Box Geolocation is an extension of the Meta Box plugin which interacts with Google Maps Geocoding API and automatically populates location data into your fields. Now you only have to type the desired address, verify it by the auto-suggested addresses from Google Maps Geocoding API and then select the correct one from dropdown. All other fields’ values (post code, state, country, …) will be automatically filled in instantly.
The screenshot below demonstrates how the extension works:
What’s the Meta Box Geolocation useful for?
As stated by its name, the extension is useful when you need full information about a location, which you can use later to query posts in the frontend (query posts by state, city, etc.).
For example, you have a real-estate website and each property listed on the website needs full information about address, town, post code, state, country. Using this extension, what you need to enter (partly) is just the address and everything else is queried from Google Maps Geolocation API database and filled in for you.
The extension can be very helpful for other kinds of listing websites: car parking, restaurants, coffee shop, tour, etc. Whenever you need a location, Meta Box Geolocation can help.
Simple to use
The extension is extremely easy to use. You don’t need to setup Google Maps API. All you need to do is just register your desired fields (address, postal code, country, etc.) as normal fields in Meta Box and then set the field’s id same as address components (
country) and it works.
For example, if you set the field id to
country, then the country name will be bound to this field. The same for
state and other components of the address.
You can also set the short version of the country name (US instead of United States, RU instead of Russia) by appending
_short to the field’s id, e.g.
For sample code, see Meta Box Geolocation documentation.
No Database Required
It’s a really bad idea to setup and maintain a huge database of locations and places. Forget it, just connect to Google and they’ll handle them all.
Powerful Binding Template
Sometimes, you want to save complex data into 1 field. For example: State + Country. Meta Box Geolocation has Binding Template which helps you do that.
Not fast, it’s INSTANT
All data will be populated instantly when user select an address.
Frequently Asked Questions
Can I populate state name to my field’s ID which named `my_dummy_field`?
Yes. By default, you can set the field id same as address components and it will work out of the box, but you can also use the binding template to auto populate data to your field which id doesn’t exist in address components.
Version 1.1.1 - September 26th, 2016
- Improvement: Improve the loader for theme. Just require the plugin and it works.
- Fix: Field should match exactly instead of contain Address Components.
Version 1.1 - August 4th, 2016
- New: Works with cloned group
Version 1.0.1 - May 20th, 2016
- Improvement: Better compatibility with Map field
- Improvement: Trigger `selected_address` when address change
Version 1.0 - March 28th, 2016
- First release