Skip to main content
Inspiring
August 14, 2016
Question

CP9: Function of "When Geolocation changes, execute script" ?

  • August 14, 2016
  • 1 reply
  • 243 views

Hi

Please can you tell me what the function of the field "When Geolocation changes, execute script" that in the Mobile Palette window (Window > Mobile Palette)?

In Geo location examples i've seen on the Web - Advanced Action scripts are normally run on entering a slide.

i.e. check user's location then "show content" / "go to a slide" related to that location.

1. My understanding is that the "geolocation changes, execute script" field automatically check user's location then runs a script if the location has changed.

Like the "geolocation.watchPosition()" method in HTML5.

Is this correct?

And i'm assuming that it would be used to create an app when you are walking around a location e.g. a zoo.

Different information would be displayed based on user's location.

2. If this is the case then I'm assuming if this field has a script then this is the only way to check if geolocation changes.

i.e. you can't have a script in this field, and other scripts checking location on other slides.

Is this right?

3. Also, how often does the field (Captivate) check the geolocation?  

Can this time be changed?

Regards

Donal.

    This topic has been closed for replies.

    1 reply

    TLCMediaDesign
    Inspiring
    August 14, 2016

    This is just a guess since I haven't looked at the actual code, but my guess is that it is the same as the variable change listener and listens for cpInfoGeoLocation to change. I would think it would update in time based on the accuracy set in the geoLocation  parameters.

    donalallAuthor
    Inspiring
    August 17, 2016

    Hi TLCMediaDesign,

    I had a look at the code (not that i would make much sense of it).

    And here's where i think the geolocation monitoring takes place - see code below.

    Not sure if that gives you enough info to answer my question.

    (cp9.0.2, responsive project with 1 slide - no objects, geolocation enabled, publish for devices).

    Thanks, Donal.

    ...

        var c = void 0;

        b.startWatchingGeoLocationChange = function() {

            if (!c)

                if (navigator.geolocation) c = navigator.geolocation.watchPosition(j, k, {

                    enableHighAccuracy: !0,

                    timeout: 1E4,

                    maximumAge: 0

                });

                else {

                    var a = b.D.geoWarnings;

                    b.showColoredNonModalWarning(a ? a.geoNoSup : "Geolocation is not supported by this browser.")

                }

        };

        b.stopWatchingGeoLocationChange = function() {

            c && (navigator.geolocation.clearWatch(c), c = void 0)

        };

        b.compareGeolocation = function(a, b) {

            if (!b) return !1;

            var c = h(a),

                f = h(b),

                d, e = c.lat,

                g = f.lat;

            d = (g - e) * Math.PI /

                180;

            c = (f.lon - c.lon) * Math.PI / 180;

            e = e * Math.PI / 180;

            g = g * Math.PI / 180;

            d = Math.sin(d / 2) * Math.sin(d / 2) + Math.sin(c / 2) * Math.sin(c / 2) * Math.cos(e) * Math.cos(g);

            d = 6371E3 * 2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d));

            return 0 === d || d && d <= Number(f.acc) ? !0 : !1

        }

    })(window.cp);

    ....