bradcornford/Googlmapper

Map Drag Event (Livewire)

seriousjelly opened this issue · 3 comments

Hey, first up, great job on this package!

Just have one question, I am currently integrating this package in to a project that uses Livewire, and essentially, I want to hook into the dragend event via the Livewire component. This would allow me to fetch new places and generate markers for them once the user has finished dragging the map (I guess similar to what AirBnB do in their search page).

Is there an easy way (writing limited JS and as Livewire esque as possible) to achieve this functionality?

Google Maps JS SDK Events

Hey, thanks! Yeah, you should be able to call the addlistener event using the event after load with the map as the first parameter on the construction map itself. Your other option is to access the maps js global and attach the listener that way.

Hey, thanks! Yeah, you should be able to call the addlistener event using the event after load with the map as the first parameter on the construction map itself. Your other option is to access the maps js global and attach the listener that way.

Thanks! I will give take another look tomorrow and see how I get on :)

'eventDragEnd' => 'window.Livewire.emit("updateLatLng", event.latLng);',

Then have it as a listener in your component.