问题
I am Trying to Implement OSM and Mapnik. My requirement is to show a Custom map to the end user(First layer of Basic Map and Second Layer of Map generated by the Data). I've Started by implementing Demo Examples from Mapnik but didn't get enough Idea.
Here is what I've tried,
App.js
var mapnik = require('mapnik');
var fs = require('fs');
/// Register fonts and datasource plugins
mapnik.register_default_fonts();
mapnik.register_default_input_plugins();
var map = new mapnik.Map(1280, 720);
map.load("./stylesheet.xml", function(err, map) {
if(err != null){
console.log(err)
return
}
map.zoomAll();
var im = new mapnik.Image(1280, 720);
map.render(im, function(err, im) {
im.encode("png", function(err, buffer) {
fs.writeFile("map.png", buffer);
});
});
});
Stylesheet.xml
<Map background-color="white" srs="+init=epsg:4326">
<Style name="My Style">
<Rule>
<PolygonSymbolizer fill="#f2eff9" />
<LineSymbolizer stroke="rgb(50%,50%,50%)" stroke-width="0.1" />
</Rule>
</Style>
<Style name="countries">
<Rule>
<PolygonSymbolizer fill="blue" />
<LineSymbolizer stroke="rgb(50%,50%,50%)" stroke-width="0.4" />
</Rule>
</Style>
<Layer name="world" srs="+init=epsg:4326">
<StyleName>countries</StyleName>
<Datasource>
<Parameter name="file">../data/India/IND_adm3.shp</Parameter>
<Parameter name="type">shape</Parameter>
</Datasource>
</Layer>
</Map>
Can anyone please guide me in this. How can I achieve Requirement ?? Any help will be appreciated.
来源:https://stackoverflow.com/questions/47076168/osm-mapnik-integration