Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Load GeoJson Map to capabilities.json

Hello,

 

I'm currently developing a custom visual, so I'm looking to load a geojson map through capabilities.json. My question is: how can I achieve that ? Shall I just consider the map as measure ?

 

Thank you,

1 ACCEPTED SOLUTION
v-viig
Community Champion
Community Champion

Regarding the first question you should follow these steps:

  • Take a look at this topic to find out more about JS File API
  • Define a text property at capabilities.json

 

"objects": {
    "internalState": {
        "displayName": "Internal State",
        "properties": {
            "geojsonMap": {
                "displayName": "geojsonMap",
                "type": {
                    "text": true
                }
            }
        }
    }
}
function save(host: IVisualHost, value: string) {
    host.persistProperties(<VisualObjectInstancesToPersist>{
        merge: [{
            objectName: "internalState",
            selector: null,
            properties: {
                geojsonMap: value || ""
            }
        }]
    });
}

 

Regarding the second question.

You should prepare type definitions for you function. Another way is to use TS file instead of JS.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

View solution in original post

24 REPLIES 24
Anonymous
Not applicable

@v-viig

You can use JS File API to load from local device/PC

    This option, how does it work ?
Keep it in an external JS and include into pbiviz.json

    Exactly I was thinking of this one, I tried it but it doesnt work. I stored the map data as a variable in a file map.js. I referenced it in pbiviz.json. And I use the variable in Main.ts file. But It couldn't find the variable.

v-viig
Community Champion
Community Champion

Please take a look at FileReader to find out more about File API.

 

How did you try to access the variable? What errors did you get?

I suppose that you should use window["variableName"] to find it. Another option is to declare the varaible in TypeScript in order to get rid of type checking errors.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

Anonymous
Not applicable

@v-viig I tried to access the variable directly but it couldn't find it, I referenced it in pbiviz.json .

I have another problem with the organization of my code. I only instanciated the map in the constructor, and handled everything else in the update method. How should I organize my code is it kind of MVC ? 

v-viig
Community Champion
Community Champion

Are you able to share the code that tries to access a varaible?

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.