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 VB.NET / C# / JScript.NET (also see sample output: USA map / North American map). 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:

Dim Finders, Finder, rs

' get the FinderList object
Finders = map.getFinders
' get the US address finder by number
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")

rs = Finder.find  ' this method returns the Recordset object

If Not rs Is Nothing Then

    Dim i = 1
	
    Do

        Response.Write( "<b>Location #" & i & "</b><br>")
		
        i = i + 1
		
        ' 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>")

    Loop While rs.moveNext
	
End If


C# | JScript.NET

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 VB.NET / C# / JScript.NET.


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:


<%

    Dim map: map = OpenMap()

    Dim idr, idrs
    idrs = Nothing
    
    idr = map.identify(CInt( Request("map.x")), CInt( Request("map.y")))

    If Not idr Is Nothing Then
        idrs = idr.getRecordset()
    End If
%>

<% If Not idrs Is Nothing Then %>

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

<table>
<tr>

<%

    Dim idFields
    Dim i As Long
    idFields = idrs.getFields()

    For i = 0 To idFields.getFieldCount()-1 Step 1
        If idFields.getFieldType(i) <> FieldType.rmShape Then
            Response.Write("<th bgcolor='#C0C0C0'>" & idFields.getFieldName(i) & "</th>")
        End If
    Next

    Response.Write("</tr>" & vbCrLf)
    idrs.moveFirst()

    Dim val

    While Not idrs.IsEOF()
        Response.Write("<tr bgcolor='#ECECEC'>")

        For i = 0 To idFields.getFieldCount()-1 Step 1
            If idFields.getFieldType(i) <> FieldType.rmShape Then
                val = idrs.getAsString(i)
                Response.Write("<td>" & val & "</td>")
            End If
        Next
        Response.Write("</tr>" & vbCrLf)
        idrs.moveNext()
    End While

%>

</table>

<% End If  %>

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

C# / JScript.NET

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