Developer forum

Forum » CMS - Standard features » Map - Nearest
Aki Ruuskanen
Reply

Hi,

I would like the maps module to show the nearest location on pageload. Can anyone point me in the right direction?

Regards / Aki

 


Replies

 
Nicolai Høeg Pedersen
Reply

A couple of solutions can be found here: https://www.google.dk/?gws_rd=ssl#q=google+map+nearest+location

BR Nicolai

 
Aki Ruuskanen
Reply

I was thinking more in the context of the Maps module. I thought that perhaps I could use the exisiting "Find nearest" functionality in that module. 

 
Nicolai Høeg Pedersen
Reply

Hi Aki

You need to get the nearest location from the browser and inject it on load in the Maps.js init function. That will be something that the browser and MAPS apis support.

I cannot get any closer without actually coding for you... Maybe someone did this already and have some code to share?

BR Nicolai

 
Aki Ruuskanen
Reply

I added

google.maps.event.addDomListener(window, 'load', searchNearest);

after the

google.maps.event.addDomListener(window, 'load', init);

in maps.js.

Looks like it does the trick.

 

 
Aki Ruuskanen
Reply

Not the best solution though...

 
Nicolai Høeg Pedersen
Reply

Neat, seems like a good solution...

 

You must be logged in to post in the forum