[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 294
  • Last Modified:

classic, javascript asp google

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
Webboy2008
Asked:
Webboy2008
1 Solution
 
sammySeltzerCommented:
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
 
Webboy2008Author Commented:
sammySeltzer: The codes you posted does not work. It doesn't show the map and direction at all.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now