目录

Tile API

Function

Allows you to directly access and obtain grid map tile data through the URL parameter in the HTTP request. You can request independent map tiles to build a map layer, so that the map can be easily loaded to an existing map platform.

Scenario

You can request independent map tiles to build a map layer, so that the map can be easily loaded to an existing map platform. For example, you can load the tiles to the QGIS or ArcGIS platform on the PC, or to the existing map as tile overlays in mobile apps.

Restrictions

For details about service call quota, please refer to Service Pricing.

Prototype

Protocol

HTTPS GET

Direction

Your server -> Map Kit server

URL

https://mapapi.cloud.huawei.com/mapApi/v1/mapService/getTile

Data Format

Response: Content-Type: image/png

Request Parameters

At least one of Authorization in Request Header and key in Query String need to be set.

Request Header

Parameter

Mandatory

Type

Description

Content-Type

Yes

application/json

Request data format.

Authorization

No

String

Authentication mode. Access token (recommended) authentication and API key authentication are supported.

NOTE:

For access token authentication:

For API key authentication:

  • For details about how to obtain an API key, please refer to Obtaining the API Key.
  • You need to call the URLEncoder.encode("Your apiKey", "UTF-8") method to encode the API key using encodeURI. For example, if the original API key is ABC/DFG+, the conversion result is ABC%2FDFG%2B.
  • You are advised to take measures for protecting the API key security. For details, please refer to How can I protect the API key?.

Query String

Parameter

Mandatory

Type

Description

key

No

String

Authentication key. For details about how to obtain one, please refer to Obtaining the API Key.

NOTE:
  1. For details about how to obtain an API key, please refer to Obtaining the API Key.
  2. You need to call the URLEncoder.encode("Your apiKey", "UTF-8") method to encode the API key using encodeURI. For example, if the original API key is ABC/DFG+, the conversion result is ABC%2FDFG%2B.

x

Yes

Integer

X coordinate. The value ranges from 0 to 1048576.

y

Yes

Integer

Y coordinate. The value ranges from 0 to 1048576.

z

Yes

Integer

Zoom level. The value is no less than 0.

language

No

String

Map display language. The value is a language code complying with ISO 639-2 or BCP47. BCP47 is recommended. For details about the value range, please refer to Supported Languages.

scale

No

int

Map scale. The options are 1 and 2. The default value is 1.

Request Example

GET
https://mapapi.cloud.huawei.com/mapApi/v1/mapService/getTile?x=5&y=1&z=3&language=en&scale=2&key=API KEY

Response Parameters

When the status code is 200:

Response Header

Parameter

Mandatory

Type

Description

Content-Type

Yes

image/png

Response data format.

Response Body

Parameter

Type

Description

Body

String

Byte stream of grid map tiles.

Call Example

Access token authentication 
public class GetTileService {
    OkHttpClient client = new OkHttpClient();

    Request request = new Request.Builder()
            .url("https://mapapi.cloud.huawei.com/mapApi/v1/mapService/getTile?x=5&y=1&z=3&language=en&scale=2")
            .addHeader("Authorization", "Bearer " + AT)
            .get()
            .build();

    Response response = client.newCall(request).execute();
}
API key authentication
public class GetTileService {
    OkHttpClient client = new OkHttpClient();

    Request request = new Request.Builder()
            .url("https://mapapi.cloud.huawei.com/mapApi/v1/mapService/getTile?x=5&y=1&z=3&language=en&scale=2&key=xxxx")
            .get()
            .build();

    Response response = client.newCall(request).execute();
}
Figure 1 Grid map tiles