Support Forum
Support › MB Geolocation › Single Field for Lat, Long
Is it possible to use a single text field to paste Lat, Lng values for the map? I've tried this but it doesn't seem to work.
Subsequently, when using two text fields, one for lat and the other for long, there is a 'No address foiund' pop up that appears each time you enter one or other of the lat or long values. How can I get round this?
Also, I've noticed strange behaviour where I paste in a known lat long value but it gets updated when the pin is lauto-located.
Images can be seen here:
Image Folder
Hello,
Currently, there isn't an option to use a single text field to paste Lat, Lng values for the map. You need to use two text fields: Lat and Lng.
Regarding the popup error, I don't see that issue on my demo site, screenshot https://imgur.com/LAfF0eE
When you change the pin on the map, the Lat and Lng values are updated. When you change the Lat and Lng values, the pin on the map is changed also. This feature is noted in the documentation https://docs.metabox.io/extensions/meta-box-geolocation/#two-way-data-binding
OK thanks, I think I got confused by 'geometry' as a value that is stored for lat-long.
I have made a short screen recording of the pop-up issue. Maybe it's only when pasting a value into the lat or long field?
The recording is in this folder:
movie Folder
Also, I'm still struggling to get a custom select function to save to the database, as per this thread. I marked it as resoled accidentally, but it's not working yet and I'd really appreciate some guidance!
Hello,
I don't see you have an address
field for the map field. Do you use the lat
field as the address field?
Following the documentation https://docs.metabox.io/extensions/meta-box-geolocation/#address-field
I'm using two fields: lat and long for those. And yes, I can see that they are connected to the map pin - if I move the pin their values update.
Should I make the field id address_lat and address_lng ?
Hello,
No, you should create a separate text
field with the ID address_xxx
to retrieve the suggestions address for the map. Here ist the sample code:
'fields' => [
[
'name' => __( 'Address', 'your-text-domain' ),
'id' => $prefix . 'address',
'type' => 'text',
],
[
'name' => __( 'Lat', 'your-text-domain' ),
'id' => $prefix . 'lat',
'type' => 'text',
],
[
'name' => __( 'Lng', 'your-text-domain' ),
'id' => $prefix . 'lng',
'type' => 'text',
],
[
'name' => __( 'Map', 'your-text-domain' ),
'id' => $prefix . 'map_v0mlzrv141',
'type' => 'map',
'api_key' => 'xxx',
'address_field' => 'address',
],
]
Thanks, I'm only really interested in the lat and long values for the map location, I don't really need things like postcode or street name.
The map does seem to be working, it's just that pop-up box that makes it a bit annoying.
Hello,
Please export your field group to a JSON file and share it here. I will check it on my demo site. Following the documentation https://docs.metabox.io/extensions/meta-box-builder/