Created
February 23, 2013 01:21
-
-
Save YenTheFirst/5017847 to your computer and use it in GitHub Desktop.
rendering tile based on XML file with node-mapnik
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
options = {z:7,x:35,y:54, metatile:1, tileSize:256,format:'png'} | |
calculateMetatile = require('tilelive-mapnik/lib/render')['calculateMetatile'] | |
meta = calculateMetatile({z:7,x:35,y:54, metatile:1, tileSize:256,format:'png'}) | |
var mapnik = require('mapnik') | |
options.headers = { 'Content-Type': 'image/png' }; | |
var image = new mapnik.Image(meta.width, meta.height); | |
var map = new mapnik.Map(256,256); | |
map.bufferSize=0 | |
map.fromString(path_to_Xml, {strict: false, base: path_to_base}, function(err,map) {console.log('done')}) | |
map.loadSync(<path_to_xml>) | |
map.resize(meta.width, meta.height); | |
map.extent = meta.bbox; | |
map.render(image, options, function(err,image) {console.log("done!",err,image)}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment