Mbtiles Offline Map Demo-based on Google Maps JavaScript API v3 + SQLite

Source: Internet
Author: User
Tags sqlite sqlite database



Mbtiles is a map tile storage data specification, it uses SQLite database, can greatly improve the reading speed of massive map tiles, than through the tile file way of reading much faster, suitable for Android, iphone and other smart phone offline map storage. For more information, please refer to: Mbtiles Mobile Storage Introduction.
In the Web map introduction We see that tiles refer to their z/x/y form coordinates, on disk storage, they are usually stored in a directory with Z, x as the name, so that a tile file path is 0/0/0.png.






Also with Google or Baidu map JS API is very convenient to call. But there is a drawback is that more files, take up disk space is much larger than the actual file, resulting in a lot of file fragments, moving very cumbersome, slow. Mbtiles provides such a feature: Tile table, Tiles:


sqlite> SELECT * FROM tiles;

zoom_level | tile_column | tile_row | tile_data
5          | 13          | 23       | [PNG data]
5          | 13          | 24       | [PNG data]
5          | 14          | 23       | [PNG data]
5          | 14          | 24       | [PNG data]
5          | 15          | 25       | [PNG data]


This table is easy to query for a particular tile: for example, the query level is 8, the column number is 116, the row number is 192 of the tile data:

sqlite> SELECT tile_data FROM tiles WHERE zoom_level = 8 AND tile_column = 116 AND tile_row = 192;

[PNG data]
tile_data is a binary stream file, which can be used to easily read tile data from the Mbtiles database, whether it is used in desktop programs or Android or iOS applications.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.