Single Field for Lat, Long
Support › MB Geolocation › Single Field for Lat, Long
- This topic has 8 replies, 2 voices, and was last updated 1 year, 2 months ago by
Peter.
-
AuthorPosts
-
January 27, 2024 at 12:20 AM #44406
leebazCDS
ParticipantIs 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.
January 27, 2024 at 12:22 AM #44407leebazCDS
ParticipantImages can be seen here:
Image FolderJanuary 29, 2024 at 10:23 PM #44427Peter
ModeratorHello,
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
January 29, 2024 at 10:39 PM #44428leebazCDS
ParticipantOK 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 FolderAlso, 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!
January 30, 2024 at 10:26 PM #44434Peter
ModeratorHello,
I don't see you have an
address
field for the map field. Do you use thelat
field as the address field?
Following the documentation https://docs.metabox.io/extensions/meta-box-geolocation/#address-fieldJanuary 31, 2024 at 9:04 PM #44441leebazCDS
ParticipantI'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 ?
January 31, 2024 at 10:56 PM #44445Peter
ModeratorHello,
No, you should create a separate
text
field with the IDaddress_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', ], ]
January 31, 2024 at 11:20 PM #44446leebazCDS
ParticipantThanks, 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.
February 1, 2024 at 8:58 PM #44452Peter
ModeratorHello,
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/
-
AuthorPosts
- You must be logged in to reply to this topic.