PHP code for Google Map to auto populate street_address, lat, lng, street

Support MB Geolocation PHP code for Google Map to auto populate street_address, lat, lng, street

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #44066
    justdoit123justdoit123
    Participant

    Hi, i tried to add text field id "street_address" and "geometry"

    but it does not auto populate data

    please give me php code to auto populate data
    Just like the gif image demo:
    https://i1.wp.com/metabox.io/wp-content/uploads/2016/03/meta-box-geolocation.gif
    in
    https://docs.metabox.io/extensions/meta-box-geolocation/#address-field

    my php code below not working to auto populate:

     $meta_boxes[] = [
            'title'      => __( 'Google Map', 'pmbds' ),
            'id'         => 'geometry',
            'post_types' => ['properties'],
            'context'    => 'after_title',
            'geo'        => [
                'api_key' => 'xxxxxxxx',
     => 'vn'
        ],
            ],
            'fields'     => [
                [
                    'name'        => __( 'address search', 'pmbds' ),
                    'id'          => $prefix . 'address_map',
                    'type'        => 'text',
                ],
    
                [
                    'name'        => __( 'lat', 'aaaa' ),
                    'id'          => $prefix . 'lat',
                    'type'        => 'text',
                    'columns'     => 12,
    
                ],
    
                [
                    'name'        => __( 'street_address', 'aaaa' ),
                    'id'          => 'street_address',
                    'type'        => 'text',
                    'columns'     => 12,
    
                ],
               [
                    'name'        => __( 'geometry', 'aaa' ),
                    'id'          => $prefix . 'geometry',
                    'type'        => 'text',
                    'columns'     => 12,
    
                ],
                [
                    'name'          => __( 'google map', 'aaa' ),
                    'id'            => $prefix . 'map_g',
                    'type'          => 'map',
                    'api_key'       => 'xxxxxx',
                    'address_field' => 'address_map',
                    'binding' => 'geometry',
                    'zoom'         => 14,
                    'columns'     => 12,
                ], 
            ],
        ];
    
    #44076
    PeterPeter
    Moderator

    Hello,

    Please check if you assign a string to the variable $prefix, try to remove it and binding setting in the map field and check this issue again. Remove the redundant code => 'vn' in the geo setting also.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.