<script language="C#" runat="server">
        
public class GeoLocation
{
    public string label;
    public double x;
    public double y;

    public GeoLocation( Map map, string label, double lat, double lon)
    {
        Projection proj = map.getProjection();
        GeoPoint pt = proj.project( lat, lon);
        this.label = label;
        this.x = pt.x;
        this.y = pt.y;
    }
}

</script>


<%

Map map = OpenMap();
    
// get the layer
Layer layer = map.getLayers().getLayerByName("Airports");
// create the SearchDef object
SearchDef searchDef = new SearchDef();

//**************************************************************************
// convert current units (miles or kilometers) to map units
double radius = map.convertDistance( 20, map.getMeasureUnits(), MeasureUnit.rmMapUnits);

GeoLocation center = new GeoLocation (map, "Redlands, CA", 34.0528, -117.1531);

searchDef.setSearchMethod( SearchDef.rmSortDistance);
searchDef.addCircle( center.x, center.y, radius, 0);
//**************************************************************************
	
Recordset rs = layer.search(searchDef); // returns Recordset object

// prints all records from the recordset
if( rs != null && rs.getRecordsCount() != 0)
{
    int recCount = rs.getRecordsCount();
    int fieldCount = rs.getFields().getFieldCount();

    Response.Write( "<table border=1 cellspacing=0 cellpadding=2>\n");
    Response.Write( "<tr bgcolor='#DDDDDD'>\n");

    for (int i = 0; i < fieldCount; i++)
        Response.Write("<th>" + rs.getFields().getFieldName(i) + "</th>");

    Response.Write("</tr>\n");

    for (int i = 0; i < recCount; i++)
    {
        rs.move(i);
        Response.Write("<tr>");

        for (int j = 0; j < fieldCount; j++)
        {
            string value = rs.getAsString(j);

            if (value == "")
                value = " ";

            Response.Write("<td>" + value + "</td>");
        }
        
        Response.Write("</tr>\n");
    }
	
    Response.Write("</table>\n");
}

%>