Skip to content
This repository was archived by the owner on Aug 5, 2021. It is now read-only.

Commit 68e0f3e

Browse files
author
Kevin Richter
committed
Add usage example for maps
1 parent ff6d394 commit 68e0f3e

File tree

4 files changed

+88
-3
lines changed

4 files changed

+88
-3
lines changed

pages/api.html.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
---
2+
title: Maps4News Basic API Usage
3+
4+
language_tabs:
5+
- javascript--wrapper: Wrapper
6+
- php: PHP
7+
8+
toc_footers:
9+
- <a href='https://api.maps4news.com/register'>Sign Up for Maps4News</a>
10+
- <a href='https://github.com/lord/slate'>Documentation Powered by Slate</a>
11+
12+
includes:
13+
- directory
14+
15+
search: true
16+
---
17+
118
# Introduction
219

320
...
@@ -115,4 +132,4 @@ A manager can use the `mine` keyword to get a list of organisations he/she manag
115132
GET /jobs/1/revisions/last
116133
```
117134

118-
To get the last revision for a job, you can use the `last` keyword.
135+
To get the last revision for a job, you can use the `last` keyword.

pages/dispatcher.html.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Map Definition
2+
title: Maps4News Map Definition
33

44
toc_footers:
55
- <a href='https://api.maps4news.com/register'>Sign Up for Maps4News</a>

pages/examples.html.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
title: Maps4News Basic API Usage
3+
4+
language_tabs:
5+
- javascript--wrapper: Wrapper
6+
- php: PHP
7+
8+
toc_footers:
9+
- <a href='https://api.maps4news.com/register'>Sign Up for Maps4News</a>
10+
- <a href='https://github.com/lord/slate'>Documentation Powered by Slate</a>
11+
12+
includes:
13+
- directory
14+
15+
search: true
16+
---
17+
18+
# Examples
19+
20+
## Building a Map
21+
22+
```Wrapper
23+
const api = window.api;
24+
```
25+
26+
To build a map via our system, you first need to create a few resources.
27+
28+
<br/>
29+
30+
```javascript--wrapper
31+
const job = await api.jobs.new({
32+
jobTypeId: 1,
33+
title: "My Map"
34+
}).save();
35+
```
36+
37+
First a [`Job`](/api/index.html#JobCreateRequest). A Job is a project on the Maps4News Platform.
38+
39+
<br/><br/><br/><br/>
40+
41+
```javascript--wrapper
42+
const revision = await job.revisions.new({
43+
languageCode: "eng",
44+
mapstyleSetId: 1
45+
}).save(mapObject);
46+
```
47+
48+
Second a [`Job Revision`](/api/index.html#JobRevisionCreateRequest). A Revision is a point-in-time that the user decided to save his/her current progress in designing their map.
49+
50+
A map object must be given to each revision. Revisions can not be updated, each save will result in a new revision.
51+
52+
Details about how to build a map object can be found on the [map object page](/dispatcher.html).
53+
54+
<br/>
55+
56+
```javascript--wrapper
57+
await revision.build();
58+
```
59+
60+
Lastly, we can queue a build of your map. This will create a `JobResult` resource for that revision.
61+
62+
<br/>
63+
64+
```javascript--wrapper
65+
const result = await revision.result();
66+
```
67+
68+
You can access your result via the `result` method on your revision. Except your result to be queued or processing if you get your result directly after queueing a build. It generally takes a few seconds to a few minutes to generate a map.

pages/index.html.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: API Reference
2+
title: Maps4News API Documentation
33

44
language_tabs:
55
- javascript--wrapper: Wrapper

0 commit comments

Comments
 (0)