473,396 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Google Map

Hi: I try to follow the instruction using google map in javascript.
Script some times work fine but when i put the values in Your Address
Textbox it wont shows the directions. Other than that if i put the
city state and zip it works. Can any one please tell me what i make
mistake in the script?

Thanks.

SCRIPT

----------

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/
>
<title>Google Maps JavaScript API Example</title>
<script src="http://maps.google.com/maps?
file=api&amp;v=2&amp;key=ABQIAAAAWjFPi89UG-
Rb3Who5FDkhRTvPROrRtr9Yene2irq6Hi48Jt9RRRSOu-klp9Mhib3eBbvZWu0LxSZjQ"
type="text/javascript"></script>
<script type="text/javascript">

//<![CDATA[

var map;

function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
}
}
//]]>

function buttonOnClick()
{
var fromaddress ;
var myaddress;
var query;
// build the callers address string
fromaddress = document.getElementById("youraddress").value + ',' +
document.getElementById("yourcity").value +',' +
document.getElementById("yourstate").value +',' +
document.getElementById("yourazip").value ;
myaddress = '1521 Straight Path, Wyandanch, NY 11798';
query = fromaddress + " to " + myaddress;
document.getElementById("query").innerHTML = query;
var dirPanel = document.getElementById("directions1")
directions = new GDirections(map, dirPanel ); // make a direction
thing
directions.load(query); // make the route

}

</script>
<body onload='load();' onunload="GUnload()">
<br>
<table>
<tr>
<td>Your Address:</td>
<td><input type='text' id='youraddress'></td>
</tr>
<tr>
<td>Your City:</td>
<td><input type='text' id='yourcity'></td>
</tr>
<tr>
<td>Your State:</td>
<td><input type='text' size='2' id='yourstate'></td>
</tr>
<tr>
<td>Your Zip Code:</td>
<td><input type='text' size='5' id='yourazip'></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type='button' value='Display Route'
onclick='buttonOnClick();'></td>
</tr>
</table>
<center><a href="index.html">Back to Home Page</a></center>
<br>
<center>
<div id="map" style="width: 500px; height: 300px" ></div>
<div id="query" &nbsp; </div>
</center>
<div id="directions1" style="width: 500px; height: 300px" ></div>
</body>
</html>

Jun 27 '08 #1
2 1602
<co*********@gmail.comwrote in message
news:3d**********************************@a23g2000 hsc.googlegroups.com...
Hi: I try to follow the instruction using google map in javascript.
Script some times work fine but when i put the values in Your Address
Textbox it wont shows the directions. Other than that if i put the
city state and zip it works. Can any one please tell me what i make
mistake in the script?
Are you also "Comacho"? Or are you asking a new question?

What instructions did you follow? Post the URL.

Google Maps needs more than just a street address which
is why it works when you put in a city, state, and zip.

The least you need is a zip code (or city and state).

Why does your initial map show Palo Alto, California which
is unrelated to your address in New York?
Jun 27 '08 #2
McKirahan wrote:
Why does your initial map show Palo Alto, California which
is unrelated to your address in New York?
Because the route to the end point in New York is only computed when the
buttonOnClick() method containing this address is executed (through the
`onclick' attribute of the `input' element below).

Palo Alto, CA, was the location of the first Google offices, which therefore
the Google Maps API example code sets the map center to. See the
GMap2::setCenter() call in load(), called through the `onload' attribute of
the `body' element.

(On a side note, it is good to see that the example code uses the standards
compliant approach.)
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: fuzzyman | last post by:
I've hacked together a 'GoogleCacheServer'. It is based on SimpleHTTPServer. Run the following script (hopefully google groups won't mangle the indentation) and set your browser proxy settings to...
3
by: Alastair | last post by:
Hello guys, I've been building a search facility for an intranet site I'm part of developing and we've been building a search engine using Index Server. It mostly works, however there have been...
25
by: Tor Erik Sønvisen | last post by:
Hi I need to browse the socket-module source-code. I believe it's contained in the file socketmodule.c, but I can't locate this file... Where should I look? regards tores
9
by: Ray5531 | last post by:
Sorry if this is irrelevant to this website,but I didn't find a better place to ask this question.I sent an email to google as well which I didn't recieve the answer.I'm creating a website and...
2
by: gen_tricomi | last post by:
THE IMPORTANCE OF MAKING THE GOOGLE INDEX DOWNLOADABLE I write here to make a request on behalf of all the programmers on earth who have been or are intending to use the Google web search API...
1
by: xahlee | last post by:
Elisp Tutorial: Make Google Earth Xah Lee, 2006-12 This page shows a example of writing a emacs lisp function that creates a Google Earth file, and creates a link to the file, as well a link...
9
by: maheswaran | last post by:
Hi all, I developed one application. From that application i created dynamic pages contact us , about us...(like joomla, but application is not in joomla)... These all are comes from database.In...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.