npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@profesia/vue-map-component

v0.2.8

Published

Vue Component for svg maps

Downloads

11

Readme

vue-map-component

npm npm total vue2

Install

NPM

Install the package:

npm install @profesia/vue-map-component --save-dev

Then import it in your project

import Vue from 'vue'
import Vuex from 'vuex';
import store from './store';
import mapComponent from '@profesia/vue-map-component'

Vue.use(Vuex);

new Vue({
    el: '#app',

    store,
    
    components: {
        mapComponent,
    },
});
example of empty store
import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex)

export default new Vuex.Store({})

Browser global

You can't just include the script, because the script needs VUEX, so you have to add it in your scripts and run NPM build (or webpack, gulp, ...).

Usage

Simply use it like so:

<map-component name="myMap" country="slovakia" :regions="slovakRegions" :showAllPins="true" :showOffersCount="true"></map-component>

Options

name

Mandatory. Name will be used to create namespace for each map component.

country

Mandatory. Name of the country.

regions

Optional. An object for storage the info about regions. Object keys can be these: offersCount - for display the number of offers in each region pin - for custom html for region pins link - for redirect page on another page after click on the region

computed: {
    slovakRegions() {
        return {
            'ba': {
                'offersCount': 5,
                'link': 'https://www.example.com'
            },
            'za': {
                'offersCount': 2,
            },
            'ke': {
                'offersCount': 0,
            }
        }
    },
}
showCountryBorder

Optional. A boolean parameter. If true, the path around country will be shown. Defaults to false.

showPin

Optional. A boolean parameter. If true, the empty pins will be positioned in to the map. If one from other parameters (showAllPins, showRegionName, showOffersCount, showRegionNameWithOffersCount) will be set to true, showPin will be set to true automatically. Defaults to false.

showAllPins

Optional. A boolean parameter. If true, the map will show pin on each region. If false, only the regions with offers will show the pin (you have to set object regions with key offersCount). Defaults to false.

showRegionName

Optional. A boolean parameter. If true, the map will show region shortcut in the pin, for example BA, KE, ... Defaults to false.

showOffersCount

Optional. A boolean parameter. If true, the map will show offers count in the pin for each region, (you have to set object regions with key offersCount). Defaults to false.

showRegionNameWithOffersCount

Optional. A boolean parameter. If true, the map will show offers count in the pin for each region on small devices, on desktop the map will show the region shortcut and the offers count will show on region mouse hover (you have to set object regions with key offersCount). Defaults to false.

customClass

Optional. String parameter, you can add some custom class.

Settings - VUEX store mutations

Select option

There is possibility to set (select) region. You need to commit a mutation with name based on your name. Structure of mutation name is vueMap + your name +/setActiveRegion, so if name is Example, you have to call mutation with name vueMapExample/setActiveRegion.

store.commit('vueMapExample/setActiveRegion', ['ba', 'ke']);
Listening for selected regions

You need to listen for state with name based on your nme: vueMap + your name +/activeRegion.

store.state.vueMapExample.activeRegion 

Structure

Once the select has been rendered, it'll create the following structure:

HTML

Single map
<div class="vue-map-component vue-map-show-all-pins">
    <div class="vue-map-container">
        <svg viewBox="0 0 209 100" xmlns="http://www.w3.org/2000/svg">
            <g>
                <a href="" class=""><path class="vue-map-region vue-map-region-ba" d="..."></path></a>
                <a href="" class=""><path class="vue-map-region vue-map-region-tt" d="..."></path></a>
                <a href="" class=""><path class="vue-map-region vue-map-region-nr" d="..."></path></a>
                <a href="" class=""><path class="vue-map-region vue-map-region-tn" d="..."></path></a>
                <a href="" class=""><path class="vue-map-region vue-map-region-bb" d="..."></path></a>
                <a href="" class=""><path class="vue-map-region vue-map-region-ke" d="..."></path></a>
                <a href="" class=""><path class="vue-map-region vue-map-region-po" d="..."></path></a>
                <a href="" class=""><path class="vue-map-region vue-map-region-za" d="..."></path></a>
            </g>
        </svg> 
        <a href="" class="vue-map-pin vue-map-pin-ba"></a>
        <a href="" class="vue-map-pin vue-map-pin-tt"></a>
        <a href="" class="vue-map-pin vue-map-pin-nr"></a>
        <a href="" class="vue-map-pin vue-map-pin-tn"></a>
        <a href="" class="vue-map-pin vue-map-pin-bb"></a>
        <a href="" class="vue-map-pin vue-map-pin-za"></a>
        <a href="" class="vue-map-pin vue-map-pin-po"></a>
        <a href="" class="vue-map-pin vue-map-pin-ke"></a>
    </div>
</div>

CSS

All CSS is based upon this structure.

.vue-map-component {
  ...
}

.vue-map-component g {
  ...
}

.vue-map-pin {
  ...
}

FAQ

  • How can I provide feedback? - Send an email to [email protected]; any feedback is appreciated.

Release History

  • 0.2.8 Add country border
  • 0.2.6 Remove unnecessary async call
  • 0.2.5 Fix BUG with undefined regions offer counts
  • 0.2.4 Fix BUG with undefined regions when they were not necessary
  • 0.2.3 Rename data to data-map
  • 0.2.2 Add data region-id to pin
  • 0.2.1 Add data offers-count to pin
  • 0.2.0 Add new class vue-map-active-region when some region is active
  • 0.1.2 Change babel preset to env
  • 0.1.1 Remove SPAN tags from SVG
  • 0.1.0 Replace A tags with SPAN tags
  • 0.0.8 Fix styles
  • 0.0.7 Create mixin Less file
  • 0.0.6 Fix styles path
  • 0.0.5 Edit styles, separate styles for Slovakia Map Component
  • 0.0.4 svg map with bigger coordinates
  • 0.0.3 Fix warning - Props with type Object/Array must use a factory function to return the default value
  • 0.0.2 Edit README
  • 0.0.1 Initial release