Log in

View Full Version : HELP!! - Google Maps API



Jeff
10-02-2008, 02:45 AM
I'd like to add Google Maps directions to a website. I'd like the destination address to be prepopulated and for the map to be focuses on the destination address on page load.

Basically, I want to user to be able to enter their home address and press a button for the map to be updated and for directions to be listed to the address that I specify.

Is this possible?

AMDave
10-02-2008, 09:34 AM
straight for the jugular

this tutorial provides examples:
http://econym.org.uk/gmap/basic4.htm

You should also check out the advanced tutorial link on that page which appears to be doing exactly what you want.

Also for assistance you will benefit from reading the following references:

directions API reference
http://code.google.com/apis/maps/documentation/services.html#Directions

class GDirections
http://code.google.com/apis/maps/documentation/reference.html#GDirections

maps API reference
http://code.google.com/apis/maps/documentation/index.html

Jeff
10-02-2008, 12:13 PM
Dave, I'm actually looking for something similiar to this.

http://code.google.com/apis/maps/documentation/examples/directions-advanced.html

Of course they don't provide the API code they used to accomplish this. And it requires both a starting and ending address.

Jeff
10-02-2008, 10:03 PM
I found exactly what I need.

http://map.pittwebsite.com/add_driving_directions_to_your_website.htm

These guys are charging 255 bucks though :(

Jeff
10-04-2008, 01:45 AM
Would someone please take a look at these two sites:

http://premier.amdusers.com/Untitled-1.html
http://premier.amdusers.com/Untitled-2.html

Untitled 1 refuses to load the graphical map - even though I copied the code from Untitled-2.html. Untitled-2.html works fine.

I've spent probably 3 hours looking at this, and I just can't figure it out. I just don't know why it won't work :(

AMDave
10-05-2008, 03:01 AM
I have had a look at this and I'm not sure why it is not working properly.
I see some significant differences in the page properties, like the script is not being loaded or executed properly.
Just wondering if something from the other google include might be interfering with it, since it works fine in the other page.
You can try either taking bits out of the page you have to diagnose the problem, or build your page around the working instance bit-by-bit until you hit the issue, then you will know what it is that needs to be resolved.

Jeff
10-05-2008, 03:23 AM
It is weird. The script does work -- sort of. If you type in an address and click the button, it does return the written directions.

AMDave
10-05-2008, 03:38 AM
Yeah, but the map call is not working.
I cannot see the "media" in the FF page properties like the other page.

Danish Dynamite
10-05-2008, 04:06 AM
these a second style tag about about half way though source
<style type="text/css">
@import url(http://www.google.com/cse/api/overlay.css);
</style>
shouldn't that be included in first style or excluded ?
<style type="text/css">
.p1 { position: relative; left: 550px; top: 23px; z-index: 3; }
body { margin:0px;padding:0px;
background-color: #ffffff;
background-image: url(images/bg_gradient.jpg);
background-repeat: repeat-x;
background-position: top center;
}
.tbl1
{
background: url('images/MAINCONTENT.jpg');
background-repeat: no-repeat;
}
.style1 {font-family: Arial, Helvetica, sans-serif}
.style3 { font-family: Arial, Helvetica, sans-serif;
color: #00465e;
}
</style>

Jeff
10-08-2008, 01:48 PM
As it turns out, there were two onload function calls.

Thanks everyone!

AMDave
10-08-2008, 02:58 PM
Thanks for the feedback.
No amount of staring at the code was going to help me pick that up.
I guess it is an easy trap to fall into when merging code from multiple pages.
I'll watch out for that myself.
Glad you got it fixed.