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
Contributor
Posts: 34
Registered: ‎10-21-2016

How to find existing Leaflet map in BI-map-panel?

[ Edited ]

 

When I use a BI-map and I want to initiate a new L.map I get the error that a Leaflet object is already initialized. This makes sense, since a map is always initialized when using a BI-map-panel. My problem is: I want to use the existing map, but Leaflet does not seem to have a function to find the current/existing maps.

 

It seems like my situation is as follows:

_Problem when using custom map + external script (Leaflet): the other scripts which are normally included (GVC etc.) aren't included, so I can't make use of them
_Problem when using BI map + no external script (Leaflet is included when using BI map): an L.map-object is already initiated, but I don't know how to find initiated Leaflet maps, so I can not to refer to its id when e.g. doing this:
 
var lmap = new L.map('map', {
    zoomControl: false
}).setView([1,101], 5);
// ...
gvc.dataStage("test").target('map', lmap); //error: map container not found

var layerGroup = L.layerGroup();
layerGroup.addTo(lmap);

Does anyone know how to deal with this? Any help would be appreciated! 

 

Regards,

Vincent

 

Highlighted
Regular Contributor
Posts: 189
Registered: ‎03-04-2016

Re: How to find existing Leaflet map in BI-map-panel?

Hi Vincent,

 

Did you find any solution regarding this?

I'm facing the same question at the moment.

 

Thanks in advance

 

Kind regards,

 

Elodie

Highlighted
Contributor
Posts: 34
Registered: ‎10-21-2016

Re: How to find existing Leaflet map in BI-map-panel?

Hi Elodie,

 

It has been a while since I got this problem, but I worked around the problem (eventually I got it all working) so I looked at the last version of my code. It seems like I do not initiate a new map at all. 

I just use a BI map, and do not refer to Leaflet in the BI Map code. 

 

At this moment I do not know how I could help you exactly, since I don't know what you are trying to achieve. If you are still in need of help, can you elaborate your problem a bit?

 

Kind regards,

Vincent

Highlighted
Regular Contributor
Posts: 189
Registered: ‎03-04-2016

Re: How to find existing Leaflet map in BI-map-panel?

[ Edited ]

Hi Vincent

 

It's really nice of you to give me this update.

 

Actually I'm just wanting to change my polilynes size in my BI Map.

So i thought i could call the concerned layer and change the style.

 

Have you done something like this already?

 

Elodie

Highlighted
Contributor
Posts: 34
Registered: ‎10-21-2016

Re: How to find existing Leaflet map in BI-map-panel?

Hi Elodie,

 

Pleased to help you. What do you mean with the size - do you mean changing the thickness of the polylines? 

 

Vincent 

Highlighted
Regular Contributor
Posts: 189
Registered: ‎03-04-2016

Re: How to find existing Leaflet map in BI-map-panel?

Exactly Smiley Happy

Highlighted
Contributor
Posts: 34
Registered: ‎10-21-2016

Re: How to find existing Leaflet map in BI-map-panel?

I haven't found a way to do this using Leaflet-commands. However, I also needed to do this and used CSS to achieve the desired result. 

 

var choroplethElements = document.getElementsByClassName('leaflet-overlay-pane')[0].getElementsByClassName("leaflet-zoom-animated")[0].getElementsByTagName("g");

for (var i = 0; i < choroplethElements.length; i++) {
	choroplethElements[i].getElementsByTagName("path")[0].style.strokeWidth = 0.4;
}

I don't know if you seek to use 'CSS-hacks', but maybe this can get you into the right direction.

 

Kind regards,

Vincent

Highlighted
Regular Contributor
Posts: 189
Registered: ‎03-04-2016

Re: How to find existing Leaflet map in BI-map-panel?

Hi Vincent,

 

Thanks very much for your answer.

Css is a way to go indeed. I will adapt and try your code.

 

Have a nice day Smiley Happy

 

Kind regards

 

Highlighted
Contributor
Posts: 34
Registered: ‎10-21-2016

Re: How to find existing Leaflet map in BI-map-panel?

Thanks Elodie Smiley Happy You have a nice day as well. 

Let me know if it doesn't work - it might be that the CSS selectors are different in your case.

 

Kind regards

Highlighted
Frequent Contributor
Posts: 83
Registered: ‎07-17-2017

Re: How to find existing Leaflet map in BI-map-panel?

Hi Vincent,

 

I'd like to add a spin from an external library to my bi map during recipe processing. So I'm at the same point as you were a year ago and need the existing leaflet map object. How did you solve it?

Would be great if you could remember and give me a hint :-)

 

Thanks

Marisa