<%@ Language=VBScript %> <% ' ' This ASP program shows how to use the AnnotatedEarth .NET Service to request information ' about locations near a entered latitude/longitude. Using the Location.asmx service at ' http://www.annotatedearth.com/service/Location.asmx, a client can pass in (using a standard ' URL) a request for information. The service will respond back; in this example, with a list ' of locations ' ' Please visit http://www.annotatedearth.com and look in the developers section for more information ' ' -------------------------------------------------------------------------------------------------- ' Copyright 2003, AnnotatedEarth ' ' -------------------------------------------------------------------------------------------------- ' Version 1 - Initial Development (ward) ' ' -------------------------------------------------------------------------------------------------- %> NearMe - AnnotatedEarth ASP/VBScript Example <% sLongitude = Request.Form("efLongitude") sLatitude = Request.Form("efLatitude") sDistance = Request.Form("efDistance") ' ' Set up defaults ' if Len(sLongitude) = 0 then sLongitude = "-122.35" if Len(sLatitude) = 0 then sLatitude = "47.62106" if Len(sDistance) = 0 then sDistance = "100" %>

Example of using AnnotatedEarth to get Locations near a Location.  See http://www.annotatedearth.com for more details

Latitude: (Example:47.62106 )
Longitude: (Example: -122.35 )
Distance:
 
<% if Len(sLongitude) > 0 and Len(sLatitude) > 0 and Len(sDistance) > 0 then ' ' This call is in feet - but we really want miles here, so convert ' sDistance = CStr(sDistance * 5280) ' ' XMLHTTP will be used to actually request locations (in a ' XML document) from the AE .NET service ' set xmlHTTP = Server.CreateObject("Microsoft.XMLHTTP") ' ' Build our URL. There's some more complex "Find" calls, ' but we're just trying to do simple here... ' sURL = "http://www.annotatedearth.com/AELocationService/Location.asmx/FindNear?userid=15&password=guest&system=nearme_example&latitude=" + sLatitude + "&longitude=" + sLongitude + "&feet=" + sDistance + "&groupid=1" Response.Write(sURL) xmlHTTP.open "GET", sURL , false xmlHTTP.send ' ' Un-comment to see the XML ' 'Response.Write( xmlHTTP.responseText) ' ' Get the XML document ' Set xmlDom = xmlhttp.ResponseXml ' ' Try to get the root node. NOTE: Really need ' some error checking here, but trying to do simply, so ' skipping here ' Set root = xmlDom.selectSingleNode( "ae") If Not root Is Nothing Then ' ' Should get a list of Locations back. Iterate though them, ' building the table (ahh, ASP.NET would be so much NICER here! :) ' Set list = root.selectNodes("locations/location") If Not list Is Nothing and list.length > 0 Then %>

 

<% For i = 0 To list.length - 1 %> <% Next %>
Title Distance Latitude Longitude
<%=list.Item(i).selectSingleNode("title").nodeTypedValue%>  <%=CInt(list.Item(i).selectSingleNode("distance").nodeTypedValue/5280)%> miles (<%=list.Item(i).selectSingleNode("distance").nodeTypedValue%> feet) <%=list.Item(i).selectSingleNode("latitude").nodeTypedValue%>  <%=list.Item(i).selectSingleNode("longitude").nodeTypedValue%> 
<% else Response.Write("No locations near that point") End If end if end if %>