Solved

javascript google api

Posted on 2011-09-14
2
307 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…

776 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