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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
ipr20
New Member

Problem Using Leaflet Map In powerbi plugin

I have a problem in using leaflet in powerbi plugin: in the constructor, I can Show the map,mark a location on it and every thing is ok:

 export class Visual implements IVisual {
    private target: HTMLElement;
   private dataView: DataView;
    private map: L.Map;
    private basemap: L.TileLayer;
    private markerLayer: L.LayerGroup<L.CircleMarker>;
constructor(options: VisualConstructorOptions) {        console.log('constructor called');
        this.target.innerHTML='<div id="map" style="height:100vh;width:100vw;"></div>';
        this.basemap = L.tileLayer('http://localhost/mapfiles/{z}/{x}/{y}.png',{    maxZoom: 17,minZoom:10  });

        this.map = L.map('map', {            center: new L.LatLng(35.658, 51.403),            zoom: 12,            maxZoom: 18,            minZoom: 12
        });

        this.map.addLayer(this.basemap);
    }

but! in public update,when (for Ex.)I want to mark another location, this.map is Undefined! and also Click event returns errors about "function not found" or "MouseEvent" is not declared.. I think the exact problem is after I add the layer to the map, Leaflet loses the map and cant find it again for editing! what can I do? is this a conflict between TS and JS?

[sorry for my grammer:) English is not my primary language]

2 REPLIES 2
ipr20
New Member

I have a problem in using leaflet in powerbi plugin: in the constructor, I can Show the map,mark a location on it and every thing is ok:

 export class Visual implements IVisual {
    private target: HTMLElement;
   private dataView: DataView;
    private map: L.Map;
    private basemap: L.TileLayer;
    private markerLayer: L.LayerGroup<L.CircleMarker>;
constructor(options: VisualConstructorOptions) {        console.log('constructor called');
        this.target.innerHTML='<div id="map" style="height:100vh;width:100vw;"></div>';
        this.basemap = L.tileLayer('http://localhost/mapfiles/{z}/{x}/{y}.png',{    maxZoom: 17,minZoom:10  });

        this.map = L.map('map', {            center: new L.LatLng(35.658, 51.403),            zoom: 12,            maxZoom: 18,            minZoom: 12
        });

        this.map.addLayer(this.basemap);
    }

but! in public update,when (for Ex.)I want to mark another location, this.map is Undefined! and also Click event returns errors about "function not found" or "MouseEvent" is not declared.. I think the exact problem is after I add the layer to the map, Leaflet loses the map and cant find it again for editing! what can I do? is this a conflict between TS and JS?

[sorry for my poor grammer:) English is not my primary language]

v-viig
Community Champion
Community Champion

It looks like there is a JS exception that.

 

We recommend to put debugger statement into constructor to debug visual step by step.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.