Does PayloadCMS supports geospatial queries? (https://www.mongodb.com/docs/manual/geospatial-queries/). I'd like to create a custom field that gets lat/lng from an autocompleted address.
Goal: I want to find database entries according to a radius around a point or within a geofence and show them on my website. (For example, show related entries that are nearby)
Great question! Look at the docs for the point field.
https://payloadcms.com/docs/fields/point
Based on what you said it should get you everything you need.
Not sure how I could miss that 😅
Btw, any hint (or even better an example), how I could create a custom field that loads data from an API endpoint (based on input) and renders a select field for the addresses?
Something like this (example taken from graphcms)
(I have a react component ready that loads google maps sdk, has an input field, etc...)
// edit:
Just found https://github.com/payloadcms/custom-field-guide and https://github.com/payloadcms/public-demo/tree/master/src/fields to look at 👀
You got it. The ui
field is useful if you don't have data directly on the field and want to show a custom element in the edit view and/or cell views.
When you do have data to store on the field, you can use whatever field type is best reflected by the data and still write your own custom components as explained in that guide. The main difference is having to update values. UI fields are nice in that you don't have to set values and can just get other field data to display what you need.
Star
Discord
online
Get dedicated engineering support directly from the Payload team..