Raster Tiles API
The Raster Tiles API service provides raster tiles for 2D maps.
To work with raster tiles, depending on your needs, you can use:
- the public endpoint for integration with third-party libraries or custom implementations.
- RasterJS API library to display the map with minimal configuration.
Getting started
1. Get an access key
-
Sign in to the Platform Manager.
-
Create a demo key or purchase a subscription for using API. For details on service prices, see the Tariffs section.
tipIf you already have an active API key obtained for RasterJS API, you can use it with Raster Tiles API until the subscription expires. You can view the subscription expiration date in the Platform Manager, on the Dashboard tab.
For more information on working with access keys and subscriptions, see the account documentation.
2. Work with API
Start working with raster tiles using public endpoints or the RasterJS API library.
Using public endpoint
When using third-party libraries, specify the endpoint for loading tile images:
https://tile{n}.maps.2gis.com/v2/tiles/{tileset}/{z}/{x}/{y}.png?key={key}
Here:
n- host number that can range from 0 to 4. You can use a single host for low traffic volumes or distribute requests across multiple hosts manually.tileset- tile set. For example,online_hdfor high-resolution tiles oronline_sdfor standard-resolution tiles.z- map zoom level. The higher the number, the more detailed the map.x,y- tile coordinates.key- your API key.
Request example:
https://tile0.maps.2gis.com/v2/tiles/online_hd/16/47851/20734.png?key=YOUR_KEY
Integrating RasterJS API library
RasterJS API is a free JavaScript library for working with 2D 2GIS maps. The library contains a ready-made set of tools for interacting with the map, automatically requests raster tiles, and displays them on the page.
To use the tiles provided by the Raster Tiles API service with the RasterJS API library, first obtain an API key, then install the library in your project. For more details, see the Getting started instruction.
Usage example
Statistics
When limits are reached, the service becomes unavailable. You can track subscription usage and service request distribution statistics in your personal account. For more information about statistics tools, see the Statistics section.
Tariffs
-
The service fee is calculated based on the number of successful requests per month. One request corresponds to loading one raster tile in PNG format of size 256×256 pixels.
-
To determine the exact number of tiles required to display a map:
- Determine the map display size in pixels (width and height).
- Divide the map width and height by 256 (size of one tile) and round each value up to the nearest integer.
- Multiply the number of horizontal tiles by the number of vertical tiles.
The resulting number is the minimum number of tiles required to display the visible map area. It is recommended to add one extra tile on each side to ensure smooth scrolling and zooming.
For example, to display a map area of 800×600 pixels, you need a minimum of 12 tiles (4 horizontally and 3 vertically) and optimally 30 tiles (6 horizontally and 5 vertically).
-
Unlimited access to the RasterJS API library is provided free of charge.
-
See current prices and rate limits in the Prices section.
Deployment options
- Cloud-based: Raster Tiles API is available through public 2GIS endpoints.
- On-Premise: to get raster tiles, install Tiles API as part of the 2GIS API Platform in a private network. For more information, see the API Platform for server.
Support
-
If you have any questions while working with the API, ask AI assistant (in the lower-right corner of website), use the documentation search, or send an email to api@2gis.com.
-
If you would like to discuss the capabilities of the API or its integration with your product, please contact a manager.