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

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

pbicvsupport@microsoft.com

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

pbicvsupport@microsoft.com

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

pbicvsupport@microsoft.com

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

pbicvsupport@microsoft.com

Anonymous
Not applicable

Thanks. It's helps

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.

Top Solution Authors