Map Tile API Developer's Guide

Metainfo Tiles with City Center Labels

This article shows example usage of matainfo tile for displaying and ineraction with city center labels.

User story

In order to make city center labels on the map interactive (display additional info upon selection, etc.) user obtains metadata information about an image, showing a map tile that includes city center label.

Original map tile

Given the following request:

https://2.base.maps.cit.api.here.com
/maptile/2.1/maptile/newest/normal.day/5/5/10/256/png8
?app_id={YOUR_APP_ID}
&app_code={YOUR_APP_CODE}

The response to the request delivers the following image:

Figure 1. Map tile with city center labels

This tile contains some city center labels: Calgary, Edmonton, Vancouver. When the user wants to find out more information they can use the following request:

Metainfo Tile Request

The code block below demonstrates a complete request for a metadata map tile:

https://2.base.maps.cit.api.here.com
/maptile/2.1/maptile/newest/normal.day/5/5/10/256/png8
?app_id={YOUR_APP_ID}
&app_code={YOUR_APP_CODE}
&metadata=metaonly
&mgen=2

Processing Metainfo Tile Response

The response to the request delivers the following Metainfo tile as a JSON object (response is suppressed to show only relevant city center data):


{ "metadata" : {
"street labels":[  ],
"labels":[ ... ],
"city center labels":[{"name": "Calgary", "box 2":[ 165.64, 165, 52.36, 16.75 ], "box 1":[ 218, 178, 5, 5 ], "city center info": {"type":"OTHER", "name": "Calgary", "alternative names":[], "country code": "CAN", "position": {"latitude":51.064453, "longitude":-114.082031}, "population": 1096830 } },
{"name": "Edmonton", "box 2":[ 168.45, 76, 62.55, 14.25 ], "box 1":[ 231, 87, 4, 4 ], "city center info": {"type":"PROVINCIAL CAPITAL", "name": "Edmonton", "alternative names":[["ENG", "Edmonton"], ["FRE", "Edmonton"], ["SPA", "Edmonton"]], "country code": "CAN", "position": {"latitude":53.525391, "longitude":-113.510742}, "population": 812200 } },
{"name": "Vancouver", "box 2":[ 16, 231, 63.44, 14.25 ], "box 1":[ 12, 242, 4, 4 ], "city center info": {"type":"OTHER", "name": "Vancouver", "alternative names":[], "country code": "CAN", "position": {"latitude":49.262695, "longitude":-123.134766}, "population": 603500 } }],
"buildings":[  ],
"transit stops":[  ],
"POIs":[  ]
}
}

This information allows to locate city center's icon and label in order to make them interactive. For this you can use "box 1" (describes a bounding box for icon), "box 2" (describes a bounding box for text label).

City center icon also can differ depending on the particular city type (e.g. capital cities can have different icons). The information about city type provided with "type" attribute of "city center info" JSON object: that could be "NATIONAL CAPITAL", "PROVINCIAL CAPITAL" or "OTHER".

If the label is localized for several languages (e.g. label for Edmonton from example above), relative information is provided as "alternative names" array of "city center info" JSON object.

There is also some additional information which can be displayed, e.g. in info bubble: "country code" and "population".

Geographical coordinates of a city are provided as "position" attribute of "city center info" JSON object. That information can be used for example for reverse geocoding.