# mapnik-style-parser

> Parse JSON data to XML Mapnik Style.

Latest version **1.1.1** (published 2016-10-19) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install mapnik-style-parser
pnpm add mapnik-style-parser
yarn add mapnik-style-parser
bun add mapnik-style-parser
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2016-10-19 |
| First published | 2016-09-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | André Moraes |
| Maintainers | andrelom |
| Keywords | mapnik, style, parser, json, xml, node |

## Links

- npm: https://www.npmjs.com/package/mapnik-style-parser
- Repository: https://github.com/andrelom/mapnik-style-parser
- Homepage: https://github.com/andrelom/mapnik-style-parser#readme
- Issues: https://github.com/andrelom/mapnik-style-parser/issues
- npm.io page: https://npm.io/package/mapnik-style-parser

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.16.3
- [pretty-data](https://npm.io/package/pretty-data.md) ^0.40.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.1.1 (latest) — 2016-10-19
- 1.0.1 — 2016-10-05
- 1.0.0 — 2016-09-29

## README

# Mapnik Style Parser

Parse JSON data to XML Mapnik Style.

## Installation

Install using the NPM:

```
npm install -S mapnik-style-parser
```

## Usage Example

A simple use case:

```javascript
import StyleParser from 'mapnik-style-parser';

StyleParser.toXML({
  attributes: [
    { name: 'background-color', value: 'blue' },
    { name: 'srs', value: '+init=epsg:4326' }
  ],
  styles: [{
    attributes: [{ name: 'name', value: 'My Style' }],
    rules: [{
      name: 'PolygonSymbolizer',
      parameters: [{ name: 'fill', value: '#F2EFF9' }]
    }, {
      name: 'LineSymbolizer',
      parameters: [
        { name: 'stroke', value: 'RGB(50%, 50%, 50%)' },
        { name: 'stroke-width', value: '0.1' }
      ]
    }]
  }],
  layers: [{
    attributes: [
      { name: 'name', value: 'world' },
      { name: 'srs', value: '+init=epsg:4326' }
    ],
    styles: ['My Style'],
    datasource: {
      parameters: [
        { name: 'type', value: 'shape' },
        { name: 'file', value: 'path/to/shapefile.shp' }
      ]
    }
  }]
});
```

Will produce the XML:

```xml
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE Map>
<Map background-color="blue" srs="+init=epsg:4326">
  <Style name="My Style">
    <Rule>
      <PolygonSymbolizer>
        <CssParameter name="fill">#F2EFF9</CssParameter>
      </PolygonSymbolizer>
      <LineSymbolizer>
        <CssParameter name="stroke">RGB(50%, 50%, 50%)</CssParameter>
        <CssParameter name="stroke-width">0.1</CssParameter>
      </LineSymbolizer>
    </Rule>
  </Style>
  <Layer name="world" srs="+init=epsg:4326">
    <StyleName>My Style</StyleName>
    <Datasource>
      <Parameter name="type">shape</Parameter>
      <Parameter name="file">path/to/shapefile.shp</Parameter>
    </Datasource>
  </Layer>
</Map>
```

## License

MIT

---
_Source: https://npm.io/package/mapnik-style-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
