Solved

javascript google api

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now