Binding street, city etc from adress field not working
Support › MB Geolocation › Binding street, city etc from adress field not workingResolved
- This topic has 2 replies, 2 voices, and was last updated 4 years, 2 months ago by
iService Ottner Roeck OG.
-
AuthorPosts
-
February 8, 2021 at 10:38 PM #24387
iService Ottner Roeck OG
ParticipantI 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 🙁
- Why do I need the api key in the map? Your documentation in Geolocation is telling me to add it above the fields with "geo" => array("api_key" => "...") and so on, but then the map is crashing.
- If I'm typing an adress in the adress field, the map loads the pin. But how can I extract the street, zip, sity an so on in the other fields?
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...", ), ), );
February 9, 2021 at 2:56 PM #24395Long Nguyen
ModeratorHi there,
Please update the newest version of MB 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', ],
February 12, 2021 at 3:35 PM #24431iService Ottner Roeck OG
ParticipantThank 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', ),
-
AuthorPosts
- You must be logged in to reply to this topic.