Skip to content

Examples

Andreas Fast edited this page Feb 21, 2016 · 3 revisions

Use these hashes to initialize core and output to a file like this:

MapPrint::Core.new(hash).print(file_path)

Farm

{
  format: 'pdf',
  pdf_options: {
    layout: 'landscape'
  },
  map: {
    ne: {lng: -56.251909732818596, lat: -33.91209553044297},
    sw: {lng: -56.268110275268555, lat: -33.92399018008704},
    zoom: 16,
    position: {
      x: 20,
      y: 20
    },
    size: {
      width: 563,
      height: 768
    },
    layers: [{
      type: 'bing',
      urls: ['http://ak.dynamic.t3.tiles.virtualearth.net/comp/ch/${quadkey}?mkt=en-us&it=A,G,L,LA&shading=hill&og=116&n=z'],
      level: 1,
      opacity: 1.0
    }],
    geojson: '{
  "type": "FeatureCollection",
  "features": [ {
      "type": "Feature",
      "properties": { "stroke": "#fffb00", "stroke-width": 2, "stroke-opacity": 1 },
      "geometry": {
        "type": "LineString",
        "coordinates": [ [ -56.25575065612793, -33.920963256108244 ], [ -56.266350746154785, -33.915710397502636 ], [ -56.26727342605591, -33.916333634946206 ] ]
      }
    },
    {
      "type": "Feature",
      "properties": { "stroke": "#555555", "stroke-width": 2, "stroke-opacity": 1, "fill": "#aa7942", "fill-opacity": 0.5 },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [ -56.267638206481934, -33.91604872696617 ],
            [ -56.2674880027771, -33.915746011193626 ],
            [ -56.267101764678955, -33.91569259065155 ],
            [ -56.266887187957764, -33.916084340515766 ],
            [ -56.26731634140015, -33.916369248376725 ],
            [ -56.267638206481934, -33.91604872696617 ]
          ]
        ]
      }
    },
    {
      "type": "Feature",
      "properties": { "image": "https://www.iconfinder.com/icons/743821/download/png/128" },
      "geometry": {
        "type": "Point",
        "coordinates": [ -56.255128383636475, -33.92120363341416 ]
      }
    },
    {
      "type": "Feature",
      "properties": {"image": "https://www.iconfinder.com/icons/743821/download/png/128"},
      "geometry": {
        "type": "Point",
        "coordinates": [ -56.25525712966919, -33.92058043159128 ]
      }
    },
    {
      "type": "Feature",
      "properties": {"image": "https://www.iconfinder.com/icons/743821/download/png/128"},
      "geometry": {
        "type": "Point",
        "coordinates": [ -56.25671625137329, -33.92085642153236 ]
      }
    },
    {
      "type": "Feature",
      "properties": { "stroke": "#fffb00", "stroke-width": 2, "stroke-opacity": 1 },
      "geometry": {
        "type": "LineString",
        "coordinates": [
          [ -56.25491380691528, -33.92100777047532 ],
          [ -56.25458121299744, -33.92098106185787 ],
          [ -56.254398822784424, -33.9207139752228 ],
          [ -56.25429153442383, -33.91977026240652 ],
          [ -56.25337958335876, -33.91831015782975 ],
          [ -56.252639293670654, -33.917829386212944 ],
          [ -56.252349615097046, -33.91780267659912 ]
        ]
      }
    },
    {
      "type": "Feature",
      "properties": { "stroke": "#0433ff", "stroke-width": 2, "stroke-opacity": 1, "fill": "#0433ff", "fill-opacity": 0.5 },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [ -56.258089542388916, -33.92180012231776 ],
            [ -56.258100271224976, -33.92200488620237 ],
            [ -56.25791788101196, -33.92214733035358 ],
            [ -56.25770330429077, -33.92213842760111 ],
            [ -56.25791788101196, -33.92182683067845 ],
            [ -56.258089542388916, -33.92180012231776 ]
          ]
        ]
      }
    }
  ]
}'
  },
  texts: [
    {
      text: "Simple Farm Map",
      position: {x: 25, y: 0 },
      box_size: {width: 250, height: 25},
      options: {
        fill_color: '#ffffff',
        color: '#000000',
        font: 'Arial',
        pointsize: '20',
        gravity: 'NorthWest',
      }
    }
  ],
  scalebar: {
    unit: 'meters',
    position: {x: 588, y: 543},
    size: {width: 200, height: 40},
    padding: {top: 5, right: 5, bottom: 5, left: 5},
    bar_height: 10,
    background_color: 'black',
    background_opacity: 0.4
  }
}

