Google Groups Home
Help | Sign in
Trouble updating map/directions to reflect user input
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
CauselessEffect  
View profile
(1 user)  More options Aug 20, 4:39 am
From: CauselessEffect <CauselessEff...@gmail.com>
Date: Tue, 19 Aug 2008 16:39:10 -0700 (PDT)
Local: Wed, Aug 20 2008 4:39 am
Subject: Trouble updating map/directions to reflect user input
First off, my goal is to have a page on my website that when opened
provides a map preset to my location.  Under this map I would like to
have a form for the visitor to input a starting location that then
updates the map on the page and lists directions just beneath.

This is my first time dabbling with Google API and actually javascript
as well so it's taken me hours to get as far as I have.  When inserted
into my .html page I can successfully get the map to show the
destination as long as variable 'a' is set to '1'.  Alternatively,
when set to '0' I can get the map and directions to pop up as long as
there is a location stored in variable 'origin'.  The javascript
'checkform' is meant to verify data has been entered, and if it has,
I've attempted to pass that to back to function 'destination'.  My
problem is getting the 'destination' function to update the page with
the entered information.

I'd really appreciate if anyone's willing to try and help me out with
this.  With a decent amount of programming experience I thought this
would be no problem but obviously there must be something I'm
missing.  Thanks.

<script src="http://maps.google.com/maps?
file=api&amp;v=2&amp;key=MYKEY" type="text/javascript"></script>
    </p>
                <div id='map_canvas' style='width: 400px; height:
400px'></div>
    <div id ='my_textual_div'>
      <h3>Get Directions</h3>
    </div>

<script type='text/javascript' language='javascript'>
        var map;
        var panel;
        var dir;
        var a=1;
        var origin='';
        var to=' to ';
        var destin='Normal, IL';

        function destination(origin, a)
        {
                map = new GMap2(document.getElementById("map_canvas"));
                panel = document.getElementById("my_textual_div");
                map.addControl(new GMapTypeControl());
                map.addControl(new GLargeMapControl());

                dir = new GDirections(map, panel);
                if (a == 0){
                to = origin + to + destin;
                dir.load(to);
                }
                else{
                map.setCenter(new GLatLng(40.525543619597684, -88.99406433105469);
                map.setZoom(16);
                }
        }
</script>

<script language="JavaScript" type="text/javascript">
        function checkform ( form )
        {
        if (form.saddr.value == "") {
        alert( "Please enter your ZIP code or Address." );
        form.saddr.focus();
        return false;
        }
        if (form.saddr.value != "") {
        destination(saddr, 0);
                return false ;
        }
        return false ;
        }
</script>

<form action="map.html" method="get" onsubmit="return
checkform(this);">
<p><label for="saddr">Enter Your Address or ZIP Code</label>
<input type="text" name="saddr" id="saddr" value="" />
<input type="submit" value="Go" />
</form>


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ralph Ames  
View profile
 More options Aug 20, 4:48 am
From: Ralph Ames <ralph.a...@gmail.com>
Date: Wed, 20 Aug 2008 02:48:49 +0300
Local: Wed, Aug 20 2008 4:48 am
Subject: RE: Trouble updating map/directions to reflect user input
Try Mike's tutorial

http://econym.googlepages.com/index.htm

Ralph


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rossko  
View profile
 More options Aug 20, 4:55 am
From: Rossko <ros...@culzean.clara.co.uk>
Date: Tue, 19 Aug 2008 16:55:41 -0700 (PDT)
Local: Wed, Aug 20 2008 4:55 am
Subject: Re: Trouble updating map/directions to reflect user input
Got some bracket mismatching here -

>                 map.setCenter(new GLatLng(40.525543619597684, -88.99406433105469);

cheers, Ross K

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
geocodezip@gmail.com  
View profile
 More options Aug 20, 5:03 am
From: "geocode...@gmail.com" <geocode...@gmail.com>
Date: Tue, 19 Aug 2008 17:03:40 -0700 (PDT)
Local: Wed, Aug 20 2008 5:03 am
Subject: Re: Trouble updating map/directions to reflect user input
On Aug 19, 4:55 pm, Rossko <ros...@culzean.clara.co.uk> wrote:
> Got some bracket mismatching here -

> >                 map.setCenter(new GLatLng(40.525543619597684, -88.99406433105469);

But that is one of the paths that the OP reports is working...
Therefore the code dump is useless as it doesn't reflect the real
problem...

Link?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google