Skip to content

Instantly share code, notes, and snippets.

@Mariusio
Created April 29, 2016 00:25
Show Gist options
  • Save Mariusio/a5969257ff46a9dbf38509386237b9e0 to your computer and use it in GitHub Desktop.
Save Mariusio/a5969257ff46a9dbf38509386237b9e0 to your computer and use it in GitHub Desktop.
{
"attribution":"<a href=\"https://www.mapbox.com/about/maps/\" target=\"_blank\">&copy; Mapbox</a> <a href=\"https://openstreetmap.org/about/\" target=\"_blank\">&copy; OpenStreetMap</a> <a class=\"mapbox-improve-map\" href=\"https://www.mapbox.com/map-feedback/\" target=\"_blank\">Improve this map</a>",
"bounds":[
-180,
-85,
180,
85
],
"created":1415246400000,
"description":"",
"filesize":0,
"format":"png8:m=h",
"id":"mapbox.streets",
"maxzoom":22,
"minzoom":0,
"name":"Streets",
"private":false,
"scheme":"xyz",
"source":"mapbox:///mapbox.mapbox-terrain-v2,mapbox.mapbox-streets-v6",
"tilejson":"2.0.0",
"tiles":[
"http://a.tiles.mapbox.com/v4/mapbox.streets/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpbTgzcHQxMzAxMHp0eWx4bWQ1ZHN2NGcifQ.WVwjmljKYqKciEZIC3NfLA",
"http://b.tiles.mapbox.com/v4/mapbox.streets/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpbTgzcHQxMzAxMHp0eWx4bWQ1ZHN2NGcifQ.WVwjmljKYqKciEZIC3NfLA"
],
"webpage":"http://a.tiles.mapbox.com/v4/mapbox.streets/page.html?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpbTgzcHQxMzAxMHp0eWx4bWQ1ZHN2NGcifQ.WVwjmljKYqKciEZIC3NfLA"
}
var assert = require('assert');
var printer = require('.');
var fs = require('fs');
var path = require('path');
var mapnik = require('mapnik');
var url = require('url');
var tilelive = require('tilelive');
var tileliveVector = require('tilelive-vector');
var TileJSON = require('tilejson');
require('tilejson').registerProtocols(tilelive);
new TileJSON('tilejson://' + __dirname + '/mapstyles/mapbox.emerald.json', function(err, source) {
return tilelive.load('tilejson://' + source.filename, function(err1, source1) {
if (err1) {
throw err1;
}
var params = {
zoom: 8,
scale: 2,
bbox: [0.023293972, 40.4104003077, 3.6146087646, 42.9542303723],
// center: {
// x: 6.6566667,
// y: 53.216667,
// w: 1000,
// h: 1000
// },
format: 'png',
limit: 75000,
getTile: source1.getTile.bind(source1)
};
return printer(params, function(err, image, headers) {
if (err) {
throw err;
}
// Object.keys(headers).forEach(function(k) {
// console.warn("%s: %s", k, headers[k]);
// });
return fs.writeFileSync(__dirname + '/images/image.png', image);
// process.stdout.write(image);
});
});
});
@Mariusio
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment