Modern TypeScript library for creating stunning vector maps
-
πΊοΈ Vector Maps
- High-quality SVG-based interactive maps
- Multiple projection types (Mercator, Equal Earth)
- Built-in world maps and custom regions
-
π Data Visualization
- Choropleth maps with customizable scales
- Heat maps and bubble charts
- Interactive legends and tooltips
-
π― Framework Agnostic
- Zero dependencies
- Works with any framework
- Official React and Vue bindings
-
π Type Safety
- Full TypeScript support
- Strict types for better DX
- Comprehensive type definitions
# Using npm
npm install ts-maps
# Using pnpm
pnpm add ts-maps
# Using yarn
yarn add ts-maps
# Using bun
bun add ts-maps
# React
npm install ts-maps ts-maps-react
# Vue
npm install ts-maps ts-maps-vue
import type { VectorMapOptions } from 'ts-maps'
import { VectorMap } from 'ts-maps'
// Create a map instance
const map = new VectorMap({
container: 'map',
map: 'world',
theme: 'light',
style: {
regions: {
fill: '#e4e4e4',
stroke: '#ffffff',
strokeWidth: 1,
},
hover: {
fill: '#2ca25f',
},
},
})
// Add interactivity
map.on('regionClick', (event, region) => {
console.log(`Clicked: ${region.id}`)
})
import type { DataVisualizationOptions } from 'ts-maps'
import { VectorMap } from 'ts-maps'
const map = new VectorMap({
container: 'map',
map: 'world',
})
// Add data visualization
const options: DataVisualizationOptions = {
scale: ['#e5f5f9', '#2ca25f'], // Color gradient from light blue to green
values: {
US: 100,
CA: 80,
GB: 65,
},
}
map.visualizeData(options)
import type { VectorMapProps } from 'ts-maps-react'
import { useVectorMap } from 'ts-maps-react'
function WorldMap() {
const { map, isLoading } = useVectorMap({
map: 'world',
theme: 'light',
})
return (
<div className="map-container">
{isLoading
? (
<div>Loading...</div>
)
: (
<div id="map" />
)}
</div>
)
}
<script setup lang="ts">
import type { VectorMapOptions } from 'ts-maps'
import { useVectorMap } from 'ts-maps-vue'
const { map, isLoading } = useVectorMap({
map: 'world',
theme: 'light',
})
</script>
<template>
<div class="map-container">
<div v-if="isLoading">
Loading...
</div>
<div v-else id="map" />
</div>
</template>
- Clone the repository:
git clone https://github.com/stacksjs/ts-maps.git
cd ts-maps
- Install dependencies:
pnpm install
- Start development:
pnpm dev
Please see our releases page for more information on what has changed recently.
Please see CONTRIBUTING for details.
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
For casual chit-chat with others using this package:
Join the Stacks Discord Server
βSoftware that is free, but hopes for a postcard.β We love receiving postcards from around the world showing where clarity
is being used! We showcase them on our website too.
Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094, United States π
We would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us.
The MIT License (MIT). Please see LICENSE for more information.
Made with π