Lakes

{
  format: 'png',
  png_options: {
    width: 595,
    height: 842,
    background_color: 'white'
  },
  map: {
    ne: {lng: 9.319753646850586, lat: 51.07419409303002},
    sw: {lng: 9.22478199005127, lat: 51.02152985954757},
    zoom: 13,
    position: {
      x: 10,
      y: 50
    },
    size: {
      width: 563,
      height: 768
    },
    layers: [{
      type: 'osm',
      level: 1,
      opacity: 1.0
    }],
    geojson: '{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [9.28018569946289, 51.05987383947526],
            [9.286365509033203, 51.05477573092765],
            [9.290871620178223, 51.054937584270576],
            [9.293575286865234, 51.056232390648105],
            [9.293060302734375, 51.06068301143367],
            [9.280829429626465, 51.0609257602634],
            [9.28018569946289, 51.05987383947526]
          ]
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [9.299626350402832, 51.062624966432985],
            [9.296793937683105, 51.0597929215016],
            [9.300527572631834, 51.056879780259706],
            [9.307866096496582, 51.05582776754445],
            [9.31241512298584, 51.056717933705386],
            [9.314346313476562, 51.05946924819267],
            [9.308252334594727, 51.06440502028951],
            [9.299626350402832, 51.062624966432985]
          ]
        ]
      }
    },
    {
      "type": "Feature",
      "properties": { "image": "https://www.iconfinder.com/icons/743821/download/png/128" },
      "geometry": {
        "type": "Point",
        "coordinates": [9.263405799865723, 51.05882189478636]
      }
    },
    {
      "type": "Feature",
      "properties": { "image": "https://www.iconfinder.com/icons/743821/download/png/128" },
      "geometry": {
        "type": "Point",
        "coordinates": [9.28919792175293, 51.04123199744911]
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [9.266281127929688, 51.04204149517769],
            [9.258899688720703, 51.03516031362447],
            [9.258642196655272, 51.02941171979751],
            [9.263148307800293, 51.02682057115055],
            [9.27220344543457, 51.027063497489635],
            [9.275550842285156, 51.03718429663773],
            [9.266281127929688, 51.04204149517769]
          ]
        ]
      }
    }
  ]
}'
  },
  texts: [
    {
      text: "A few lakes in Germany",
      position: {x: 25, y: 0 },
      box_size: {width: 250, height: 25},
      options: {
        fill_color: '#ffffff',
        color: '#000000',
        font: 'Arial',
        pointsize: '10',
        gravity: 'NorthWest',
      }
    }
  ],
  scalebar: {
    unit: 'meters',
    position: {x: 373, y: 506},
    size: {width: 200, height: 40},
    padding: {top: 5, right: 5, bottom: 5, left: 5},
    bar_height: 10,
    background_color: 'black',
    background_opacity: 0.4
  },
  legend: {
    position: {x: 10, y: 550},
    size: {width: 80, height: 20},
    image_size: {width: 16, height: 32},
    textbox_size: {width: 60, height: 16},
    textbox_style: {
      fill_color: '#000000',
      color: '#000000',
      font: 'Arial',
      pointsize: 3,
      gravity: 'NorthWest',
    },
    orientation: 'horizontal', # horizontal, vertical
    overflow: 'hidden', # expand, hidden, compact
    columns: 1,
    rows: 1,
    elements: [{
      image: 'https://www.iconfinder.com/icons/743821/download/png/128',
      text: 'City'
    }]
  }
}

Clone this wiki locally