RouteMAP IMS 3.0 .NET API

Getting Started

The Map interface is the primary mapping interface in the system. It gives full control over the map conditions and the map image.

The Map interface based object must be initialized before using any of the other objects or methods.

The basic steps to initialize the Map object are:
1) Create the IMSConnection object;
2) Set the server URL, group, user name, locale, and charset;
3) Load the map;
4) Set the map image size;
5) Set the initial extent;
6) Set the measuring units.


For example:

// The following parameters are generated automatically by the Map Author,
// see the parameters.user file in your web site directory.

var par_ServerUrl = "http://127.0.0.1/webgate/webgate.dll";
var par_Uid = "test";
var par_Groupid = "routemap";
var par_MapName = "Map 1";

var par_Lang = "EN";
var par_Country = "US";

// initial extent
var par_Location = "-122.996058;45.124554;6687.631535;4454.699470;0.189586;0;600;400";

// map size in pixels
var par_Width = 600;
var par_Height = 400;

// rmMiles, rmKilometers, or rmMapUnits
var par_Units = rmMiles;

var conn = Server.CreateObject("RMIMS.IMSConnection");
    
conn.setConnectionURL(par_ServerUrl);
conn.setGroup(par_Groupid);
conn.setUserName(par_Uid);
conn.setLocale(par_Lang, par_Country);
conn.setCharset("");
	
var Map = conn.loadMap(par_MapName);

// set image size in pixels
Map.setImageSize(par_Width, par_Height);

// set extent
var location = Server.CreateObject("RMIMS.Location");
location.setString(par_Location);
Map.setLocation(location);

// set measure units
Map.setMeasureUnits(par_Units);
	

VBScript version

A key method of the Map interface is getMapImageURL(). After performing any desired function on the map image (set label or route, draw ellipses, rectangles, or polygons), call this method to get the resulting map image and display it in the browser (JS/VBS):

<img src="<%= Map.getMapImageURL(Map.getImageWidth(), Map.getImageHeight(), rmDefault)%>"
width="<%=Map.getImageWidth()%>" height="<%=Map.getImageHeight()%>">

Examples

All the examples in this guide are written to work in ASP script using the following structure:

<%@ LANGUAGE = JScript %>

<!--#include file="parameters.user"-->
<!--#include file="apiconst.asp"-->

<%

var Map = OpenMap();

// insert code here

%>

VBScript version

To obtain the include files, create an ASP application based on the ASP Template (JScript or VBScript) from the Map Author and copy both files to the folder with the examples.

The Map variable initialized with the valid Map object is required. You can use either the code above or the standard version (see the RmApiExJs.asp file in the ASP application directory) of the OpenMap function (JScript / VBScript).

Other functions are included in the examples code.

There is a separate step that is used to retrieve locations represented in map units. Most of the examples require locations represented by the coordinates that are in map units, however there are several projections of the US maps in RouteMAP IMS which require their own projection dependent coordinates. Therefore to make projection independent locations represented by their coordinates we use the following code:

// pass label, latitude, and longitude to the constructor
var location = new GeoLocation ("Redlands, CA", 34.0527, -117.1531);

// now we have the location object with the x and y coordinates in map units
Response.Write( location.x + ", " + location.y);

// output for the Cylindrical projection:
// -1160.8126558920917, 2355.452143609115

function GeoLocation( label, lat, lon)
{
    var pt = Map.getProjection().project( lat, lon);
    this.label = label;
    this.x = pt.x;
    this.y = pt.y;
}

VBScript version

Most of the methods of the API require the GeoPoint object as a parameter. You can use the following methods to get the GeoPoint object.

If x, y is in pixels:

Map.toMapUnits(x, y)
If x, y is in map units:
function createPoint(x, y)
{
    var pt = Server.CreateObject("RMIMS.GeoPoint");
    pt.x = x;
    pt.y = y;

    return pt;
}

VBScript version