When a REST Map request is sent with the ocs parameter, projection mode is turned on and a string representing the Current Map Reference (cmr) is returned in the response with the projected map. The cmr value can be used in subsequent requests in conjunction with the dc parameter to pan this projected map. See the dc and cmr parameters for details. Note that you do not have to parse the contents of cmr to send it in subsequent requests.
There are several ways to obtain the cmr value for a REST map depending on the map image format:
NOTE: See Samples—terms and conditions for usage permissions.
This sample demonstrates how to obtain the cmr value from a projected REST map in SWF format using Flash. In Flash, the cmr value is set by the method setCurrentMapReference().
See REST mapping parameters for details on the parameters mentioned below.
var cmr:String;
var mclListener:Object
var image_mc:MovieClip;
var url:String; //REST URL to call
System.security.allowDomain("www.arcwebservices.com");
//create the MovieClip to load the map onto
image_mc = this.createEmptyMovieClip("image_mc",this.getNextHighestDepth());
//create a listener
mclListener = new Object();
//create the MovieClipLoader
var image_mcc:MovieClipLoader = new MovieClipLoader();
//set the listener to this loader
image_mcc.addListener(mclListener);
//load the rest url into image_mc
image_mcc.loadClip(url, image_mc);
mclListener.onLoadComplete = function(target_mc:MovieClip):Void{
trace( "onLoadComplete");
};
//Once onLoadComplete is fired, the map will call this function
function setCurrentMapReference(sys:String){
cmr=sys;
trace(cmr);
}
This sample demonstrates how to obtain the cmr value from a projected REST map in SVG format from within the SVG environment and parse the response to obtain the cmr parameter value.
In the code for this sample, the getURL() method makes a call to restproxyservlet, and upon receipt of the data, the function specified in the getURL is called. In this example, MapLoaded is the callback function.
The MapLoaded function parses the SVG response from the ArcWeb server and displays cmr in a Web browser. The cmr along with dc parameter can then be used in subsequent requests for panning the map.
For example:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="400px " height="400px" viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg" version="1.0" xmlns:xlink="http://www.w3.org/1999/xlink">
<desc>
-117.0|34.0|0.0|0.0|50000.0|0.0|3
</desc>
In this example, the cmr value is:
-117.0|34.0|0.0|0.0|50000.0|0.0|3
NOTE: The SVG document needs to be hosted on the same server where the REST map is created—in this case it is the server hosting the restproxyservlet—otherwise, a security violation error will occur.
"http://<myhostname>[:port]/restproxyservlet/restProxy?sf=50000&ds=bam&c=-117|34&actn=getMap&fmt=svg&ocs=0";
http://<localhost>[:port]/restproxyservlet/getcmr.svg
For example: http://myhostname:8080/restproxyservlet/getcmr.svg
The above request displays the cmr contained in the SVG response of the REST request specified in the getcmr.svg document.
This sample demonstrates how to obtain the cmr value from the HTTP header of a projected REST map using Java. This method can be used for maps in JPG, PNG, SVG, or SWF format.
Download
the sample code (1cmrHTTPHeader.zip) and unzip the cmrHTTPHeader.jsp
file.username: ArcWeb Username
password: ArcWeb Password
http://<localhost>:<port number>/<path to cmrHTTPHeader.jsp>/getcmrHTTPHeader.jsp
The map and the HTTP header display on the HTML page.
The following lines of code in cmrHTTPHeader.jsp create a URL REST request with a valid ArcWeb REST token:
String restURL= "https://www.arcwebservices.com/services/v2006_1/restmap?" +
"actn=getMap&tkn=" + getToken(username,password, ipAddress) + "&ds=bam&sf=500000&c=-117|34&ocs=0";
URL urlCMR = new URL(restURL);
This line of code opens a URL connection:
URLConnection connectionCMR = urlCMR.openConnection();
Use this code to prevent cached data from being used in the response:
connectionCMR.setUseCaches(false);
This line of code reads the cmr value from the HTTP header:
cmrhdr = connectionCMR.getHeaderField("Cmr");
This sample demonstrates how to obtain the cmr value from a projected REST map using a network capturing tool such as Ethereal.
Visit the Feedback page to give comments or suggestions about the ArcWeb Developer's Guide.