Render Map

Description

Returns an image of a map, in the format specified, defined by the inline JSON map definition and the request parameters.

The RenderMap method is very similar to the RenderNamedMap method, except you do not specify a named map in the URL, rather define the map in the JSON body of the REST request. Rendering an inline defined map is used when you want to obtain a view of a map as an image, by specifying the representation (for example, gif), the dimensions of the raster and a view represented as either a center and zoom, a center and scale or a bounding box. Optionally, you may specify the locale and resolution (DPI) and well as provide authorization (security) information.

The body JSON representation is in GeoJSON format. For more information about GeoJSON, see geojson.org/geojson-spec.html.

These rules in priority order determine how the rendering view is created:

  • if the center and zoom is specified then all other parameters governing the view are ignored (for center and zoom you must specify the c and z parameters in the request)
  • if the center and scale is specified then all other parameters governing the view are ignored. (for center and scale you must specify the c and s parameters in the request)
  • if the bbox is specified then the bounding box is used to define the view (for bounding box you must specify the b parameter in the request)
  • if none of these requirements are satisfied then an HTTP code of 404 (Not Found) will be returned

ACL Authorization Flow

To return an image of a map, the user (or any roles they belong to) will need Execute permission on the named map in the following manner:

  • “EXECUTE” for entity type “Location Intelligence.Named Resources”

HTTP POST URL Format

This format is used for HTTP POST requests:


HTTP POST:	/maps/image.image type;
POST DATA:	w=width;h=height;c=x,y,srs;z=zoom;s=scale;b=x1,y1,x2,y2,srs;
			[r=resolution];[bc=background color];[bo=background opacity];
POST BODY: Content-Type:application/json {map definition}
			

Parameters

For information about the parameter types listed below, see Request URL Data Types.

Parameter Type Required Description
image type String yes The type of image to return (gif, png, jpg, bmp, jpeg, or tiff)
w=width Integer yes Width of the image in pixels
h=height Integer yes Height of the image in pixels
c=x, y, srs Double, Double, String Only required if defining the view using center and zoom, or center and scale The center of the view in geographic coordinates consisting of a x, y position and the srs name (spatial reference system).
z=zoom Integer, String Only required if defining the view using center and zoom The Zoom, or distance across the view in linear units. The zoom is represented by a string with a number followed by one or more spaces followed by an linear unit abbreviation (e.g., mi, km, m, etc.).
s=scale Integer Only required if defining the view using center and scale The map view will be zoomed to the specified scale. The scale value is used to compare map and real world distance values. For example, if a value of 1000 is specified, the map scale is 1:1000 (1 map unit is equal to 1000 real world units).
b=x1, y1, x2, y2, srs Double, Double, Double, Double, String Only required if defining the view using a bounding box The bounding box that defines the entire view in real world coordinates using opposing x, y corner positions and the srs name (spatial reference system).
r=resolution Integer no The DPI resolution of the map as an integer. DPI measures the resolution of map images in dots per inch (the number of individual dots that can be placed within the span of one linear inch). If not specified then assumes server default.
bc=background color String no The background color to use for the map image, as expressed in RRGGBB format. If not supplied, the background color will be transparent.
Note: Unlike with the SOAP API, a leading # should not precede the hexadecimal web color.
bo=background opacity Double no

The opacity of the background color. If the background and backgroundOpacity attributes are specified, these values will be used to draw the background. If the background is not used, then the background will be totally transparent regardless of the backgroundOpacity attribute. If the background is used but no opacity is specified, then the background will be totally opaque.

Returns

Returns an image of the map in the specified format.

Example

At the simplest form, the render map can define a single named layer, and return the image. In this instance, the map is returned as a PNG that is 400 x 400 pixels in dimension, the map view is defined by the bounding box in EPSG 27700. The map is defined using a single layer defined in the JSON body.


POST http://<server>:<port>/rest/Spatial/MappingService/maps/image.png;w=400;h=400;b=-140012,3087,736671,1193876,epsg%3A27700 HTTP/1.1
Content-type: application/json
Authorization: <Basic or Spectrum Token>

{
   "layers":[
      {
         "type":"NamedLayer",
         "name":"/Samples/NamedLayers/UK_REGNS_Layer"
      }
   ]
}

			

The following examples show how various JSON map descriptions are defined:

Description Example
Center and Zoom with Multiple Layers Example
Bounding Box with a Single Layer Example
Center and Scale with Multiple Layers Example
Setting Layer Renderability Example
Map with Pie Layer Overlay Example
Equal Count Range Theme with MapBasic Styles Example
Feature Layer with Bi-Quantile Range Theme Example
Graduation Bar Layer Example
Line Chart Layer Example
Line Linkage Layer with Metric Expression Example
Render Map Using a Feature Service Response Example
Rendering a map using Grid layer Example

Render a map with a translucent blue background:

http://<server>:<port>/rest/Spatial/MappingService/maps/image.png;w=256;h=256;b=-180,-90,180,90,epsg:4326;bc=0048FF;bo=.5
Content-type: application/json
Authorization: <Basic or Spectrum Token>

{
   "layers":[
      {
         "type":"NamedLayer",
         "name":"/Samples/NamedLayers/WorldcapFeatureLayer"
      },
      {
         "type":"NamedLayer",
         "name":"/Samples/NamedLayers/UK_REGNS_Layer"
      },
      {
         "type":"NamedLayer",
         "name":"/Samples/NamedLayers/WorldFeatureLayer"
      }
   ]
}