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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Create Your Own Custom Map for Power BI.

I try to create own custom visual with bing maps. I added script "https://www.bing.com/api/maps/mapcontrol?callback=InitMap"

and div with Id:

this.divMap = d3.select(options.element)
.append('div')
.classed('map', true)
.attr({ id: "map_id"});
 
But when I want to create a global function InitMap. Power Bi doesn't see it. 
 
I did: 
declare function InitMap():void;
And in Visual constructor:
(window as any).InitMap= this.InitMap;
 
This code doesn't want to work.
 
When  I create a new script with the text of function, it's work:
let scriptMapBody = document.createElement('script');
 scriptMapBody.type = "text/javascript"
 scriptMapBody.text = " function InitMap() \
 var map = new Microsoft.Maps.Map(document.getElementById('map_id'),{ \
 credentials: ''});\
}"
 
 
 
Is there any way to create this function in ts code?
 
1 ACCEPTED SOLUTION
v-viig
Community Champion
Community Champion

Please try using API 1.13.0 if it works there.

 

PBI isolation might break some libraries that work by injecting JS from remote hosts.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

[email protected]

View solution in original post

6 REPLIES 6
v-viig
Community Champion
Community Champion

Our suggestion is to check window.InitMap and window.window.InitMap.

 

What Custom Visuals API version are you using?

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

[email protected]

Anonymous
Not applicable

window.InitMap and window.window.InitMap don't help.

v-viig
Community Champion
Community Champion

What API version are you using?

 

Power BI creates a copy of window for isolating Power BI JS from Custom Visual JS. It might be a root cause of this issue.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

[email protected]

Anonymous
Not applicable

I use  API v2.3.0

v-viig
Community Champion
Community Champion

Please try using API 1.13.0 if it works there.

 

PBI isolation might break some libraries that work by injecting JS from remote hosts.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

[email protected]

Anonymous
Not applicable

Thanks. It's helps

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors