1

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.

aydinugur
  • 1,208
  • 2
  • 14
  • 21
Kanaiya Katarmal
  • 5,974
  • 4
  • 30
  • 56
  • Do you need to show your data in a slippy map? – João Paulo Dec 20 '17 at 15:13
  • Can you add a few more details about the target platform and what problem you're trying to solve? Is there any reason you're writing mapnik code on the fly rather than using some other option? – SomeoneElse Dec 20 '17 at 21:19

0 Answers0