Preview
Hi, Visitor  | 

Map feature data with the ShapeServer REST API

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]
Use the following URL templates to create a static map with feature data.

Supported HTTP Methods

GET

URL Templates

Create a static map with feature data
http://api.shapeserver.com/REST/v1/shapefiles/map?file=file&fid=fid&size=size&culture=culture&type=type&linecolor=linecolor&linewidth=linewidth&buffer=buffer&includehotspots=includehotspots&useBoundingBox=useBoundingBox&zoom=zoom&format=format&nocache=nocache&key=ShapeServerKey

Template Parameters

Note
Parameter names and values are not case-sensitive.
Parameter Description Values
file Required The name of the shapefile that contains the feature(s) you wish to visualize. A string with the shapefile name.
Example: file=RiverSample
fid Optional Specifies the ids of the feature(s) to put on the map. A single image with all shapefile features will be created if this parameter is omitted.
Note
To retrieve a child feature from a multi-part feature (MultiPoint, MultiPolyLine and MultiPolygon shapes), use the parent.child format notation.
Example: fid=5.2 refers to child feature 2 of multi-part parent feature 5.
A comma-separated string with feature ids.
Example: fid=1,2,5.2,11
size Optional A comma-separated string containing the map image height and width. A string with two integer values separated by a comma, indicating the height and width of the map image. The default value is 480,640.
Example: size=300,400
culture Optional Indicates culture settings of the map. One of the following values:
  • English [default]
  • Dutch
Example: culture=Dutch
type Optional Specifies the type of map imagery. One of the following values:
  • Road [default]
  • Aerial
  • AerialWithLabels
Example: type=Aerial
lineColor Optional Specifies the color of a line string or polygon border. A string with a hexadecimal color code. The default value is #FF0000 (red).
Example: lineColor=#AF4400
lineWidth Optional Specifies the width of a line string or polygon border in pixels. A string that contains an integer value. The default value is 2.
Example: lineWidth=4
buffer OptionalThe amount of pixels to use to create a buffer around the resulting map image. A string that contains an integer value. The default value is 12.
Example: buffer=20
includeHotSpots Optional Indicates whether to generate a FeatureImage that contains a HotSpot collection for use in an image map control. A string that contains an integer value of 0 or 1. The default value is 0 (false).
Example: includeHotSpots=1
useBoundingBox Optional Indicates whether to use the bounding box of the base shapefile. If omitted, the map will provide an optimal view of the specified shapefile features. A string that contains an integer value of 0 or 1. The default value is 0 (create optimal view).
Example: useBoundingBox=1
zoom Optional Used to override the zoom level of the map. A string that contains an integer value between 1 and 22. The optimal zoom level is calculated by default.
Example: zoom=11
noCache Optional Indicates whether to cache the specified features. Use this option to improve performance when selecting the same set of features multiple times from a large shapefile. A string that contains an integer value of 0 or 1. The default value is 0 (use cache).
Example: noCache=1
format Optional The output format for the response. One of the following values:
  • xml [default]
  • json
Example: format=json
key Required Specifies the ShapeServer key to use for this request. A valid ShapeServer key.
Example: key=abc1234def56789

Input

When you create the HTTP request, you must set the content type in the request to the following value:
  • XML (application/xml)

Response

A Response resource is returned when you make a request. The response supports the following response formats:
  • XML (application/xml)
  • JSON (application/json)

Examples

Create a static map with feature data
The following example creates a static map image of type 'Road' with feature id '1' of shapefile 'rivers' drawn on it.
http://api.shapeserver.com/REST/v1/shapefiles/map?file=rivers&fid=1&type=Road&key=ShapeServerKey

XML Response

                    
<Response xmlns="http://schemas.shapeserver.com/rest/v1" 
          xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <Copyright>Copyright © 2011-2012 BartelsOnline. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from BartelsOnline.</Copyright>
  <StatusCode>200</StatusCode>
  <StatusDescription>OK</StatusDescription>
  <ErrorDetails/>
  <TraceId>A194389081078C7D09BEBEABD04A01E877624938/36a2c534-4ad0-42f2-b371-40151fbdb5e6/804404427</TraceId>
  <Resource i:type="ShapefileFeatureImageCollection">
    <ItemId>1</ItemId>
    <Shapefile>rivers</Shapefile>
    <ShapefileFeatureImages>
      <ShapefileFeatureImage>
        <ItemId>1</ItemId>
        <FeatureId>-1</FeatureId>
        <FeatureImage>iVBORw0KGgoAAAANSUhEUgAAAeAAAAKACAYAAABEyII ...</FeatureImage>
        <FeatureHotSpots i:nil="true"/>
      </ShapefileFeatureImage>
    </ShapefileFeatureImages>
  </Resource>
</Response>
                

JSON Response

                    
{
	"Copyright":"Copyright © 2011-2012 BartelsOnline. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from BartelsOnline.",
	"StatusCode":200,
	"StatusDescription":"OK",
	"ErrorDetails":"",
	"TraceId":"A194389081078C7D09BEBEABD04A01E877624938\/6467b9eb-c1c7-418f-8c29-e2f355e62b1b\/1177528584",
	"Resource":
	{
		"__type":"ShapefileFeatureImageCollection:http:\/\/schemas.shapeserver.com\/rest\/v1",
		"ItemId":1,
		"Shapefile":"rivers",
		"ShapefileFeatureImages":
		[
			{
				"ItemId":1,
				"FeatureId":-1,
				"FeatureImage":[137,80,78,71,13,10,26,10,0,0,0,13,73,72,66,96,130, ...],
				"FeatureHotSpots":null
			}
		]
	}
}
                
Note
The binary data in the FeatureImage nodes has been truncated to improve readability.

HTTP Status Codes

When the request is successful, the following HTTP status code is returned.
  • 200
When the request is not successful, the response returns one of the following errors.
  • 400
  • 401
  • 404
  • 500
  • 503

See Also