numero2 / contao-storelocator

Contao Plugin for managing stores (or in common address data) and providing a frontend-search based on geo data.
https://www.numero2.de/contao/erweiterungen/storelocator.html
GNU Lesser General Public License v3.0
13 stars 8 forks source link

User location on loading #30

Closed vmulot closed 4 years ago

vmulot commented 6 years ago

Hi, it's not a bug, but i'd like to get User Position (with the browser prompt for geolocation), center Map on it, and get the distance calc for stores around him. i didn't find if your module can handle that. i' tried myself, i managed to get user position, centering the map, but i don't have the distance in the store list.

any advice/idea/update? :)

thanks

bennyborn commented 6 years ago

Not quite sure if I understand you correctly but the Storelocator itself can tell you the distance to the store from the given location

https://github.com/numero2/contao-storelocator/blob/599d6616b55b9df971d48395f686fb3904d42ed1/templates/modules/mod_storelocator_list.html5#L30-L34

If you'd want to use the browsers location you might add you script to the mod_storelocator_search.html5 and populate all the hiddens fields (which also contain the coordinates) and submit this form automatically.

That way the user will end up in the results list having all distances shown ;)

vmulot commented 6 years ago

Thanks for answering ! i tried your tip but how do you handle the submit only the first time and only if coords are available ? i tried to check the GET params (lat and lng) but it keep submitting form.

As github is messing up my code, here is a gist of what i did

Thanks again for your help !