cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
skizofre3e Member
Member

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

Accepted Solutions
Moderator v-viig
Moderator

Re: Load GeoJson Map to capabilities.json

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

23 REPLIES 23
Community Support Team
Community Support Team

Re: Load GeoJson Map to capabilities.json

@skizofre3e,

 

You may do research into objects in API https://github.com/Microsoft/PowerBI-visuals-tools/blob/master/templates/visuals/.api/v1.6.0/schema..... Also check if a Shape Map visual could be an alternative.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
skizofre3e Member
Member

Re: Load GeoJson Map to capabilities.json

Shape file could be an alternative but is its source code available for developement ? In Fact I'm looking to load a geojson map and display it using d3 Library .. But I don't know how to load the json file.

Moderator v-viig
Moderator

Re: Load GeoJson Map to capabilities.json

Hello @skizofre3e

 

Do you want to load json file from local computer or do you want to save it using Power BI Data sets?

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

skizofre3e Member
Member

Re: Load GeoJson Map to capabilities.json

Either way, for now, I just want to display a custom map. So it can either be load from a local file, or through a drap and drop via Power BI.

 

 

Thank you for your help Smiley Happy

Moderator v-viig
Moderator

Re: Load GeoJson Map to capabilities.json

@skizofre3e,

 

You might load local file using FileReader.

 

Please feel free to ask us any questions about custom visual development.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

skizofre3e Member
Member

Re: Load GeoJson Map to capabilities.json

Thank you for you response. I'm talking about loading a file within a custom visual and not a web page. Apparently, I should use an object within capabilities but I don't know which one.

 

Moderator v-viig
Moderator

Re: Load GeoJson Map to capabilities.json

@skizofre3e,

 

I'm not sure that understand your case well.

Do you want to upload and save a file in Power BI? Is that correct?

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

skizofre3e Member
Member

Re: Load GeoJson Map to capabilities.json

I'm developing a custom visual that is displaying a shape map.

I want to know how I can upload the .geojson map into my custom visual.

In other words, how I can upload a file into my custom visual. I know that I can achieve that through defining an object in capabilities.json file. but I don't know how.

Moderator v-viig
Moderator

Re: Load GeoJson Map to capabilities.json

@skizofre3e

 

Just to make sure that my understaning is correct.

You want to have an ability to load a file by using the format panel. Is that correct?

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com