RouteMAP IMS 3.0 Java API

Working with Layers

There are four main objects that deal with map layers:
1) LayerList
   The LayerList object represents the collection of geographical data layers defined for a Map.
2) Layer
   The Layer object represents a geo-referenced data layer on a Map.
3) Renderer
   The Renderer object represents a way of symbolizing features of a Layer by drawing a Symbol for each unique data value or range of values.
4) RendererItem
   The RendererItem object provides a way to apply a Symbol to a feature using expressions over the feature attribute information.

This example shows how to find records using an SQL-like expression:


// get layer
Layer layer = map.getLayers().getLayerByName("Cities");
SearchDef searchDef = new SearchDef();	

// select locations by the expression (see Appendix A)
searchDef.setExpression( "Capital = \"Y\"");
//specify the fields you want to retrieve (all fields by default)
searchDef.setFields( "Area Name, State, County");

// returns the Recordset object
Recordset rs = layer.search( searchDef);

The following example will display only the selected records on the map:


// get layer
Layer layer = map.getLayers().getLayerByName("Cities");
Renderer renderer = layer.getRenderer();

// add new RendererItem
RendererItem ritem = renderer.addItem();

// select locations by the expression (see Appendix A)
ritem.setExpr( "Capital = \"Y\"");

// set font attributes
TextFont font = ritem.getFont();
Color color = new Color(0x0000FF); //blue
font.setColor( color);
font.setSize( 10);
font.setBold(true);
ritem.setFont( font);

ritem.setFontMask( RendererItem.FONT_COLOR | RendererItem.FONT_SIZE | RendererItem.FONT_BOLD);

// set symbol attributes
Symbol symbol = ritem.getSymbol();
symbol.setSymbolStyle("std:circle"); // see Appendix D
color = new Color( 0xFF0000); //red
symbol.setColor( Symbol.SYMBOL_COLOR, color);
symbol.setSize( 16);

ritem.setSymbol( symbol);
ritem.setSymbolMask( RendererItem.SYMBOL_COLOR1 | RendererItem.SYMBOL_STYLE | RendererItem.SYMBOL_SIZE);
ritem.setMinMaxZoomLevel( RendererItem.MIN_ZOOM_LEVEL, RendererItem.MAX_ZOOM_LEVEL);

// add new RendererItem
RendererItem ritem2 =  renderer.addItem();

// select all records except the records specified above
ritem2.setExpr( "Capital <> \"Y\""); //see Appendix A

// hide symbols and labels
Symbol symbol2 = ritem2.getSymbol();
symbol2.setSymbolStyle("std:null"); //see Appendix D

ritem2.setLabelVisible( false);
ritem2.setSymbolMask( RendererItem.SYMBOL_STYLE);
ritem2.setMinMaxZoomLevel( RendererItem.MIN_ZOOM_LEVEL, RendererItem.MAX_ZOOM_LEVEL);

This example shows another way to do the same thing.
1) Make all the symbols of the layer invisible: start Map Author, open map, select layer, then Edit -> Layer Properties -> Multiple -> Select -> All -> Symbol/Line/Fill -> uncheck Visible;
2) Use this code to display the specified locations:


// get layer
Layer layer = map.getLayers().getLayerByName("Cities");
Renderer renderer = layer.getRenderer();

// add new RendererItem
RendererItem ritem = renderer.addItem();

// select locations by the expression (see Appendix A)
ritem.setExpr( "Capital = \"Y\"");

// set font attributes
TextFont font = ritem.getFont();
Color color = new Color(0x0000FF); //blue
font.setColor( color);
font.setSize( 10);
font.setBold(true);
ritem.setFont( font);

ritem.setFontMask( RendererItem.FONT_COLOR | RendererItem.FONT_SIZE | RendererItem.FONT_BOLD);

// set symbol attributes
Symbol symbol = ritem.getSymbol();
symbol.setSymbolStyle("std:circle"); //see Appendix D
color = new Color( 0xFF0000); //red
symbol.setColor( Symbol.SYMBOL_COLOR, color);
symbol.setSize( 16);

ritem.setSymbol( symbol);
ritem.setSymbolMask( RendererItem.SYMBOL_COLOR1 | RendererItem.SYMBOL_STYLE | RendererItem.SYMBOL_SIZE);
ritem.setMinMaxZoomLevel( RendererItem.MIN_ZOOM_LEVEL, RendererItem.MAX_ZOOM_LEVEL);

The result should look like this:


Dynamic Layers

RouteMAP IMS allows adding database layers dynamically. There are two types of dynamic data sources: external and built-in. For more information about the built-in data source feature see Appendix C: Built-in data source.

Here is a brief explanation of how to use the external data source feature. The RouteMAP IMS 3.0 supports the following external databases: dBASE, Microsoft Access, SQL Server, and Oracle.


A) Installation Instructions:

  1. Build the External Data Source "ExtDS.dll" or use the one from C:\Program Files\RouteMAP IMS\SDK\EDS\EXTDS, for more information see Appendix B: External data sources
  2. Shutdown RouteMAP IMS 3.0
  3. Copy "ExtDS.dll" into your RouteMAP IMS 3.0 Server Manager Directory (e.g. "C:\Program Files\ESRI\RouteMAP IMS\Server Manager")
  4. Add the following text to "imsds.ini" file in the RouteMAP IMS 3.0 Server Manager Directory
    
    [Data Source Name]
    DsDllPath=ExtDS.dll
    
    
  5. Restart RouteMAP IMS 3.0
  6. Installation is now complete, see the section 'B' for details on how to use an External Data Source


B) Usage

  1. you can add the following lines right before returning from the OpenMap function:
    
    ParameterList ds = new ParameterList();
    ds.add("DataSource", "Data Source Name" );    
        
    // Select the Fields from your database that you would like displayed during a 
    // Find Nearest. The Label/Name, Lat, Long fields are required. The rest are optional.
    String strSQL = "select Name, latitude, longitude,Address,City,State,Zip from tableName";
    
    
  2. For a *.dbf file, add the following under "var strSQL = ..."
        
    // Note: the actual name of the dbf file is in the SQL Query
    // IE. If you have the file "c:\my_database\database.dbf" Your
    // SQL Query would look like "select name, latitude, longitude from database"
    //  and the "FilePath" would be "c:\\my_database\\"
    
    ds.add("DataSourceType","File");
    ds.add("ODBCDriver","Microsoft dBASE Driver (*.dbf)");
    ds.add("FilePath","d:\\my_database\\");
    
    
  3. For a *.mdb file, add the following
        
    ds.add("DataSourceType","File");
    ds.add("ODBCDriver","Microsoft Access Driver (*.mdb)");
    ds.add("FilePath","c:\\my_database\\database.mdb");
    
    
  4. For access to an SQL Server
        
    ds.add("DataSourceType","SQL");
    ds.add("ODBCDSN","Your ODBC Data Source Name");
    ds.add("ODBCUsername","Username");
    ds.add("ODBCPassword","");
    
    
  5. Continue to add the following
    
    ds.add("SQLStatement",strSQL);
    ds.add("IconFile","c:\\my_icons\\icon1.bmp");
    ds.add("LabelField","Name");
    ds.add("LatField","latitude");
    ds.add("LonField","longitude");
    
    
  6. The following parameters are optional
        
    ds.add("UrlField","");
    ds.add("IconSize","8"); // Default is 10    
    
    
  7. Continue to add the following
        
    map.getLayers().addDynamicLayer(ds);
    

After this you should see your database records on the map.