Smart M.App discussions

Looking for answers in regards to M.Apps, M.App Exchange or M.App Studio? Smart M.App Tech Discussion board is where you can search, ask your questions and assist others by sharing your knowledge. Join the conversation, connect, contribute and share.
Showing results for 
Search instead for 
Do you mean 
Reply
Highlighted
Frequent Contributor
Posts: 113
Registered: ‎01-20-2016
Accepted Solution

Add scale bar to BI Map

Hi,

how can I add a scale bar to my BI map?

 

It worked well with leaflet in a custom panel.

 

var mymap = L.map('mapid').setView([51.505, -0.09], 13);
var scaleBar = L.control.scale().addTo(mymap);

 

 

In my BI Map I do not know which div to address. "Map" didn't work and I lost the zooming functionality using mainMap.

 

Any help is appreciated

Ruth

 

Technical Evangelist
Posts: 35
Registered: ‎04-07-2016

Re: Add scale bar to BI Map

Hello Ruth,

 

Scale Bar can be added using Leaflet controls but you must use a private API. To achieve this, paste the following snippet into the customization panel:

 

JS panel:

var scaleBar;
mainContext.switchingMapViewerAdapter.getMapAdapter().then(function(adapter){
scaleBar = L.control.scale({position: "bottomright"}).addTo(adapter.__map);
});

CSS panel:

.leaflet-right {
    right: 0 !important;
    padding: 30px;
    z-index: 1;
}

Scale Bar will appear on bottom-right part of a map.

 

Best regards,

Michał.

Frequent Contributor
Posts: 113
Registered: ‎01-20-2016

Re: Add scale bar to BI Map

Michał,

 

thank you, this works well!

 

Ruth