Skip to content

Transform lat/lng from collection to meilisearch _geo attribute #7

Discussion options

You must be logged in to vote

Hi @tao

thx for the inspirations! I ended up with adding a _geo to my Statamic collection which holds the lat and lng values separated by comma. So the transformer was easy to set up:

 'transformers' => [
                '_geo' => function ($_geo) {
                    $latlng = explode(',', $_geo);
                    return [
                        '_geo' => [
                            'lat' => (float) $latlng[0],
                            'lng' => (float) $latlng[1]
                        ]
                    ];
                },

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@tao
Comment options

Answer selected by preeco-privacy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant