Dev: SM: Static Maps API

From AAT Wiki
Jump to: navigation, search

Introduction

The Streetmaps Static Maps API V2 is based on the Google Maps Static API. It is a drop-in replacement with some enhancements.

For the base documentation, consult Static Maps API V2 Developer Guide. The base URL has changed from https://developers.google.com/maps/documentation/staticmaps/ to https://www.streetmaps.co.za/api/staticmap - all the arguments work the same.

Mandatory Changes

You need to specify your API key in the parameters with key=<YOURKEY>.

Enhancements to the Service

Map Size

The image size that can be generated is increased to 2048x2048 from 640x640.

URL Callbacks

To address the problem of long commands, you may construct the command and serve it from a web server. You then instruct the static maps API to collect it via the "url" parameter.

The retrieved text will be appended to the command.

For example, here is a command that's over 32kb long: https://www.streetmaps.co.za/demo/staticapi_demo1.aspx which results in this map of all the police stations in South Africa: https://www.streetmaps.co.za/api/staticmap?size=500x500&url=https://www.streetmaps.co.za/demo/staticapi_demo1.aspx

Circles

You may draw a circle on the map by specifying 2 or 3 points on the circumference.

The circle parameter takes set of value assignments (circle descriptors) of the following format:

circle=circleStyles|circleLocation1|(circleLocation2|meterradius)|[circleLocation3]

Note that circle points are separated from each other using the pipe character (|). Because both style information and point information is delimited via the pipe character, style information must appear first in any circle descriptor. Once the Static Map server encounters a location in the circle descriptor, all other path parameters are assumed to be locations as well.

If there are two parameters, and the second is a meter radius (specified as "123m") that radius will be used.

Circle Styles The set of circle style descriptors is a series of value assignments separated by the pipe (|) character. This style descriptor defines the visual attributes to use when displaying the circle. These style descriptors contain the following key/value assignments:

  • weight: (optional) specifies the thickness of the circle in pixels. If no weight parameter is set, the circlr will appear in its default thickness (5 pixels).
  • color: (optional) specifies a colour either as a 24-bit (example: color=0xFFFFCC) or 32-bit hexadecimal value (example: color=0xFFFFCCFF), or from the set {black, brown, green, purple, yellow, blue, gray, orange, red, white}.

    When a 32-bit hex value is specified, the last two characters specify the 8-bit alpha transparency value. This value varies between 00 (completely transparent) and FF (completely opaque).

  • fillcolor: (optional) indicates both that the cirlclr marks off a circular area and specifies the fill color to use as an overlay within that area.

Branding

Paying clients may remove the branding on the map by specifying the nobranding parameter:

nobranding=1

Localization

The labels may be localized depending on language. The format is

lang=XXX

where "XXX" is the MARC Language Code. Here is a reproduction of the Dev: SM: MARC Language Codes. Example: Luxembourg with Default (No) Localization and German Localization

Custom Styles

If you are running the standalone version of the mapping server, and have created custom styles, you may select them for rendering:

style=[style_name]

Projection

By default, Geographic projection will be used. To use Spherical Mercator, specify the parameter

&projection=1