RouteMAP IMS 3.0 .NET API

Labeling and Drawing

There is an extensive set of the methods that allow drawing several types of symbols or simple figures such as callouts, circles, ellipses, rectangles, or polygons on the map.

There are three types of objects: callouts, ellipses, and polygons.

The basic steps to add any symbol to the map are:
1) Create and initialize the object that represents your figure or symbol;
2) Get the enumeration of the objects of type using the CosmeticLayer interface;
3) Get or create the Symbol object, that controls how the figure will be displayed;
4) Set optional attributes such as color, style, or size using auxiliary objects;
5) Add your symbol to the enumeration of the objects of type.

Let's see how to draw the most frequently used object, the Callout object:

// step 1
var callout = Server.CreateObject("RMIMS.Callout");
//define the point on the map where callout will be displayed (pixels)
callout.setAnchor( Map.toMapUnits( 300, 200));

// step 2
var cLayer = Map.getCosmeticLayer();
var en = cLayer.getCallouts();

// step 3
var symbol = Server.CreateObject("RMIMS.Symbol");

// step 4
var color = Server.CreateObject("RMIMS.Utils").createColor(255, 0, 0); // red
var font = Server.CreateObject("RMIMS.TextFont");

symbol.setSize(20);
symbol.setColor( rmSymbolColor, color);
symbol.setSymbolStyle( "std:star");


font.setColor( color);
font.setBold( true);
font.setUnderline( true);
font.setItalic( true);
font.setSize( 20);

callout.setSymbol( symbol);
callout.setOrientation( rmTopCenter);
callout.setFont( font);
// to get a symbol without any text, omit this step
callout.setText( "Sample Callout");

// step 5	
en.add(callout);

VBScript version

The result should look like this:


Here is another example where we draw an ellipse:

// step 1
var es = Server.CreateObject("RMIMS.EllipseSymbol");
var ellipse = Server.CreateObject("RMIMS.GeoEllipse");
ellipse.center = Map.toMapUnits( 300, 200);
ellipse.height = Map.convertDistance( 120, rmPixels, rmMapUnits);
ellipse.width = Map.convertDistance( 200, rmPixels, rmMapUnits);
es.setEllipse(ellipse);

// step 2	
var cLayer = Map.getCosmeticLayer();
var en = cLayer.getEllipses();

// step 3
var symbol = es.getSymbol();

// step 4
var color = Server.CreateObject("RMIMS.Utils").createColor(0, 0, 255); // blue
symbol.setColor(rmBrushColor, color);
symbol.setBrushStyle("brush:bdiagonal");

// step 5
en.add(es);

VBScript version



This example shows how to draw a rectangle.

// step 1
var rc = Server.CreateObject("RMIMS.PolygonSymbol");

var vertex = new Array();
vertex[0] = Map.toMapUnits( 125, 300); // bottom/left
vertex[1] = Map.toMapUnits( 125, 100); // top/left
vertex[2] = Map.toMapUnits( 475, 100); // top/right
vertex[3] = Map.toMapUnits( 475, 300); // bottom/right

var gp = Server.CreateObject("RMIMS.GeoPointsImpl");

for(var i = 0; i < vertex.length; i++)
    gp.addPoint( vertex[i].x, vertex[i].y);

rc.setPoints( gp);
    
// step 2	
var cLayer = Map.getCosmeticLayer();
var pl = cLayer.getPolygons();

// step 3
var symbol = rc.getSymbol();

// step 4
var color = Server.CreateObject("RMIMS.Utils").createColor(0, 0, 255); // blue
symbol.setColor(rmBrushColor, color);
symbol.setBrushStyle("brush:bdiagonal");

// step 5
pl.add(rc);

VBScript version