RouteMAP IMS 3.0 .NET API

Finding Locations

RouteMAP IMS allows you to find several types of locations, depending on the map data. There are two special interfaces that provide this functionality: the FinderList and the Finder interfaces.

For example, the North American data set supports the following types of locations:
1) US Address;
2) Canadian Address;
3) US Streets Intersection;
4) Canadian Streets Intersection;
5) US ZIP Code;
6) US ZIP3 Code;
7) Canadian Postal Code;
8) US City;
9) Canadian City;
10) US County;
11) US Area Code;
12) Latitude/Longitude - location specified by its coordinates.

Each location type has a corresponding finder, and each finder has one or more corresponding fields. You can find out what types of locations the map supports by using this code JScript / VBScript (also see sample output: USA map / North American map). Now when you know the type of location and all the corresponding fields, you can easily find the location. For example, if you're trying to find US address, you know that the US address finder number is 0 and there are four fields: Address, ZIP, City and State. Follow the steps below:


// get the FinderList object
var Finders = Map.getFinders();
// get the US address finder by number
var Finder = Finders.getFinder( 0);

Finder.setFieldValueByName("Address", "1235 Colton Ave");
Finder.setFieldValueByName("ZIP", "");   // you can specify either ZIP, or City and State
Finder.setFieldValueByName("City", "Redlands");
Finder.setFieldValueByName("State", "CA");

var rs = Finder.find(); // this method returns the Recordset object


if( rs != null)
{
    var i=1;
	
    do
    {
        Response.Write( "<b>Location #" + i++ + "</b><br>");
		
        // see the find() method for details
        Response.Write( "name: " + rs.getAsStringByName( "NAME") + "<br>");
        Response.Write( "score: " + rs.getAsIntByName("SCORE") + "<br>");
        Response.Write( "x: " + rs.getAsDoubleByName( "X") + "<br>");
        Response.Write( "y: " + rs.getAsDoubleByName( "Y") + "<br>");
        Response.Write( "latitude: " + rs.getAsDoubleByName( "LAT") + "<br>");
        Response.Write( "longitude: " + rs.getAsDoubleByName( "LONG") + "<br>");		
    } while( rs.moveNext())
}	


VBScript version

Output:

Location #1
name: 1235 W Colton Ave, Redlands, CA 92374
score: 99
x: -8106.836740446592
y: 2356.1476224139105
latitude: 34.06285454545455
longitude: -117.20063636363636
Location #2
name: 1235 E Colton Ave, Redlands, CA 92374
score: 99
x: -8104.249760516279
y: 2356.1451071198603
latitude: 34.06281818181818
longitude: -117.16323636363637

To find a different type of location, first identify the number of the finder to use and then fill in all the required fields for that specific finder.

Advanced version of the findLocation function JScript / VBScript.


You can also identify a point on the map using the identify method of the Map interface. This method tries to find a feature on the map starting from the top layer.
See the following example:


<%
    var Map = OpenMap();

    var idrs = null;
    var idr = null;
    
    if( Request("map.x").Count > 0 && Request("map.y").Count > 0)
        idr = Map.identify( parseInt(Request("map.x")), parseInt(Request("map.y")));

    if( idr != null)
        idrs = idr.getRecordset();
%>

<% if( idrs != null) {%>

<br>Layer: <%= Map.getLayers().getLayer(idr.getLayerNumber()).getName() %><br>

<table>
<tr>

<%

    var idFields = idrs.getFields();

    for( var i = 0; i < idFields.getFieldCount(); i++)
    {
        if( idFields.getFieldType(i) != rmShape)
            Response.Write("<th bgcolor='#C0C0C0'>" + idFields.getFieldName(i) + "</th>");
    }

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

    var val;
    
    while( !idrs.IsEOF())
    {
        Response.Write("<tr bgcolor='#ECECEC'>");

        for( i = 0; i < idFields.getFieldCount(); i++)
        {
            if( idFields.getFieldType(i) != rmShape)
            {
                val = idrs.getAsString(i);
                Response.Write("<td>" + val + "</td>");
            }
        }
        
        Response.Write("</tr>\n");
        idrs.moveNext();
        
    }
%>

</table>

<% } //end if  %>

<form>
<input type="image" name="map" src="<%= Map.getMapImageURL(Map.getImageWidth(), Map.getImageHeight(), rmDefault)%>"
width="<%=Map.getImageWidth()%>" height="<%=Map.getImageHeight()%>">
</form>

VBScript version

Start this example and try to click on the map image.