Making an App – Part 3

Let's put some markers on the map.

Fortunately we can get marker data from the same place we got maps tiles. The following command will download some JSON that describes the markers to botw_markers.json:

$ curl "" > botw_markers.json

We should trim it down a little since there's too much data. It's a little easier to see if we reformat it with jq which will "pretty print" it by default:

$ cat botw_markers.json | jq '.' | less

Each marker looks like this:

  "id": "8549",
  "mapId": "19",
  "submapId": "1901",
  "overlayId": null,
  "markerCategoryId": "1905",
  "markerCategoryTypeId": "1",
  "userId": "1",
  "userName": "|N|NjA|",
  "name": "Pot Lid",
  "description": "GameID: 871017963",
  "x": "155.90646875",
  "y": "-152.331625",
  "jumpMakerId": "0",
  "tabId": "",
  "tabTitle": "",
  "tabText": "",
  "tabUserId": "",
  "tabUserName": "",
  "globalMarker": "0",
  "visible": "1"

It would be better if we trimmed it down to something like this:

  "category": "1905",
  "name": "Pot Lid",
  "description": "",
  "x": "155.90646875",
  "y": "-152.331625"

That's relatively easy with jq – map the elements of the array into a new array of elements without "pretty printing" into markers.json:

$ cat markers.json | jq -c '[.[] | {category: .markerCategoryId, name: .name, x: .x, y: .x }]' > markers.json

There's some interesting text in the "tabText" field, but for now we just want to show the markers on the map.

The "category" field will map to a category which we can also get the JSON for:

$ curl "" > botw_categories.json

Like with markers, let's format the data a little:

$ cat botw_categories.json | jq '.[0]'

A category looks like this:

  "id": "1931",
  "parentId": "1930",
  "name": "Enemy Camp",
  "checked": "1",
  "img": "BotW_Enemy-Camp",
  "color": "#ff422e",
  "markerCategoryTypeId": "1",
  "visibleZoom": "5"

One thing that jumps out is that there's a heirarchy and a category may have a parent. We'll trim it down just a little:

$ cat botw_categories.json | jq -c '[.[] | { id: .id, parent: .parentId, name: .name, color: .color }]' > categories.json

Next step will be parse these into Swift types which we'll do in the next post.