
Product
Socket Now Supports pylock.toml Files
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
map-tile-downloader
Advanced tools
The purpose of this module is to download or cache map tiles shown to the user that fall within a specified area (bbox, polygon, wkt) and a designated zoom range.
To use map services (xyz, wms, and wmts), you need to know the URL address of the map service you want to download. The tile URL address contains {s} subdomains, {z} zoom level, {x}, and {y} information, which are always present. While {s} is not mandatory, it has also been included for all scenarios. If {s} is used, don't forget to add subdomains.
After these operations, three different export methods are provided. You should be aware that the hierarchical folder and file structure of the downloaded tiles is in the format zoom_levels/{z}/{x}/{y}. Apart from this, you can download them to the path you define on your server or computer in zip or folder structure, or if you are going to use them within an API, you can access them as a Zip Buffer Array.
Let's illustrate these operations with a few examples..
intall npm package
npm install map-tile-downloader
You can use 3 different service for tile URL, This sample for XYZ Tiles
// type can be url, wms, wmts
// subdomians sometimes can be -> ['a','b','c','d']
// min max zoom range is 0 to 22
// format can be png, gif, pbf, jpg, jpeg
var tileOptions = {
type: 'url',
url: 'https://server{s}.service-domain.com/abcd/{z}/{x}/{y}.png',
subdomains: [0, 1, 2, 3],
minZoom: 0,
maxZoom: 15,
format: 'png'
};
You can use 3 different geometry type for filtering area
// Area Sample 1 - GeoJSON - Polygon
var areaOptions = {
type: 'geojson',
data: {
type: "Feature",
properties: {},
geometry: {
type: "Polygon",
coordinates: [
[
[27.12637, 38.42191],
[27.15161, 38.42013],
[27.16448, 38.44603],
[27.14505, 38.44900],
[27.12637, 38.42712],
[27.12402, 38.42284],
[27.12637, 38.42191]
]
]
}
}
};
// Area Sample 1 - BBOX
var areaOptions = {
type: 'bbox',
data: [27.12402, 38.42013, 27.16448, 38.44900]
};
// Area Sample 1 - WKT Polygon
var areaOptions = {
type: 'wkt',
data: 'POLYGON ((27.126379667467944 38.42191945460772, 27.151617849934297 38.420139862716354, 27.16448932299207 38.44603848581883, 27.145055922492958 38.449003384245714, 27.126379667467944 38.42712615684721, 27.124024103770523 38.422842188698525, 27.126379667467944 38.42191945460772))'
};
var MapTileDownloader = require('map-tile-downloader');
var areaOptions = {
type: 'bbox',
data: [27.12402, 38.42013, 27.16448, 38.44900]
};
var tileOptions = {
type: 'url',
url: 'https://server{s}.service-domain.com/abcd/{z}/{x}/{y}.png',
subdomains: [0, 1, 2, 3],
minZoom: 0,
maxZoom: 15,
format: 'png'
};
var options = {
tile: tileOptions,
area: areaOptions,
};
var downloader = new MapTileDownloader(options);
When you use this method, it'll return a zip buffer array in callback parameter. Then you can use it whatever you want. Generaly this usage best for API respond
downloader.getAsZip((zipFile)=>{
//bufferArray
});
You can download zip file to any file path in your server or pc.
downloader.downloadZipToPath('D:/export.zip',(status)=>{
console.log(status);
},(status)=>{
console.log(`Progress: ${status.progress}%`);
console.log(`Current: ${status.current}`);
console.log(`Total: ${status.total}`);
console.log(`Downloaded Tile: ${JSON.stringify(status.tile)}`);
console.log(`Status: ${status.status}`);
});
When you use this method tiles will download in hierarchical folders step by step
downloader.generateToPath('D:',(status)=>{
console.log(status);
},(status)=>{
console.log(`Progress: ${status.progress}%`);
console.log(`Current: ${status.current}`);
console.log(`Total: ${status.total}`);
console.log(`Downloaded Tile: ${JSON.stringify(status.tile)}`);
console.log(`Status: ${status.status}`);
});
Sr. GIS Dev. Ali Kilic | ali.kilic@gislayer.com | https://akilic.com
FAQs
This Package developed for downloading map raster tiles
The npm package map-tile-downloader receives a total of 4 weekly downloads. As such, map-tile-downloader popularity was classified as not popular.
We found that map-tile-downloader demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.
Research
Security News
Malicious Ruby gems typosquat Fastlane plugins to steal Telegram bot tokens, messages, and files, exploiting demand after Vietnam’s Telegram ban.