mikebronner / nova-map-marker-field

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

Listen to Nova Events & Custom Label for geosearch box #34

Closed angelformica closed 4 years ago

angelformica commented 4 years ago

Hello,

First, I want to say thank you for this Map field. It's very good!

I think this might be useful to merge:

This adds a listener to custom event to update the map position not only with the geosearch field, but also with any field in nova.

Any nova component just has to emit an event like this:

Nova.$emit("newcenter",{lat,lng})

and the map will pan to the new position.

If you need to use a custom name for the event you can define it in your field like this:

MapMarker::make(__('Location'))->listenToEventName('myCustomEventName')

After that, any component can update the map location like this:

Nova.$emit("newcenter",{lat,long})

And the map will pan to the new position.

This is useful if you have, like me, a table with a list of locations.

If you don't specify a custom event name, "newcenter" will be used by default.

This also, allows you to specify a custom search label for the geosearch box, allowing for localization, like this:

MapMarker::make(('Location'))->searchLabel(('Enter Address'))

I hope you find this helpful,

Best regards

mikebronner commented 4 years ago

Thank you @angelformica ! This sounds like a great feature update. Let me take a look and merge it if everything is ok. :)

angelformica commented 4 years ago

Awesome!

On Sat, Feb 8, 2020 at 9:36 AM Mike Bronner notifications@github.com wrote:

Thank you @angelformica https://github.com/angelformica ! This sounds like a great feature update. Let me take a look and merge it if everything is ok. :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/GeneaLabs/nova-map-marker-field/pull/34?email_source=notifications&email_token=ADDG7WSQD3JXQFOSFTDZPATRB27QRA5CNFSM4KRYVRM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELFTEAI#issuecomment-583741953, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADDG7WV2V7U52JMTLTWGJ2LRB27QRANCNFSM4KRYVRMQ .

mikebronner commented 4 years ago

Hi @angelformica I see you have been making more updates. Let me know when you're finished, and I'll test it out.

angelformica commented 4 years ago

Hello @mikebronner

Yes, It's ready for review. I hope everything is ok, and It can be merged. My last update was only to allow custom icons not only on the FormField but also on the DetailField.

Best regards,

mikebronner commented 4 years ago

@angelformica I have one issue with the proposed changes: how can I trigger the event from the resource class? To make this truly effective, we shouldn't have to create custom components just to trigger the event -- it would be great to trigger the event from any Nova field. What are your thoughts on this?

angelformica commented 4 years ago

@angelformica I have one issue with the proposed changes: how can I trigger the event from the resource class? To make this truly effective, we shouldn't have to create custom components just to trigger the event -- it would be great to trigger the event from any Nova field. What are your thoughts on this?

Hello @mikebronner , I am sorry for the radio silence. I'm not really sure how this can be achieved. At a first thought I guess we would have to pass the name of the nova field we want to observe, to the nova map field, and then watch for changes. I would try to study the chances to do this.