Directions on CGGoogleMaps2

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
Guido
Forum Members
Forum Members
Posts: 221
Joined: Sat Aug 29, 2009 3:00 pm

Directions on CGGoogleMaps2

Post by Guido »

Hi,

I was wondering if someone can help me on my way with this. I incorporated CGGoogleMaps2 on a site I'm working on and I'd like to offer people the ability to plan a route from a desktop. I ran into a couple of problems:
  1. You can't use 'My location' from a desktop computer, since it doesn't get the correct location. Calguy explained me that since a desktop has no GPS, it will probably resolve your server location as your location, which is almost never correct.
  2. So I tried changing the input <select> field to an <input> field, but I discovered something else: The module doesn't send your request to google directly; it first checks your input with the pre-arranged list of locations you can assemble in the admin of CGGoogleMaps2. Only if there is a match will it get the address location and send this of to google to get directions. So making a text input field where someone can just type "Street, City" and the press 'submit' won't work. Is there someone who can point me to a workaround?
  3. Right now, the output of the 'directions' action is an overlay of the route on to the map, but I'd like to offer a step-by-step navigation like the regular google maps offers, but I've no idea on how to accomplish this in this module, anyone have any ideas?
JohnnyB
Dev Team Member
Dev Team Member
Posts: 731
Joined: Tue Nov 21, 2006 5:05 pm

Re: Directions on CGGoogleMaps2

Post by JohnnyB »

Well, you can improve the reliability of your desktop location lookup by using a GeoIP extension for your web server (either a PECL or PHP extension) and use a GeoIP database. There are some fee ones (http://dev.maxmind.com/geoip/legacy/geolite/) that will help but are not as accurate as the commercially available ones (https://www.maxmind.com/en/geoip2-servi ... -databases)

With those advanced tools, your lookups will be as accurate (or more accurate) as any desktop user is accustomed to seeing because even with the free one, you can almost always grab the user's city (unless they are doing some IP trickery).

As for #2 -- I think that is an option in the settings to use or not use cached lookup results.
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
Guido
Forum Members
Forum Members
Posts: 221
Joined: Sat Aug 29, 2009 3:00 pm

Re: Directions on CGGoogleMaps2

Post by Guido »

Thanks for these pointers, I didn't know they existed. I'll be sure to check them out. Of course, if someone is doing some IP trickery they don't want to be found so no use trying to serve directions to them.

Well, there is an option to turn of the cache, but I don't think it applies to this. It says it will first try the cache, and if that fails, do an online lookup. But is still Always requires you to pre-specify locations for a map you create.

Let's say I create map1, and check the 'show directions' box, the default action is to show two dropdowns (from and to locations) that let me choose 'My location' (which will hopefully be more accurate thanks to your tip) or one of the predefined locations I set up in the backend for 'map1'. When you select one of the options from a dropdown, a javascript function is triggered that fires the directions to be fetched. I changed the 'from' dropdown to an input text field and made the directions fetch function fire on clicking a DIV, but that only works if you type the exact alias of one of your predefined locations.

If 'My Location' would be accurate, I wouldn't have the need for a manual type-in (but still be curious how to make it work).

The only thing left is how to get the step-by-step directions.
Post Reply

Return to “Modules/Add-Ons”