# svg2marker

> Parse SVG path to G/Marker path array

Latest version **0.1.3** (published 2019-11-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install svg2marker
pnpm add svg2marker
yarn add svg2marker
bun add svg2marker
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2019-11-06 |
| First published | 2019-11-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 10.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Maintainers | zqlu |

## Links

- npm: https://www.npmjs.com/package/svg2marker
- Repository: https://github.com/zqlu/svg2marker
- Homepage: https://github.com/zqlu/svg2marker#readme
- Issues: https://github.com/zqlu/svg2marker/issues
- npm.io page: https://npm.io/package/svg2marker

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.11
- [svg-path-parser](https://npm.io/package/svg-path-parser.md) ^1.1.0

## Recent versions

- 0.1.3 (latest) — 2019-11-06

## README

# svg2marker

Convert SVG icon to G/Marker register

## Usage

### 对g2 3.x开源版本

```js
import { G } from '@antv/g2';
import svg2marker from '@alipay/svg2marker';
import plus from './icons/plus.svg'

// 注册 plus symbol
G.Marker.Symbols['plus'] = svg2marker(plus);

// 绘制 svg
container.addShape('Marker', {
    attrs: {
        symbol: 'plus',
        x: 10,
        y: 10,
        r: 10
    }
});
```

### 对g2 4.x TS版本

```js
import { G } from '@antv/g2';
import svg2marker from '@alipay/svg2marker';
import plus from './icons/plus.svg';

// 注册 plus symbol
G.Marker.symbolsFactory.register('rise', svg2marker(plus));

// 绘制 svg
container.addShape('Marker', {
    attrs: {
        symbol: 'plus',
        x: 10,
        y: 10,
        r: 10
    }
});
```

## FAQ
- 为什么报错`${symbol} marker is not supported.`？

因为注册的G和绘图的G不一致导致的，应该改为同一个G引用
```js
 import { G } from '@antv/g6';
 import { G } from '@antv/g2';
 
```
## LICENSE

MIT

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