culdesac
10-26-2009, 10:13 AM
Hi,
I found that it is possible to call javascript from VBScript from this link http://www.webdeveloper.com/forum/archive/index.php/t-49920.html
Here is the way i tried...and could not succeed...
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps Reverse Geocoding</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var geocoder;
var map;
var infowindow = new google.maps.InfoWindow();
var marker;
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(0, 0);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: 'roadmap'
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
function codeLatLng(X,Y) {
var latlng = new google.maps.LatLng(X, Y);
if (geocoder) {
geocoder.geocode({'latLng': latlng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
map.set_zoom(11);
marker = new google.maps.Marker({
position: latlng,
map: map
});
infowindow.set_content(results[0].formatted_address);
infowindow.open(map, marker);
} else {
alert("No results found");
}
} else {
alert("Geocoder failed due to: " + status);
}
});
}
}
</script>
</head>
<body style="margin:0px; padding:0px;" onload="initialize()">
<form name="msisdnform" action="/tracking/RGusinggoogle.asp" method="post">
<table width="350" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#EEEEEE">
<tr>
<td align="center">
<table class="panel" style="margin:5px" border="0" cellspacing="0" cellpadding="0" width="340">
<tr>
<td>
<table border="0" cellspacing="10" cellpadding="0" width="100%">
<tr>
<td align="left" width="70" nowrap>MSISDN: </td><td><input class="geocode" type="text" name="msisdn" size="18" onfocus="this.select();"></td>
</tr>
<tr>
<td></td><td align="left" width="70" nowrap><input type="submit" value="Locate"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<%
dim msisdn, xmlapi, xmlHttp,xmlDOM
'CONSTRUCT XML POST MESSAGE
msisdn= Request.Form("msisdn")
If msisdn <> "" then
xmlapi= "<?xml version=""1.0"" encoding=""UTF-8""?><svc_init ver=""3.0.0""><hdr ver=""3.0.0""><client><id>qq</id><pwd>pp</pwd><requestmode type=""ACTIVE""/></client></hdr><rgeor version=""3.0.0""><msids><msid type=""MSISDN"" enc=""ASC"">" &MSISDN& "</msid></msids><maxcandidates>1</maxcandidates></rgeor></svc_init>"
'POST REQUEST TO LOCATION SERVER
set xmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
xmlHttp.open"POST", "http://x.x.x.x/yyyy", false
xmlHttp.send(xmlapi)
RSSXML = xmlHttp.ResponseText
Set xmlDOM = Server.CreateObject("MSXML2.DomDocument.3.0")
xmlDOM.async = False
xmlDOM.validateOnParse = False
xmlDom.resolveExternals = False
If not xmlDOM.LoadXml(RSSXML) Then
ErrorMessage = "Can not load XML:" & vbCRLF & xmlDOM.parseError.reason & vbCRLF & ErrorMessage
End If
Set xmlHttp = Nothing ' clear HTTP object
Set LON = xmlDOM.getElementsByTagName("X")
Set LAT = xmlDOM.getElementsByTagName("Y")
X = LON.Item(0).Text
Y = LAT.Item(0).Text
'Response.Write (X) & vbCRLF
'Response.Write (Y) & vbCRLF
'Response.End
Am getting X and Y values here if i uncomment the above lines
Function CallGoogleJS(X,Y)
codeLatLng(X,Y)
End Function
CallGoogleJS(X,Y)
Set xmlDOM = Nothing ' clear XML
Set xmlhttp = nothing
end if
%>
</body>
</html>
Here am getting error as
Cannot use parentheses when calling a Sub
codeLatLng(X,Y)
---------------^
How to pass this X and Y values to Javascript which will display the map ?
I found that it is possible to call javascript from VBScript from this link http://www.webdeveloper.com/forum/archive/index.php/t-49920.html
Here is the way i tried...and could not succeed...
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps Reverse Geocoding</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var geocoder;
var map;
var infowindow = new google.maps.InfoWindow();
var marker;
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(0, 0);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: 'roadmap'
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
function codeLatLng(X,Y) {
var latlng = new google.maps.LatLng(X, Y);
if (geocoder) {
geocoder.geocode({'latLng': latlng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
map.set_zoom(11);
marker = new google.maps.Marker({
position: latlng,
map: map
});
infowindow.set_content(results[0].formatted_address);
infowindow.open(map, marker);
} else {
alert("No results found");
}
} else {
alert("Geocoder failed due to: " + status);
}
});
}
}
</script>
</head>
<body style="margin:0px; padding:0px;" onload="initialize()">
<form name="msisdnform" action="/tracking/RGusinggoogle.asp" method="post">
<table width="350" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#EEEEEE">
<tr>
<td align="center">
<table class="panel" style="margin:5px" border="0" cellspacing="0" cellpadding="0" width="340">
<tr>
<td>
<table border="0" cellspacing="10" cellpadding="0" width="100%">
<tr>
<td align="left" width="70" nowrap>MSISDN: </td><td><input class="geocode" type="text" name="msisdn" size="18" onfocus="this.select();"></td>
</tr>
<tr>
<td></td><td align="left" width="70" nowrap><input type="submit" value="Locate"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<%
dim msisdn, xmlapi, xmlHttp,xmlDOM
'CONSTRUCT XML POST MESSAGE
msisdn= Request.Form("msisdn")
If msisdn <> "" then
xmlapi= "<?xml version=""1.0"" encoding=""UTF-8""?><svc_init ver=""3.0.0""><hdr ver=""3.0.0""><client><id>qq</id><pwd>pp</pwd><requestmode type=""ACTIVE""/></client></hdr><rgeor version=""3.0.0""><msids><msid type=""MSISDN"" enc=""ASC"">" &MSISDN& "</msid></msids><maxcandidates>1</maxcandidates></rgeor></svc_init>"
'POST REQUEST TO LOCATION SERVER
set xmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
xmlHttp.open"POST", "http://x.x.x.x/yyyy", false
xmlHttp.send(xmlapi)
RSSXML = xmlHttp.ResponseText
Set xmlDOM = Server.CreateObject("MSXML2.DomDocument.3.0")
xmlDOM.async = False
xmlDOM.validateOnParse = False
xmlDom.resolveExternals = False
If not xmlDOM.LoadXml(RSSXML) Then
ErrorMessage = "Can not load XML:" & vbCRLF & xmlDOM.parseError.reason & vbCRLF & ErrorMessage
End If
Set xmlHttp = Nothing ' clear HTTP object
Set LON = xmlDOM.getElementsByTagName("X")
Set LAT = xmlDOM.getElementsByTagName("Y")
X = LON.Item(0).Text
Y = LAT.Item(0).Text
'Response.Write (X) & vbCRLF
'Response.Write (Y) & vbCRLF
'Response.End
Am getting X and Y values here if i uncomment the above lines
Function CallGoogleJS(X,Y)
codeLatLng(X,Y)
End Function
CallGoogleJS(X,Y)
Set xmlDOM = Nothing ' clear XML
Set xmlhttp = nothing
end if
%>
</body>
</html>
Here am getting error as
Cannot use parentheses when calling a Sub
codeLatLng(X,Y)
---------------^
How to pass this X and Y values to Javascript which will display the map ?