Custom Fields
Re-Envisioned
Support Meta Box Geolocation Is it possible to search for a city or an address?

  • Creator
    Topic
  • #30875
    Andreas Wundersee
    Participant

    Hi,

    at first I needed the geolocation for complete addresses - that worked perfectly. But now I need the possibility to search for cities and addresses, because not every entry has a complete address.

    I thought that I just have to add the "types" field to the "geo"-entry, but the combination doesn't work. I can only search for "cities" or an "address" - is that right or is my code wrong?

        $meta_boxes[] = array(
            'id'      => 'geolocation',
            'title'   => 'GeoLocation',
            'context' => 'normal',
            'priority'    => 'high',
        'geo' => array(
                'componentRestrictions' => array(
                    'country' => 'deu'
                ),
                'api_key' => 'AIzaSyC6A39MylwOhGD7sU-CKCV2JAdSyve_2zM',
                'types' => array('address', '(cities)'),
            ),
    
            'fields' => array(
                array(
                    'type' => 'text',
                    'name' => 'Addresse',
                    'id'    => 'address',
                ),  
                array(
                    'type' => 'text',
                    'name' => 'Breitengrad',
                    'id'    => 'lat',
                    'binding' => 'lat', 
            'address_field' => 'address',
                ),
                array(
                    'type' => 'text',
                    'name' => 'Längengrad',
                    'id'    => 'lng',
                    'binding' => 'lng',
            'address_field' => 'address',
                ),      
            )
        );

    Thanks for your help,
    Andi

  • You must be logged in to reply to this topic.