Support Forum
Support › Meta Box Geolocation › Open Street Maps OSM Isn't Autopopulating Fields
Hey there,
I'm trying to use MB Geolocation to add location data to a custom post type.
MB Geolocation when used with Open Streetmaps does not work. The address field works and will autopopulate just fine. However my other fields for city, state, etc., do not populate their information.
To test, I tried with Google Maps info and went through the set up and that all works fine. Everything autopopulates in addition to the address field autopopulating.
I'm not using code here, just trying to integrate data into bricks builder.
Video explainer
https://watch.screencastify.com/v/gcnnCDJuzmqJQ41lhVpb
Hello,
Please open the Console tab in Inspect tool of the browser and see if there is any JS error. You can also try to deactivate all plugins except Meta Box, MB extensions and switch to a standard theme of WordPress then check this issue again.
Hi there,
I did that and I didn't notice any errors still. https://watch.screencastify.com/v/XjbnyJE5PD8DXxhwvxyx - I did switch to 2023 and deactivated plugins except mb related.
Hello,
Can you please recheck the issue on a clean installation of WordPress and Meta Box? I do not see that issue on my demo site. If it still does not work, please share your site credentials via this contact form https://metabox.io/contact/, I will take a closer look.
I did this and still having the same issue. I submitted a contact form to ask for help.
Hello,
I got the issue. The address field must have the ID address
or something with address
prefix like address_something
or address_1234
.
Please read more here https://docs.metabox.io/extensions/meta-box-geolocation/#address-field
Hmm, I think you might be referreing to Google Maps and Not OSM. I can get Google Maps Geolocation to work just fine. That is not the problem. Open Street Maps does NOT work properly. The documentation you're referring to only applies to Google Maps/Location, what you're directing me to do is for the wrong thing basically.
Address field
The address field is used to retrieve the suggestions from the Geolocation API. To add an address field, add a text field with an ID that starts with address (like address or address_something)...
This issue is still open
For Open Street Maps you must use 'building' not 'address' per your docs.
The docs for Geolocation are, for me, pretty confusion. I think the docs should be split up in a way that it's clear which part is for Google Config and for OSM config. I'm happy to update that doc once this issue is resolved.
Hello,
The different fields between Google Map and Open Street Map are listed in the section "Other Fields". Both map should use the address field with the ID address
or something with address
prefix like address_something
or address_1234
. I've changed the field ID to address and the address fields are populated properly, screenshot https://monosnap.com/file/K7RQ7lMeGQSbWP1ySdj0UighcIQuyt
I totally agree with @digisavvy that the documentation is for Geolocation is confusing. Extremely helpful would be a code example of how Google version with binding is structured and a separate code example for the OSM variant with binding.
Of note: the animated demo of this extension shows the Google version, but the OSM version requires that an OSM map be included in the field group.
Ah ha! It's only under the 'Multiple addresses' section that some hint is provided:
'address_field' => 'address_id'
So a simplified OSM example would look like this:
$meta_boxes[] = [
'id' => 'private_details_box',
'title' => 'Private Address',
'type' => 'user',
'geo' => true, // include the geo API
'context' => 'normal',
'priority' => 'high',
'fields' => [
[
'type' => 'osm',
'name' => 'The Required OSM Map',
'address_field' => 'private_address' // tell the map which field to use
],
[
'type' => 'text',
'name' => 'Private Address',
'id' => 'private_address', // does NOT need to start with address
],
[
'type' => 'text',
'name' => 'Street Address',
'id' => 'private_street_address',
'attributes' => [
'binding' => 'streetaddress',
'required' => true,
],
],
[
'type' => 'number',
'name' => 'Postal Code',
'id' => 'private_postal_code',
'attributes' => [
'required' => true,
'binding' => 'postcode'
],
],
]
];