All Projects → VictorCazanave → Vue Svg Map

VictorCazanave / Vue Svg Map

Licence: mit
A set of Vue.js components to display an interactive SVG map

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Vue Svg Map

React Svg Map
A set of React.js components to display an interactive SVG map
Stars: ✭ 150 (+212.5%)
Mutual labels:  svg, interactive, component, map, checkbox
Svg World Map
🗺 A JavaScript library to easily integrate one or more SVG world maps with all nations (countries) and second-level political subdivisions (countries, provinces, states).
Stars: ✭ 38 (-20.83%)
Mutual labels:  svg, interactive, map
Vue Calendar Heatmap
A lightweight calendar heatmap Vuejs component built on SVG, inspired by github's contribution calendar graph
Stars: ✭ 120 (+150%)
Mutual labels:  svg, component
Vue Content Loader
SVG component to create placeholder loading, like Facebook cards loading.
Stars: ✭ 2,790 (+5712.5%)
Mutual labels:  svg, component
Ngx Treeview
An Angular treeview component with checkbox
Stars: ✭ 312 (+550%)
Mutual labels:  component, checkbox
Apexcharts.js
📊 Interactive JavaScript Charts built on SVG
Stars: ✭ 10,991 (+22797.92%)
Mutual labels:  svg, interactive
Geojson2svg
Converts geojson to svg string given svg viewport size and maps extent.
Stars: ✭ 117 (+143.75%)
Mutual labels:  svg, map
Svgmap
svg地图组件,完整版包含城市及区县数据及更多扩展功能。。。
Stars: ✭ 298 (+520.83%)
Mutual labels:  svg, map
Ember Toggle
Checkbox based Toggle Switches for Ember
Stars: ✭ 111 (+131.25%)
Mutual labels:  component, checkbox
React Planner
✏️ A React Component for plans design. Draw a 2D floorplan and navigate it in 3D mode.
Stars: ✭ 846 (+1662.5%)
Mutual labels:  svg, component
Google Map React
Google map library for react that allows rendering components as markers 🎉
Stars: ✭ 5,529 (+11418.75%)
Mutual labels:  component, map
Respin
React SVG loading spinner based on jxnblk.com/loading
Stars: ✭ 21 (-56.25%)
Mutual labels:  svg, component
Landscapeapp
🌄Upstream landscape generation application
Stars: ✭ 96 (+100%)
Mutual labels:  svg, interactive
React Usa Map
React component with all USA States with customizable options. No D3 needed.
Stars: ✭ 63 (+31.25%)
Mutual labels:  svg, map
Any Ui
❄️ 一个移动端组件库
Stars: ✭ 58 (+20.83%)
Mutual labels:  svg, component
react-vector-maps
🗺 A React component for interactive vector maps of the world and 100+ countries
Stars: ✭ 112 (+133.33%)
Mutual labels:  map, interactive
React Qmap
💡react腾讯地图开源组件
Stars: ✭ 60 (+25%)
Mutual labels:  component, map
Github Corners
A fresher "Fork me on GitHub" callout.
Stars: ✭ 4,583 (+9447.92%)
Mutual labels:  svg, interactive
Jquery Mapael
jQuery plugin based on raphael.js that allows you to display dynamic vector maps
Stars: ✭ 981 (+1943.75%)
Mutual labels:  svg, map
Svg To Component
Convert SVG to React/Vue components
Stars: ✭ 40 (-16.67%)
Mutual labels:  svg, component

vue-svg-map

npm version Build Status codecov Dependency Status peerDependencies Status

A set of Vue.js components to display an interactive SVG map.

Vue SVG Map

Demo

Take a look at the live demo!

Installation

npm

npm install --save vue-svg-map

yarn

yarn add vue-svg-map

Usage

Install the map you need from svg-maps or use your own map. See maps section for more details.

🌍 Simple SVG Map

This is the base component to display an SVG map.

In a SFC (Single File Component):

  • Import SvgMap component from vue-svg-map
  • Import the map you want
  • Optionally, import vue-svg-map/dist/index.css if you want to apply the default styles
<template>
	<svg-map :map="Taiwan" />
</template>

<script>
import { SvgMap } from "vue-svg-map";
import Taiwan from "@svg-maps/taiwan";

export default {
	name: "MyMap",
	components: {
		SvgMap
	},
	data() {
		return {
			Taiwan
		};
	}
};
</script>

<style src="vue-svg-map/dist/index.css"></style>

Props

