Solved

classic, javascript asp google

Posted on 2011-09-02
2
268 Views
Last Modified: 2012-05-12
The attached suppose to get two from/to address that already in the codes and run the google map direction and show the page on the webpage.
for some reasons, it does not do anything and want experts helps.

Thanks
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%
function queryString(name)
{
	var value = new String (Request.Form(name));
	return convertToString(value);
}
	
function convertToString(name)
{
	var value = new String (name);
    	var fieldValue = value.toLowerCase();
	if (fieldValue == "null" || 
		fieldValue == "undefined" || 
		fieldValue == "undefine" ||
		fieldValue == "object")
		return "";
   	else return value;
}

function formatPhone(phone)
{
	try {
	     var phone = new String (phone);
		 if (phone != "")
		 {
			var code = phone.substring(0, 3);
			return "(" + code + ") " + phone.substring(3, 6) + "-" + phone.substring(6); 
		 }  
	} catch (e) { return phone; }
}
  
function formatTitleCase(word)
{
    try {
	  	var word = new String (word);
	  	if (word != "")
	  	{
	  		var letter = word.substring(0, 1).toUpperCase();
			return letter + word.substring(1, word.length).toLowerCase();  
	  	}
	} catch (e) { return word; }
}


function getDestinationAddress(val)
{
	var pos = 0;	
	var address = new String (val);
        if (address.length > 10)
	{
		var pos = address.indexOf('AAA');
                return address.substring(pos + 3);
	}
	return val;
        
}

function getOriginAddress(val)
{
	var address = new String (val);
        if (address.length > 10)
	{
		var pos = address.indexOf('AAA');
                return address.substring(0, pos);
	}
return val;
}


%>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>My Google API Application</title>
     <script type="text/javascript" src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAJxYcItOgkqR8R_oLqIOOTBQBTZKV61x1v48YJEqqfLRn8l4ZShTSK_3kHakNOTnwhzJ3mFGsv0ntTw"></script>
  <script type="text/javascript">

      var map;
      var gdir;
      var geocoder = null;
      var addressMarker;


      function initialize(from, to) {
          if (GBrowserIsCompatible()) {
              map = new GMap2(document.getElementById("map_canvas"));
              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);
          else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
              alert("Error code: " + gdir.getStatus().code);
          else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
              alert("Error code: " + gdir.getStatus().code);
          else if (gdir.getStatus().code == G_GEO_BAD_KEY)
              alert("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);
          else alert("An unknown error occurred.");

      }

      function onGDirectionsLoad() { }



    </script>
  
  </head>
  <body onunload="GUnload()">
<div id="contact"> 
<div class="contactInfo">
<p><strong>Origin:</strong><span id="origin"> <%="100 Main Street"%>&nbsp;<%="Los Angeles"%>, CA&nbsp; <%="90032"%></span></p>
<p><strong>Destination:</strong><span id="destination"> <%="100 Airport Blvd"%>&nbsp;<%="Los Angeles"%>, CA&nbsp; <%="90045"%></span></p>
</div>
<%
	  
	 
%>
<div class="clear"></div>
<div id="map_canvas"></div>
<div id="direction">
<div class="clear"></div>

</div>
</div>


<script type="text/javascript">

    try {
        $(document).ready(function () {
            var points = "1000";
            var fromAddress = document.getElementById("origin").innerHTML;
            var toAddress = document.getElementById("destination").innerHTML;
            document.getElementById("origin").innerHTML = " " + points;
            initialize(fromAddress, toAddress);

           
        });

    } catch (e) { }

</script>

  </body>
 </html>

Open in new window

0
Comment
Question by:Webboy2008
2 Comments
 
LVL 28

Accepted Solution

by:
sammySeltzer earned 500 total points
ID: 36475629
I think you confused Javascript with VBScript

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<script>
function queryString(name)
{
	var value = new String (Request.Form(name));
	return convertToString(value);
}

function convertToString(name)
{
	var value = new String (name);
    	var fieldValue = value.toLowerCase();
	if (fieldValue == "null" ||
		fieldValue == "undefined" ||
		fieldValue == "undefine" ||
		fieldValue == "object")
		return "";
   	else return value;
}

function formatPhone(phone)
{
	try {
	     var phone = new String (phone);
		 if (phone != "")
		 {
			var code = phone.substring(0, 3);
			return "(" + code + ") " + phone.substring(3, 6) + "-" + phone.substring(6);
		 }
	} catch (e) { return phone; }
}

function formatTitleCase(word)
{
    try {
	  	var word = new String (word);
	  	if (word != "")
	  	{
	  		var letter = word.substring(0, 1).toUpperCase();
			return letter + word.substring(1, word.length).toLowerCase();
	  	}
	} catch (e) { return word; }
}


function getDestinationAddress(val)
{
	var pos = 0;
	var address = new String (val);
        if (address.length > 10)
	{
		var pos = address.indexOf('AAA');
                return address.substring(pos + 3);
	}
	return val;

}

function getOriginAddress(val)
{
	var address = new String (val);
        if (address.length > 10)
	{
		var pos = address.indexOf('AAA');
                return address.substring(0, pos);
	}
return val;
}

</script>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>My Google API Application</title>
     <script type="text/javascript" src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAJxYcItOgkqR8R_oLqIOOTBQBTZKV61x1v48YJEqqfLRn8l4ZShTSK_3kHakNOTnwhzJ3mFGsv0ntTw"></script>
  <script type="text/javascript">

      var map;
      var gdir;
      var geocoder = null;
      var addressMarker;


      function initialize(from, to) {
          if (GBrowserIsCompatible()) {
              map = new GMap2(document.getElementById("map_canvas"));
              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);
          else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
              alert("Error code: " + gdir.getStatus().code);
          else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
              alert("Error code: " + gdir.getStatus().code);
          else if (gdir.getStatus().code == G_GEO_BAD_KEY)
              alert("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);
          else alert("An unknown error occurred.");

      }

      function onGDirectionsLoad() { }



    </script>

  </head>
  <body onunload="GUnload()">
<div id="contact">
<div class="contactInfo">
<p><strong>Origin:</strong><span id="origin"> <%="100 Main Street"%>&nbsp;<%="Los Angeles"%>, CA&nbsp; <%="90032"%></span></p>
<p><strong>Destination:</strong><span id="destination"> <%="100 Airport Blvd"%>&nbsp;<%="Los Angeles"%>, CA&nbsp; <%="90045"%></span></p>
</div>
<%


%>
<div class="clear"></div>
<div id="map_canvas"></div>
<div id="direction">
<div class="clear"></div>

</div>
</div>


<script type="text/javascript">

    try {
        $(document).ready(function () {
            var points = "1000";
            var fromAddress = document.getElementById("origin").innerHTML;
            var toAddress = document.getElementById("destination").innerHTML;
            document.getElementById("origin").innerHTML = " " + points;
            initialize(fromAddress, toAddress);


        });

    } catch (e) { }

</script>

  </body>
 </html>

Open in new window

0
 

Author Comment

by:Webboy2008
ID: 36475672
sammySeltzer: The codes you posted does not work. It doesn't show the map and direction at all.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

863 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

24 Experts available now in Live!

Get 1:1 Help Now