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.
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,
Solved! Go to Solution.
Regarding the first question you should follow these steps:
"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
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.
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
@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 ?
Are you able to share the code that tries to access a varaible?
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
17 | |
2 | |
2 | |
1 | |
1 |