How to access this method?

Hi all,

This has me stumped, mainly because of my knowledge with JavaScript and the Plugin Editor right now, but I’m getting there.

So, what I hope will be a simple question is this.

I’m using the following in my script header section:

<script src="https://cdn.jsdelivr.net/npm/leaflet-compass@1.5.5/dist/leaflet-compass.src.js"></script>

And I can successfully use that in one my functions like this:

When I run it, it gives us a pretty little compass in the top right corner…

image

Now according to that script, (below) there’s a few methods in it, one of which is called setAngle but I don’t know how to give it a value or access any of them for that matter in my Bubble function.

Does anyone know how to do it? I’ve been sitting here for a while now trying to read up/try various ways/etc and I thought I could just access it by using something like:

compass.setAngle(90);

All that does is give me a nice error saying “TypeError: compass.setAngle is not a function”

Just going through the process of learning some of these things, not quite there yet but this type of problem I have is what I hope to be, once you know how to do it you won’t have it again!

Thanks
Paul

Where is the setAngle() method being invoked? I don’t see it in the screenshot.

1 Like

Well, that’s the thing I’m really not sure. Right now, I’m playing with this and just looking through the Console

Bit of guess work on my behalf, you can attempt to run that when you go here:
https://parksmart-testing.bubbleapps.io/version-test

I managed to get it working, thanks @sudsy.
This did the trick, I know how to deal with it now.

function(instance, properties, context) {
    
    compass = new L.Control.Compass({autoActive: true, showDigit: true}).addTo(instance.data.mymap);
    compass.setAngle(90);
    
} 

Thanks
Paul

But that’s precisely what you said in your original post that you tried and didn’t work. :confused:

Anyway, glad you’re on your way. :slightly_smiling_face:

Thanks, I think it must have been something to do with the way I had my first line.
Previously it was:

compass = instance.data.mymap.addControl(new L.Control.Compass({autoActive: true, showDigit: true}));

When it was changed to this, it worked…

compass = new L.Control.Compass({autoActive: true, showDigit: true}).addTo(instance.data.mymap);

1 Like