To create a sample application and generate the initial parameters follow these steps:
1) Start the Map Author;
2) Open a map (File->Open Map) or create a new one (File->New Map);
3) Create an ASP.NET based web application: Tools->Make Web Page->Without Applet->Template: ASPX Template (VB.NET) (or CSharp)->Save (to <APPLICATION_DIRECTORY>).
All the initial parameters are stored in the <APPLICATION_DIRECTORY>\Web.config file.
For additional information on setting up an ASP.NET application read the \RouteMAP IMS\Map Author\Templates\readme.htm file.
A typical ASP.NET script that allows you to execute all the examples is a file with the following structure:
<%@ Page Language="VB" %> <%@ Import Namespace="com.esri.rmims" %> <script language="VBScript" runat=server> ' Auxiliary functions and classes here </script> <% Dim map : map = OpenMap() ' Main code here %>
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 (all the parameters are in the Web.config file):
<%@ Page Language="VB" %> <%@ Import Namespace="com.esri.rmims" %> <script language="VBScript" runat=server> Public Function OpenMap() Dim conn, map conn = new IMSConnection() conn.setConnectionURL( GetConfigStr("par_ServerUrl") ) conn.setGroup( GetConfigStr("par_Groupid") ) conn.setUserName( GetConfigStr("par_Uid") ) conn.setLocale( GetConfigStr("par_Lang"), GetConfigStr("par_Country") ) conn.setCharset("") map = conn.loadMap( GetConfigStr("par_MapName") ) ' set image size map.setImageSize( GetConfigInt("par_Width"), GetConfigInt("par_Height") ) ' set location Dim location location = new Location() location.setString(GetConfigStr("par_Location")) map.setLocation(location) ' set measure units map.setMeasureUnits( GetConfigInt("par_Units") ) OpenMap = map End Function Public Function GetConfigStr(keyName As String) As String GetConfigStr = CStr(ConfigurationSettings.AppSettings(keyName)) End Function Public Function GetConfigInt(keyName As String) As Long GetConfigInt = CInt(ConfigurationSettings.AppSettings(keyName)) End Function <% Dim map : map = OpenMap() ' Example code here %>
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 (VBS/C#):
<img src="<%= map.getMapImageURL(map.getImageWidth(), map.getImageHeight(), ImageFormat.rmDefault)%>" width="<%=map.getImageWidth()%>" height="<%=map.getImageHeight()%>">
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:
' create new GeoLocation object and pass label, latitude, and longitude to the init function loc = new GeoLocation(map, "Redlands, CA", 34.0527, -117.1531) ' now we have the location object with the x and y coordinates in map units Response.Write( loc.x & ", " & loc.y) ' output for the Cylindrical projection: ' -1160.81265589209, 2355.44522655048 Class GeoLocation Public label Public x Public y Sub New( map, ilabel, ilat, ilon) Dim proj, pt proj = map.getProjection() pt = proj.project( ilat, ilon) label = ilabel x = pt.x y = pt.y End Sub End Class
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:
new GeoPoint(x, y)