Prop Type Default Description
map Object required Describe SVG map to display. See maps section for more details.
location-class String|Function null CSS class of each <path>. The function parameters are the location object and the location index.
location-tabindex String|Function null Tabindex each <path>. The function parameters are the location object and the location index.
location-role String null ARIA role of each <path>.
is-location-selected Function null Executed to determine if a location is selected. This property is used to set the aria-checked HTML attribute.

Note: other HTML attributes (e.g. style, title, data-*...) can be added to and customized for each <path> modifying the map object.

Events

All the listeners (click, keypress...) are applied to each location.

Slots

There are 2 named slots:

  • before which is before the locations
  • after which is after the locations

☑️ Checkbox SVG Map

This is an implementation of SvgMap that behaves like a group of checkboxes.
It is based on this WAI-ARIA example to support keyboard navigation and be accessible.

  • Import CheckboxSvgMap component from vue-svg-map
  • Import the map you want
  • Optionally, import vue-svg-map/dist/index.css if you want to apply the default styles
<template>
	<checkbox-svg-map v-model="selectedLocations" :map="Taiwan" />
</template>

<script>
import { CheckboxSvgMap } from "vue-svg-map";
import Taiwan from "@svg-maps/taiwan";

export default {
	name: "MyCheckboxMap",
	components: {
		CheckboxSvgMap
	},
	data() {
		return {
			Taiwan,
			selectedLocations: []
		};
	}
};
</script>

<style src="vue-svg-map/dist/index.css"></style>

Props

Prop Type Default Description
map Object required Describe SVG map to display. See maps section for more details.
value String[] [] List of ids of selected locations. Used for v-model.
location-class String|Function null CSS class of each <path>. The function parameters are the location object and the location index.

Note: other HTML attributes (e.g. style, title, data-*...) can be added to and customized for each <path> modifying the map object.

Events

Like for SvgMap all the listeners (click, keypress...) are applied to each location.

Event Output Description
change String[] Emits the new list of ids when a location is selected/unselected. Used for v-model.

Slots

Like in SvgMap there are 2 named slots:

  • before which is before the locations
  • after which is after the locations

Note: inserting focusable elements may break the checkboxes' behaviour.

🔘 Radio SVG Map

This is an implementation of SvgMap that behaves like a group of radio buttons.
It is based on this WAI-ARIA example to support keyboard navigation and be accessible.

  • Import RadioSvgMap component from vue-svg-map
  • Import the map you want
  • Optionally, import vue-svg-map/dist/index.css if you want to apply the default styles
<template>
	<radio-svg-map v-model="selectedLocation" :map="Taiwan" />
</template>

<script>
import { RadioSvgMap } from "vue-svg-map";
import Taiwan from "@svg-maps/taiwan";

export default {
	name: "MyRadioMap",
	components: {
		RadioSvgMap
	},
	data() {
		return {
			Taiwan,
			selectedLocation: null
		};
	}
};
</script>

<style src="vue-svg-map/dist/index.css"></style>

Props

Prop Type Default Description
map Object required Describe SVG map to display. See maps section for more details.
value String null Id of selected location. Used for v-model.
location-class String|Function null CSS class of each <path>. The function parameters are the location object and the location index.

Note: other HTML attributes (e.g. style, title, data-*...) can be added to and customized for each <path> modifying the map object.

Events

Like for SvgMap all the listeners (click, keypress...) are applied to each location.

Event Output Description
change String Emits the new id when a location is selected. Used for v-model.

Slots

Like in SvgMap there are 2 named slots:

  • before which is before the locations
  • after which is after the locations

Note: inserting focusable elements may break the radio buttons' behaviour.

Maps

Existing maps

All the existing maps are in an independant svg-maps project because they may be useful for other components/projects.

Custom maps

You can modify existing maps or create your own.

Modify a map

  1. Import the map to modify
  2. Create a new object from this map
  3. Pass this new object as map prop of the component
<template>
	<svg-map :map="customTaiwan" />
</template>

<script>
import { SvgMap } from "vue-svg-map";
import Taiwan from "@svg-maps/taiwan";

export default {
	name: "MyMap",
	components: {
		SvgMap
	},
	data() {
		return {
			customTaiwan: {
				...Taiwan,
				label: "Custom map label",
				locations: Taiwan.locations.map(location => {
					// Modify each location to customize/add attributes of <path>
				})
			}
		};
	}
};
</script>

It is recommended to not modify the SVG properties (viewBox, path), because it may break the map's display.

Create a map

If you create a new map (other country, city...), feel free to contribute to svg-maps project!

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].