createMapService Method

Description

Creates a map service based on a declared map scheme, making it available for use in the diagram editor.

Note that mapping is a separately licensed feature of the Web SDK.

Syntax

.createMapService(/* String */ schemeId, /* Object */ serviceConfiguration);

Parameters

schemeId: String

The ID of a declared map scheme. Five map schemes are pre-declared, 'Bing', 'Google', 'NearMap', 'ESRI Custom', and 'ESRI Base Layer'. The first two schemes use the REST-based map image service provided by Google and Bing to place maps in diagrams. The NearMap scheme retrieves images from Nearmap's high resolution map service. The ESRI schemes use the Leaflet javascript library to generate a map image from ESRI map services.

serviceConfiguration: Object

A hash containing information used to initialize the map service. For the Bing and Google map schemes, this should contain one attribute, 'key', with the value set to the API key for Bing or Google maps. NearMap requires an API key and optional region ('us' or 'au'). The ESRI Base Layer scheme has no options. The ESRI Custom scheme requires one attribute, 'layerUrls', with the value set to an array of URLs to compatible REST-based map services that will be applied in the specified order as map layers. It can also take an optional attribute, 'maxZoomLevel', which determines how far in the user can zoom before the closest map image is scaled rather than loaded from the map server. The default is 19, and this should be adjusted lower if a map layer lacks close-in imagery or higher to allow zooming closer. It is limited to between 18 and 24, inclusive. See the gisConfiguration property documentation for an example.

Remarks

Custom map schemes can be declared to enable the use of other map services. For more information on this, contact Trancite support.

Example

editor = new window.__editor(undefined, document.getElementById('editor-node'));

editor.startup();

// If the map feature is enabled, create map services and configure the map layer.
if (editor.get('enableMaps')) {
    editor.createMapService('Bing', {key: '==== Bing Map API Key ====='});
    editor.createMapService('Google', {key: '==== Google Map API Key ====='});
	editor.createMapService('NearMap', {key: '==== NearMap API Key =====', region: 'us'});
}