Link to home
Start Free TrialLog in
Avatar of Jules Webb
Jules WebbFlag for United States of America

asked on

Problems with get directions using google map api

I am using jQuery GPS - http://www.birdwingfx.com/jQuery_gps/index.html  to add a google map to a site.

With the help of wilq32 I got it working the way I needed it to, but now the get directions isn't working and I don't know how to figure out why.

Link to original thread: https://www.experts-exchange.com/questions/25353701/Google-Maps-with-jQuery.html

Link to page in question: http://www.massagecenters.webbdemo.com/contact

Thanks for the help!
Jules
Avatar of Pawel Witkowski
Pawel Witkowski
Flag of Poland image

What do you mean by isn't working?  I open a page, type New York there click "get direction" and I receive directions? Hmm maybe the google had problems when you posting this problem ?
Avatar of Jules Webb

ASKER

I don't know what the deal is, but I've tried it on three different computers and 4 browsers, I asked the owner to try it from his home office, none of us are getting directions.  When I look at the div#directions in firebug it's empty.  Just to be sure I went to maps.google.com and yep I got directions.  I'm stumped... can you try emptying your cache and seeing if you get the same problem then?
So I did test on different browsers to see the problem and.... well it seems like strange Google Bug - the same code works on Firefox 3.6 and in chrome, but in Safari and IE it works for ... not every entries! Try typing in fields:

New York
California


And you will get results in all broswers so this is something more google problem specific :/ You can try make a second parameter that you put as a constant a geoLocation (using lat,lng numbers) - anyway its kinda strange bug o_O
I even look at Safari response from server and safari gets response from google server:

_xdc_._ig88g1kk6 && _xdc_._ig88g1kk6({"name":"from: New York to: Massage Center of Bellevue 37 103rd Ave. N.E. Suite A, Bellevue, WA 98004","Status":{"code":602,"request":"directions"}})



And firefox:

_xdc_._2g88ipumq && _xdc_._2g88ipumq({"name":"from: New York to: Massage Center of Bellevue 37 103rd Ave. N.E. Suite A, Bellevue, WA 98004","Status":{"code":200,"request":"directions"},"Placemark":[{"id":"","address":"Nowy Jork, NY","AddressDetails":{"Country":{"CountryNameCode":"US","CountryName":"USA","AdministrativeArea":{"AdministrativeAreaName":"NY","SubAdministrativeArea":{"SubAdministrativeAreaName":"New York","Locality":{"LocalityName":"New York"}}}},"Accuracy": 4},"Point":{"coordinates":[-74.005973,40.714269,0]}},{"id":"","address":"37 103rd Avenue Northeast, Bellevue, WA 98004","AddressDetails":{"Country":{"CountryNameCode":"US","CountryName":"United States","AdministrativeArea":{"AdministrativeAreaName":"WA","SubAdministrativeArea":{"SubAdministrativeAreaName":"King","Locality":{"LocalityName":"Bellevue","Thoroughfare":{"ThoroughfareName":"37 103rd Avenue Northeast"},"PostalCode":{"PostalCodeNumber":"98004"}}}}},"Accuracy": 0},"Point":{"coordinates":[-122.202862,47.610550,0]}}],"Directions":{"copyrightsHtml".........................




As you can see you get a 602 status For the same request but on different browsers (???). Please try type in a different street name:]

"G_GEO_UNKNOWN_ADDRESS = 602       No corresponding geographic location could be found for the specified address. This may be due to the fact that the address is relatively new, or it may be incorrect. " - quote taken from   http://code.google.com/intl/pl/apis/maps/documentation/reference.html#GGeoStatusCode.G_GEO_UNKNOWN_ADDRESS
I did a  search using the term "google map code help" and came across http://www.mobilefish.com/services/googlemap/googlemap.php

I went ahead and set the page up with this new code and it works fine, but I'd still like to replace the standard icon with with custom marker. Can you help me with this?

Jules
// Google Map Custom Marker Maker 2009
// Please include the following credit in your code

// Sample custom marker code created with Google Map Custom Marker Maker
// http://www.powerhut.co.uk/googlemaps/custom_markers.php

var myIcon = new GIcon();
myIcon.image = 'http://www.massagecenters.webbdemo.com/assets/jquery/markers/image.png';
myIcon.shadow = 'http://www.massagecenters.webbdemo.com/assets/jquery/markers/shadow.png';
myIcon.iconSize = new GSize(27,50);
myIcon.shadowSize = new GSize(52,50);
myIcon.iconAnchor = new GPoint(27,50);
myIcon.infoWindowAnchor = new GPoint(14,0);
myIcon.printImage = 'http://www.massagecenters.webbdemo.com/assets/jquery/markers/printImage.gif';
myIcon.mozPrintImage = 'http://www.massagecenters.webbdemo.com/assets/jquery/markers/mozPrintImage.gif';
myIcon.printShadow = 'http://www.massagecenters.webbdemo.com/assets/jquery/markers/printShadow.gif';
myIcon.transparent = 'http://www.massagecenters.webbdemo.com/assets/jquery/markers/transparent.png';
myIcon.imageMap = [14,0,15,1,15,2,24,3,24,4,25,5,25,6,24,7,23,8,22,9,21,10,20,11,19,12,18,13,17,14,16,15,16,16,16,17,17,18,17,19,17,20,17,21,17,22,18,23,18,24,18,25,18,26,17,27,17,28,17,29,17,30,17,31,17,32,17,33,17,34,17,35,17,36,16,37,16,38,16,39,16,40,15,41,15,42,14,43,13,44,13,45,11,46,10,47,10,48,9,48,9,47,9,46,10,45,10,44,10,43,9,42,9,41,9,40,8,39,8,38,8,37,7,36,7,35,8,34,7,33,7,32,7,31,7,30,7,29,8,28,8,27,8,26,8,25,9,24,9,23,10,22,10,21,10,20,10,19,10,18,10,17,11,16,11,15,10,14,9,13,8,12,7,11,6,10,4,9,1,8,2,7,2,6,2,5,11,4,11,3,12,2,12,1,13,0];

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Pawel Witkowski
Pawel Witkowski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you for the instructions.  I updated the function createMarker and it works just fine.  I tested it in Safari, Google, Firefox and ie7.

"The code for directions is very similar - first check if you can find route on that page to the exactly the same address that you type on there. As I already told you its rather not a problem of a script that does everything how it should based on googleApi documentation. Its rather strange bug that for the same address google returns 602 status (not found) or 200 status (everything ok)."

Not sure I understand what your are trying to communicate.  It does work when the start and end destinations are the same.  It gives one line of instructions "Head north on..."  I never did see 602 or 200 status errors, with this code or the previous one.


Thank you so much for your continued help!
Appreciate your time, thanks:-)