mikebronner / nova-map-marker-field

Provides an visual interface for editing latitude and longitude coordinates.
MIT License
131 stars 36 forks source link

Support for Storing lat/long in mysql Geo Point field #51

Closed danielwashbrook closed 3 years ago

danielwashbrook commented 3 years ago

We've been using mysql's geo Point() field for storing the latitude and longitude values. I wrote a quick override to the fillAttributeFromRequest to handle this in our app. Is there any interest in merging this type of support into the main repo? Cheers

mikebronner commented 3 years ago

@danielwashbrook Any PRs you send in would be greatly appreciated! :)

danielwashbrook commented 3 years ago

Cool, happy to put together a PR. Do you think the best approach would be a field option like ->fieldType('Point') vs ->fieldType('Text') or a trigger like ->isPointField() ?

mikebronner commented 3 years ago

@danielwashbrook I can't say without more context. Would it be a huge difference in code either way? Say, if you went one way, how hard would it be to flip to the other way?

danielwashbrook commented 3 years ago

It seems minimal effort either way. A condition in the fillAttributeFromRequest and resolve is all it really needs. But if we go with the fieldType() we could allow for 'Array' storage as well perhaps? We could go with both approaches and see 🤷

nshontz commented 3 years ago

Wanted to follow up and see how this was coming and offer any support.

mikebronner commented 3 years ago

@danielwashbrook @nshontz Certainly still open for a PR, if you can submit one. :)

nshontz commented 3 years ago

This is where I landed in my attempt: https://github.com/nshontz/nova-map-marker-field/commit/e3d375c0b0195dc557c81c4974edd15eaa41f022

BUT it seems like Laravel Nova is trying to serialize and log the change in action_events, because the shape data isn't UTF friendly it's throwing an error. I'm working on that now. If I can find a solution I'll write some documentation and submit the PR.

but if you have feedback on the code now, I'm happy to refactor as needed.

Implemented: MapMarker::make("Location") ->fieldType('point') ->pointField('location')

nshontz commented 3 years ago

ActionEvent.php: 108 'original' => array_intersect_key($model->getRawOriginal(), $model->getDirty()),

Calling getRawOriginal here returns the raw shape data which yields something like "location":"�\u0010\u0000\u0000\u0001\u0001\u0000\u0000\u0000�Ye���T���q�xA@"

nshontz commented 3 years ago

PR: https://github.com/GeneaLabs/nova-map-marker-field/pull/53