kartena / printlet Goto Github PK
View Code? Open in Web Editor NEWGenerate static map images from tiles and draw stuff on top
License: MIT License
Generate static map images from tiles and draw stuff on top
License: MIT License
It's nice to have a LICENSE file to be clear about the terms from early on.
I suggest MIT or BSD, copy it from for example Proj4Leaflet, for example.
If I enter incorrect zoom level as part of URL in server.js mode, Printlet is trying to display image for a while, then failing silently. It would be useful, if image useful for debugging was generated instead (with message such as Entered zoom value exceeds maxzoom property defined in your tileJSON file. Please enter correct value and try again
Similar checks would be probably also useful for other properties.
First, thanks for Printlet, seems very useful. I would like to format rendered text somehow, so it would be possible to use renders in more design-oriented projects.
At the moment styles for GeoJSON is defined in the properties
attribute of a GeoJSON feature as a dictionary called style
. The keys under style
are the same as the HTML5 canvas API for styling shapes.
I have had a look at GeoJSON CSS and simplestyle and think something like GeoJSON CSS would be a good standard.
Preferably placing the styles
dictionary directly under the feature so not to collide with user defined keys under properties
.
Also style inheritance might be something to consider, defining a style
property in the parent FeatureCollection
would set a default style for it's Feature
elements.
As you work on this you might be interested to see another approach of using cairo somewhat in this way: https://github.com/mapnik/mapnik/blob/master/bindings/python/mapnik/printing.py
Feel free to close this right off unless you have questions.
Not really an issue, but it would make a nice addition if one could use bounding box to specify what area to stich rather than {latLng},{z},{w},{h}
Not sure if that is hard to implement, but figured i might as well ask!
Har'e gött!
The repo link in package.json
points to a location on our own servers :) - switch it to GitHub.
If I read the server,js correctly, there's currently no caching for generated images. Do you think it would be useful, for example for large Geojson geometries?
I tried to display polygons and it didn't work with server.js, nor with static.js. Other types of geometry work fine.
My static.js for reference:
var fs = require('fs'),
printlet = require('../lib/printlet'),
tileJson = require('./osm.json');
// Create a printlet instance from a TileJSON
printlet(tileJson)({
// Specify the image options
width: 800,
height: 600,
zoom: 12,
lng: 11.95,
lat: 57.7,
format: 'png',
// Add the features to be drawn
geojson: {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
11.969261169433594,
57.71941492162019
],
[
11.957588195800781,
57.71588512774503
],
[
11.95638656616211,
57.70726548342996
],
[
11.970462799072266,
57.70630252339771
],
[
11.982049942016602,
57.71368456258319
],
[
11.978273391723633,
57.71748962217837
],
[
11.969261169433594,
57.71941492162019
]
]
]
},
"properties": {
"style": {
"strokeStyle": "rgba(700, 0, 0, 1)",
"lineWidth": "10"
}
}
},
// Draw a semi-transparent line
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [[11.95, 57.7], [12, 58]]
},
"properties": {
"style": {
"strokeStyle": "rgba(200, 0, 0, 0.6)",
"lineWidth": "5"
}
}
},
// Draw a point represented by a text marker
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [11.95, 57.7]
},
"properties": {
"style": {
"font": "32px serif",
"fillStyle": "rgb(20, 20, 120)",
"marker": {
"text": "Hello World"
}
}
}
}
]
}
}, function(err, data) {
if (err != null) throw new Error(err + '\n' + err.stack);
// Get the image data as a stream and write save it to a file
data.stream.pipe(fs.createWriteStream('image.png'));
});
I'm using latest version of Printlet.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.