Template Service

If you wish to provide your own custom template service you can use the templateServiceUrl startup parameter. This parameter defines a base url for a REST service that conforms to the specifications described below.

If you do not want to provide custom templates, omit the templateServiceUrl parameter from the startup method and the default templates will be provided by the server.

Example

editor = new ESDWeb(null, 'editorNode');

/* set other properties here */

editor.startup({
    /* other parameters */,
    templateServiceUrl: "http://www.example.com/REST"
});
		

Template Service REST Requests

There are five REST requests you must implement for a custom template service.

  1. Get Template Groups
  2. Get Template Information for All Groups
  3. Get Template Information for a Group
  4. Get Information about Templates Near a Location
  5. Get Template

You may implement this REST service using the server-side technology of your choice. Please refer to the documentation for your server-side technology on how to accomplish this.

Note that the parameter <locale>; is included with each of these requests. If your application supports multiple languages you can use this parameter to return localized results.

Get Template Groups

Request: <template service URL>/groups/<locale>

Returns a list of all template groups.

The result will be a JSON string in the following format:

[
    "group name one",
    "group name two,
    ...
]
		

Get Template Information for All Groups

Request: <template service URL>/allgroups/<locale>[?s=<search>]

Returns info about all templates. The template info may be limited to the templates that match the search string <search>.

The result will be a JSON string in the following format:

[
    {
        "templateId": <template ID>,
        "name": "<template name>",
        "description": "<template description>"
    },
    ...
]
		

Get Template Information for a Group

Request: <template service URL>/group/<locale>/<group name>[?s=<search>]

Returns info on the templates in the group <group name> where <group name> is a group name returned by Get Template Groups. The template info may be limited to the template that match the search string <search>.

The result will be a JSON string in the following format:

[
    {
        "templateId": <template ID>,
        "name": "<template name>",
        "description": "<template description>"
    },
    ...
]
		

Get Information about Templates Near a Location

Request: <template service URL>/location/<locale>?latitude=<latitude>&longitude=<longitude>

Returns info on the templates near the location specified by <latitude> and <longitude>.

The result will be a JSON string in the following format:

[
    {
        "templateId": <template ID>,
        "name": "<template name>",
        "description": "<template description>"
    },
    ...
]
		

Get Template

Request: <template service URL>/template/<locale>;/<template id>

Returns the template with ID <template id> as an SVG string.