Nuclear Potato Monster

    clevermaps-js-sdk

    2.0.1 • Public • Published

    The sdk manages clevermaps app in iframes.

    Installation

    npm i 'clevermaps-js-sdk'
    

    Example

    // import sdk library as a dependency
    import cmSdk from 'clevermaps-js-sdk';
    
    // create new sdk instance connected to 'https://secure.clevermaps.io/'
    const sdk = cmSdk('https://secure.clevermaps.io/');
    
    // invoke authentiaction
    // async method
    await sdk.authenticate();
    
    // call iframe factory method to create a new one
    // it constructs the url: https://secure.clevermaps.io/#/ra65qrdk8u9o8g69/map/catchment_area_view?shareId=dftdloihl09eneyj
    const iframe1 = sdk.createIframe('ra65qrdk8u9o8g69/map/catchment_area_view?shareId=dftdloihl09eneyj');
    // share id is optional
    const iframe2 = sdk.createIframe('ra65qrdk8u9o8g69/map/catchment_area_view');
    
    // render iframes into dom
    // first parameter is id of the container element
    // the second one is a instance of the iframe
    sdk.renderIframe('div_a', iframe1);
    sdk.renderIframe('div_b', iframe1); // you can render one frame into multiple elements
    sdk.renderIframe('div_c', iframe2);
    
    // you can change iframe state
    // will change immediately in dom
    iframe1.setState('ra65qrdk8u9o8g69/map/catchment_area_view?shareId=dftdloihl09eneyj'); 
    
    // you can change filters of CM within iframe
    iframe1.message.addFilter('clients.sex_name', ['Female'], 'filterId1') // initially set filter value
    iframe1.message.setFilter('filterId1', ['Male']) // update filter value
    iframe1.message.resetFilter('filterId1')
    iframe1.message.removeFilter('filterId1')
    
    // remove iframe from the element id 'div_a'
    sdk.removeIframe('div_a', iframe1);  
    

    Keywords

    none

    Install

    npm i clevermaps-js-sdk

    DownloadsWeekly Downloads

    4

    Version

    2.0.1

    License

    MIT

    Unpacked Size

    283 kB

    Total Files

    5

    Last publish

    Collaborators

    • jiriclevermaps
    • ondrejvelisek
    • marekherda