• Resolved nattila

    (@nattila)


    Would it be possible to save MAPS GPS coordinates into separate meta fields? I would use a special SQL query on these fields but it requires separate LAT and LNG meta fields.
    Could it be solved somehow probably with built in actions?

    thanks

    https://wordpress.org/plugins/meta-box/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Anh Tran

    (@rilwis)

    Currently it’s not possible.

    I’d suggest you create a new field which inherits from map, but save LAT and LNG into 2 more fields. I wrote a documetation for creating a custom field, please take a look.

    To do what you want, I think all you need is just add save method, like this:

    function save( $new, $old, $post_id, $field )
    {
        parent::save( $new, $old, $post_id, $field );
    
        list( $lat, $lng, $zoom ) = explode( ',', $new . ',' );
        add_post_meta( $post_id, $field['id'] . '_lat', $lat );
        add_post_meta( $post_id, $field['id'] . '_lng', $lng );
    }

    It will save LAT, LNG in 2 custom fields: $field['id'] . '_lat' and $field['id'] . '_lng'.

    Thread Starter nattila

    (@nattila)

    Thank you very much. It’s great.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Save maps gps into separate meta fields’ is closed to new replies.