Welcome guest, please Login or Register

EEC.MS - ExpressionEngine add-ons

You are here: HomeForum Home → Free add-ons → Modules → Thread

   

Using geolocation with MX Google Maps

RankRank

Total Posts: 31

Joined 2010-09-29

PM

Hi Max,

I’d like to combine MX Google Maps with http://code.google.com/p/geo-location-javascript/ so that if you’re on a mobile device, rather than show you a map of all locations on a store locator map, it’d instead show you your closest one.

I’m guessing I need to get the output of geo.js into the latitude and longitude parameters for the Google maps script but I’m having trouble figuring out how to do that (javascript isn’t my strong suit).

I know it’s nearly Xmas so don’t expect a reply soon, it was just something I was tinkering with today that I’ll need for next year.

Merry Xmas!

Cheers
John

     
Rank

Total Posts: 9

Joined 2011-12-23

PM

yep, I wanna do this too. same thing, store locator and I wanna show nearest store by default and also use current location to show distance to located stores.

     
RankRank

Total Posts: 31

Joined 2010-09-29

PM

Just realised I might’ve posted this in the wrong forum, oops!

     
Avatar
RankRankRankRank

Total Posts: 701

Joined 2010-07-13

PM

Hm, and I miss it too - will check it today.

p.s. Don’t feel shy to send me twitter if I don’t answer you in 24 hours.

     
RankRank

Total Posts: 31

Joined 2010-09-29

PM

No problem. I figured you were probably off doing Xmas/end of year stuff. By the way, like the changes to the forum. smile

     
RankRank

Total Posts: 31

Joined 2010-09-29

PM

Bump.

     
Avatar
RankRankRankRank

Total Posts: 701

Joined 2010-07-13

PM

Tyssen couple questions :
1. So you want to setup map center base on geolocation? Is it correct?
2. And you also want to hide markers which not close to user?

     
RankRank

Total Posts: 31

Joined 2010-09-29

PM

Max Lazar - 16 January 2012 10:29 AM

1. So you want to setup map center base on geolocation? Is it correct?

Yes.

Max Lazar - 16 January 2012 10:29 AM

2. And you also want to hide markers which not close to user?

Well actually I had thought that you’d just show the one marker for the closest store, i.e. the map would only contain one marker, but it probably does make more sense to have them all included and then hide the others because then you could have a link to toggle all the other stores too.

     
Avatar
RankRankRankRank

Total Posts: 701

Joined 2010-07-13

PM

Tyssen - 16 January 2012 10:49 AM

Well actually I had thought that you’d just show the one marker for the closest store, i.e. the map would only contain one marker, but it probably does make more sense to have them all included and then hide the others because then you could have a link to toggle all the other stores too.

well yes, it’s possible to have one marker, but for this we need to refresh the page or use ajax load after location detect. So if you don’t have too much markers - it’s better change center, setup zoom, and hide all markers out of custom radius (you want setup some radius I expect? 5km?)

     
RankRank

Total Posts: 31

Joined 2010-09-29

PM

Actually displaying whichever stores are within a certain radius would probably be better than just one. But does the radius parameter require a page refresh?

     
Avatar
RankRankRankRank

Total Posts: 701

Joined 2010-07-13

PM

ok MX Google Map + Geo Location - quick example. Default radius is 100mil. I put 2 markers into AU, so you can try to find it by change your distance.

     
RankRank

Total Posts: 31

Joined 2010-09-29

PM

Thanks Max but what’s actually supposed to happen there? Because when I first view the page I see a map of part of the US (didn’t see any markers) and then when I clicked ‘allow’ in my browser for it to use my location I got a map of Brisbane with no markers on it.

     
Avatar
RankRankRankRank

Total Posts: 701

Joined 2010-07-13

PM

yes, the closes marker is in the Australia center.  So try to play w/ distance (default 100)  - put 1500 miles for example.

Full store locator with just JS

     
RankRank

Total Posts: 31

Joined 2010-09-29

PM

I’m not getting anything happen when I enter a distance (have tried up to 3000).

     
Avatar
RankRankRankRank

Total Posts: 701

Joined 2010-07-13

PM

do you have any JS errors?

     
RankRank

Total Posts: 31

Joined 2010-09-29

PM

Only ‘event.layerX and event.layerY are broken and deprecated in WebKit. They will be removed from the engine in the near future.’