-
-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Geopoint support #112
Comments
Hi @TheAussieStew |
Sounds good! |
I am marking this feature as a good first issue. |
Anyone manage to get a working implementation before I go and make one myself tonight? Worth an ask :) |
H @SKLn-Rad, as far as I know this has not been implemented yet! |
Any news on the status of this? Would love to see all Firestore data types supported. Could somebody please share a code snippet that would be required to add support for Firestore geopoints? Thanks! |
This feature is not planned at this moment. |
Ok, thanks for your reply. Could you share how the workaround you suggested, using custom fields would work? Something really simple, like giving the user a text field where comma separated |
Hi @jbxbergdev |
@fgatti675 hm ok. I tried a custom field implementation as per your link for the type GeoPoint. However, in the CMS, I still get the error "Currently the field geopoint is not supported". Any idea what I'm doing wrong?
|
Hi @jbxbergdev did you also link the field in your corresponding property? |
@fgatti675 ah yeah, I did. I'll update the code snippet. So in the create/edit view the field is showing the error message. |
Here is a working implementation. I have made the following react jsx element.
This can be used in a custom field as follows:
This can be added to your collection as follows:
|
Awesome! Think you could submit a PR? |
Sure, I'll try and do that sometime this week @fgatti675 . |
@singhvedant111 Did you ever get around to this? |
@singhvedant111 – I like your map implementation. I ended up working something out based on yours that's a simple text input, accepting a comma separated latitude, longitude. import React, { FunctionComponent } from "react";
import { FieldDescription, FieldProps, GeoPoint } from "firecms";
import {TextField} from "@mui/material";
const GeoPointField: FunctionComponent<FieldProps<GeoPoint>> = ({
property,
value,
setValue,
error,
isSubmitting,
}) => {
const geoPointToString = (geoPoint: GeoPoint) : string => {
return `${geoPoint.latitude}, ${geoPoint.longitude}`;
}
const stringToGeoPoint = (str: string) : GeoPoint => {
const [latitude, longitude] = str.split(',');
return new GeoPoint(parseFloat(latitude), parseFloat(longitude));
}
return (
<>
<TextField
required={property.validation?.required}
error={!!error}
disabled={isSubmitting}
label={property.name}
helperText={error}
fullWidth
variant={"filled"}
value={value?.latitude && value.longitude ? geoPointToString(value) : ''} onChange={(evt) => {
setValue(
stringToGeoPoint(evt.target.value)
);
}}/>
<FieldDescription property={property} />
</>
);
}
export default GeoPointField; |
I'm having a bit of trouble implementing this custom field. The implementation complains that the field is not supported. Are custom fields not supported? How does one use a different datatype? |
I understand that Geopoint isn't currently supported, however is there a potential roadmap for adding support? Or does the custom view support allow us to add it ourselves?
The text was updated successfully, but these errors were encountered: