Hide error message of current location block

Hey,

in a project I'm working on, I want to get the current real-world coordinates of the user using the "current location" block from the "Web services access (https)" library.
The program already works, but when the user denies access to their location to the website, or their device doesn't have GPS, it of course doesn't return their location. That by itself is fine, I don't actually need their location, I can just make a special case for when I can't get their location.
The problem is that, whenever the block fails to get the user's location, a pop-up appears, with the text "Warning: Geolocation failed."
This doesn't impact the program directly, but I don't want that pop-up to appear every time the block fails to get the location, when I already have a fail-safe in place.

You can test it out by adding the "Web services access (https)" library and copying the following script:
when :triangular_flag_on_post: clicked:
say (current location)

(I would have added an image here, but it seems I'm not a trusted enough user yet.)

When running the program, if your device has geolocation, it should ask you for permission to see your location. If it doesn't you might have already given it permission at some point, try again in a private window.

What I'm looking for is something like a try-catch, or just some way to stop the pop-up from appearing.

Thank you for your time.

Try (pun intended) adding in the Catch Errors library

Thank you, I'll try that and get back to you.

No, that changes nothing. Even in that 'safely try' block, the pop-up shows up.

no-there is no way to prevent this.

I'll just have to deal with it then. Thanks for the confirmation, the way I know myself I would have probably put a few more hours into trying to solve it.

:)

I believe I know what you're referring to, it pops up a modal that's similar to "opening project" or "saving project". This is in the JS code of the library, and you would need to modify the library itself in order to prevent this. This wouldn't be a problem if it was normal snap blocks, but the geolocation scripts in the library, obviously, uses javascript.

Since the user is likely not going to be changing their location while using the project, you can get away with running the block once and storing it in a variable. That way the message will show once, and not every time you want to use their location.

Is there a way for me to edit the Javascipt? I don't have much experience with that language specifically, but I'm pretty confident I'll be able to change it if I get access to the code.

just use snapblocks!
[sb] when flag clicked [/sb]
when flag clicked

you can, but then users can no longer use the project without enabling JS extensions first in the settings, so they cant use the project on the project page.

In one or more of the blocks, there's an extension block called extension [lbr_load(url) V] [/libraries/geolocation] @delInput@addInput or something, append this link to snap.berkeley.edu/ and you have the js code for the library

the new js code has the same problem I mentioned

Is that not part of the geolocation one? I don't have much experience with most of the libraries lol
What?

Thank you, I'll try that. It sucks that it won't work on the project page, but the project is primarily used for me and my friends to play around with anyways, so if I release it publicly I might just remove the geolocation part altogether, it's honestly just a minor feature of my project anyways.

To the person who said to use the 'World map' library (whose comment seems to have been deleted), I just tried that and it had the same problem.

Having looked into it, it might just require an extra parameter adding to the extension that the block calls to disable the pop-up.

SnapExtensions.primitives.set(
    'geo_location(acc?)',
    function (includeAccuracy) {
        var crd = new List(),
            myself = this,
            options = {
                enableHighAccuracy: true,
                timeout: 5000,
                maximumAge: 0
            };

        function success(pos) {
            crd = new List([
                pos.coords.latitude,
                pos.coords.longitude
            ]);
            if (includeAccuracy) {
                crd.add(pos.coords.accuracy);
            }
        }

        function error(err) {
            crd = new List([37.872099, -122.257852]);
            myself.inform('Warning:\nGeolocation failed.');
        }

Although adding it probably wouldn't cause a lot of side effects it might not make it to the top of the (extensive) to-do list

You can edit your own version of the JavaScript but from what you say - you want this to apply to anyone who runs your project which requires a change to the official Snap! code

And would require the users to go into the project and manually check "enable JavaScript" as thus

Would anyone who loads the project into the editor be able to use it? If it's just me and my friends using it, that would be enough. When I upload a public version, I might just remove the geolocation part altogether.

No. It would require a change to the official release