Solved

javascript google api

Posted on 2011-09-14
2
308 Views
Last Modified: 2012-05-12
Attached codes in javascript for Google API Map 2.0 is working fine.
We prefer to upgrade to Google API Map 3.0 that does not require API Key,
any ideas what we should change in order to match Google API Map 3.0?

Thanks
<%@LANGUAGE="Vbscript" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAJxYcItOgkqR8R_oLqIOOTBQBTZKV61x1v48YJEqqfLRn8l4ZShTSK_3kHakNOTnwhzJ3mFGsv0ntTw" type="text/javascript"></script>
    <script type="text/javascript">
        function initialize(from, to) {
            if (GBrowserIsCompatible()) {
                map = new GMap2(document.getElementById("map_canvas"));
                map.addControl(new GSmallMapControl());
                map.addControl(new GMapTypeControl());
                map.setCenter(new GLatLng(37.4419, -122.1419), 13);
                gdir = new GDirections(map, document.getElementById("directions"));
                GEvent.addListener(gdir, "load", onGDirectionsLoad);
                GEvent.addListener(gdir, "error", handleErrors);
                setDirections(from, to, "en_US");
            }
        }
        function setDirections(fromAddress, toAddress, locale) {
            gdir.load("from: " + fromAddress + " to: " + toAddress,
	{ "locale": locale });
        }


        function handleErrors() {
            if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS) {
                //alert("Error code: " + gdir.getStatus().code);
                document.getElementById("span_ID").innerHTML = "Invalid Address. Error code:  " + gdir.getStatus().code;
            }
            else if (gdir.getStatus().code == G_GEO_SERVER_ERROR) {
                //alert("Error code: " + gdir.getStatus().code);
                document.getElementById("span_ID").innerHTML = "Error code: " + gdir.getStatus().code;
            }
            else if (gdir.getStatus().code == G_GEO_MISSING_QUERY) {
                //alert("Error code: " + gdir.getStatus().code);
                document.getElementById("span_ID").innerHTML = "Error code: " + gdir.getStatus().code;
            }
            else if (gdir.getStatus().code == G_GEO_BAD_KEY) {
                //alert("Error code: " + gdir.getStatus().code);
                document.getElementById("span_ID").innerHTML = "Error code: " + gdir.getStatus().code;
            }
            else if (gdir.getStatus().code == G_GEO_BAD_REQUEST) {
                //alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
                document.getElementById("span_ID").innerHTML = "A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code;
            }
            else alert("An unknown error occurred.");

        }
        function onGDirectionsLoad() { }
</script>
</head>
<%
GoogleFromAddressValue="12 Main Street ave. Los Angeles, CA 90032" 
GoogleToAddressValue="100 Airport Blvd. Los Angeles, CA 90045"
%>
<body onload="initialize('<%=GoogleFromAddressValue%>','<%=GoogleToAddressValue%>')" onunload="GUnload()" >
<%Function ContactGoogle()
p="<table cellpadding=""3"" cellspacing=""2""   class=""GoogleMapMasterInfor"">"
p=p & "<tr><td colspan=""2""><h3>Vanpool Contact Information</h3></td><td colspan=""3"" align=""right""><a href=""javascript:history.go(-1)"" class=""BackButton"">Back</a>&nbsp;</td></tr>"
p=p & "<tr><td><span class=""GoogleContactTdSubject"">ID:</span></td><td>" & RefNo & "</td><td width=""15""><br></td><td><span class=""GoogleContactTdSubject"">Origin:</span></td><td>" & OriginAddress & "</td></tr>"
p=p & "<tr><td><span class=""GoogleContactTdSubject"">Name:</span></td><td>" & PersonName & "</td><td><br></td><td><br></td><td>" & OriginCity & ", " & OriginState & " " & OriginZip & "</td></tr>"
p=p & "<tr><td><span class=""GoogleContactTdSubject"">Phone:</span></td><td>" & PhoneNo  & "</td><td><br></td><td><span class=""GoogleContactTdSubject"">Destination:</td><td>" & DestinationAddress & "</td></tr>"
p=p & "<tr><td><span class=""GoogleContactTdSubject"">Email:</span></td><td>" & EmailUrl & "</td><td><br></td><td><br></td><td>" & DestinationCity & ", " & DestinationState & " " & DestinationZip & "</td></tr>"
p=p & "<tr><td><span class=""GoogleContactTdSubject"">Employer:</span></td><td>" & EmployerName & "</td><td><br></td><td><span class=""GoogleContactTdSubject"">Work Hours:</span></td><td>" & WorkHours  & "</td></tr>"
p=p & "<tr><td colspan=""5"" align=""left""><span class=""GoogleContactTdSubject"" id=""span_ID""></span><br>" 
p=p & "<div id=""map_canvas"" style=""width: 605px; height: 370px;  border: 1px solid #C0C0C0;""></div>"
p=p & "</td></tr>"
p=p & "</table>"
ContactGoogle=p
End Function
Response.write ContactGoogle()
%>
</body>
</html>

Open in new window

0
Comment
Question by:Webboy2008
2 Comments
 
LVL 14

Accepted Solution

by:
nishant joshi earned 500 total points
ID: 36538157
0
 
LVL 7

Expert Comment

by:Kishan Zunjare
ID: 36544883
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
html input 8 42
JavaScript Sort Ordering and Choice Limiting 5 23
Why is initialize not a function? 8 22
How to filter by key press ? 6 23
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question