Read-only mirror of https://github.com/gisktzh/cim-symbol-to-svg — Kanton Zürich. Issues & pull requests at the source.
  • TypeScript 98.8%
  • JavaScript 1.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Pascal Thormeier 6dfd4a7fe3
Merge pull request #1 from Tugark/patch-1
Update README.md
2026-03-05 09:28:16 +01:00
.github/workflows Cleanup README and fix pipeline. 2025-11-12 12:24:22 +00:00
bin Update to @arcgis/core 5.0.0 2026-03-03 17:01:21 +00:00
src Update to @arcgis/core 5.0.0 2026-03-03 17:01:21 +00:00
test Update to @arcgis/core 5.0.0 2026-03-03 17:01:21 +00:00
.gitignore Prepare release on npmjs 2026-03-04 16:07:11 +00:00
.nvmrc Update to @arcgis/core 5.0.0 2026-03-03 17:01:21 +00:00
.prettierignore Initial commit: Add lib, tests, linting, etc. 2025-11-12 12:18:51 +00:00
.prettierrc Initial commit: Add lib, tests, linting, etc. 2025-11-12 12:18:51 +00:00
esbuild.config.mjs Initial commit: Add lib, tests, linting, etc. 2025-11-12 12:18:51 +00:00
eslint.config.mts Initial commit: Add lib, tests, linting, etc. 2025-11-12 12:18:51 +00:00
LICENSE.md Initial commit: Add lib, tests, linting, etc. 2025-11-12 12:18:51 +00:00
package-lock.json chore: release v1.0.1 2026-03-04 16:10:43 +00:00
package.json chore: release v1.0.1 2026-03-04 16:10:43 +00:00
README.md Update README.md 2026-03-05 09:27:06 +01:00
tsconfig.json Update to @arcgis/core 5.0.0 2026-03-03 17:01:21 +00:00
vitest.config.ts Initial commit: Add lib, tests, linting, etc. 2025-11-12 12:18:51 +00:00

gisktzh/cim-to-svg

Library to convert @arcgis/core CIMSymbols to SVGs.

Installation

To install the library, execute the following command in the project root:

npm i @gisktzh/cim-symbol-to-svg

Usage

IMPORTANT: This library is meant to be used in the browser. If you need to use it in a server environment, make sure you install and configure jsdom.

  • Include the library's main function:

    import cimSymbolToSVG from '@gisktzh/cim-symbol-to-svg'
    
  • Use it, for example, with a loaded WebSymbol:

    const webStyleSymbol = new WebStyleSymbol({
      name: 'Gorilla',
      styleUrl: 'https://cdn.arcgis.com/sharing/rest/content/items/1fbb242c54e4415d9b8e8a343ca7a9d0/data',
    })
    
    const cimSymbol = await webStyleSymbol.fetchSymbol({ acceptedFormats: ['cim'] }) as CIMSymbol
    
    const svgElement = cimSymbolToSVG(cimSymbol)
    

Currently unsupported features

Since they're rather complex, the following features are not supported currently:

  • Rectangualr gradients
  • AcrossLine gradients
  • AlongLine gradients
  • Color substitution in pictures

Everything else should work according to specs.

Please keep in mind that certain CIMSymbols, such as backgrounds, hatches, etc. provide an SVG which can be used as backgrounds for other SVGs only, since they themselves do not offer any geometry!

Development

  • To get started developing in this library, clone the repository:
    git clone https://github.com/gisktzh/cim-to-svg
    
  • Ensure that you're running the correct Node version (either via nvm use or by installing the Node version specified in .nvmrc)
  • Install dependencies:
    npm install
    
  • Run tests to ensure your changes work:
    npm run test
    

Contribution

If you want to contribute to this library, please feel free to open Pull Requests or Issues here on Github.

License

BSD 3-Clause License, see LICENSE.md