datamaps icon indicating copy to clipboard operation
datamaps copied to clipboard

How to use it with Vue?

Open hifall opened this issue 7 years ago • 4 comments

I am new to datamaps and to Vue (sort of). I'd like to use datamaps inside a Vue-based app. How would I go about doing it?

Thanks!

hifall avatar Jun 05 '18 10:06 hifall

This example might help https://gist.github.com/baranovxyz/b71a097d87c08983c4df2340447c4e11

baranovxyz avatar Jun 20 '18 08:06 baranovxyz

@baranovxyz Do yo know, by chance, how to properly import datamaps in a Vue+Typescript project? I'm getting errors that way, but the script itself works. The "clean" way would be import 'datamaps'; but that way I cannot initialize the map.

Edit:
Using require in the constructor of the specific Vue component made it for me.

class xyz {
    private DataMap: any;
    private myMap!: any;

    constructor() {
        this.DataMap = require('datamaps');
    }

    public mounted() {
        this.myMap = new this.DataMap({
            // ...
        });
    }
}

3c7 avatar Jun 24 '18 12:06 3c7

@3c7 No, I don't, have not used TS in a while.

baranovxyz avatar Jun 24 '18 14:06 baranovxyz

@hifall It is not perfect but consider VueDatamaps.

Seungwoo321 avatar Feb 06 '20 15:02 Seungwoo321