Support Forum
Support › Meta Box Geolocation › Binding street, city etc from adress field not workingResolved
I installed Meta Box and Geolocation and can't extract the address parts I need. I'm confused with the documentation in the metabox (fields) and the other plugin Geolocation because the information's are different. And I can't find a working example 🙁
My Config:
$meta_boxes[] = array(
"id" => "prefix_entry",
"title" => esc_html__("my entry", "my_module"),
"post_types" => array("my_entry"),
"context" => "normal",
"priority" => "high",
"api_key" => "...-pAfUh8L_UpPGfA...", // API Key tested -> working fine
"fields" => array(
array(
"id" => "prefix_address",
"name" => esc_html__("Address", "my_module"),
"type" => "text",
),
array(
"id" => "prefix_city",
"name" => esc_html__("City", "my_module"),
"type" => "text",
"binding" => "locality",
"address_field" => "prefix_address",
),
array(
"id" => "prefix_street",
"name" => esc_html__("Street", "my_module"),
"type" => "text",
"binding" => "street_address",
"address_field" => "prefix_address",
),
array(
"id" => "prefix_map",
"name" => esc_html__("Location", "my_module")),
"type" => "map",
"address_field" => "prefix_address",
"api_key" => "...pAfUh8L_UpPGfA...",
),
),
);
Hi there,
Please update the newest version of Meta Box Geolocation v1.3.1 then use the sample code here: https://pastebin.com/fcVpvtC0.
If you use the Google Maps field, no need to add the key to the geo
setting.
// For Open Street Maps or using API key in Google Maps field.
'geo' => true,
// For using geolocation with address components only
'geo' => [
'api_key' => 'YOUR API KEY',
],
Thank you very much. I got it running and tested it a little bit. In your example it is not extracting the city. The key that worked for me is "administrative_area_level_1". Also worth mentioning is the fact, that my mistake was to add prefixes to my column ids.
I think I also found a bug by extracting the steet information:
[
'type' => 'text',
'name' => 'Street',
'id' => 'street_address',
'address_field' => 'address6',
],
[
'type' => 'text',
'name' => 'Number',
'id' => 'street_number',
'address_field' => 'address6',
],
The Number is working but not the street name. Cant find the Street in any other field.
And finally I got an example with open street map because the binding is working different. If someone need this information. I think the documentation could be more detailed. In this example all bindings are working:
array(
'id' => 'address',
'name' => 'Search Pin',
'desc' => 'Search order: number, street, city, postcode',
'type' => 'text',
),
array(
'id' => 'map',
'name' => 'Map',
'type' => 'osm',
'language' => 'de',
'address_field' => 'address',
),
array(
'id' => 'road',
'name' => 'Street',
'type' => 'text',
'address_field' => 'address',
'binding' => 'road',
),
array(
'id' => 'house_number',
'name' => 'Number',
'type' => 'text',
'address_field' => 'address',
'binding' => 'house_number',
),
array(
'id' => 'postcode',
'name' => 'Postcode',
'type' => 'text',
'address_field' => 'address',
'binding' => 'postcode',
),
array(
'id' => 'city',
'name' => 'City',
'type' => 'text',
'address_field' => 'address',
'binding' => 'city',
),
array(
'id' => 'country',
'name' => 'Country',
'type' => 'text',
'address_field' => 'address',
'binding' => 'country',
),