Welcome to TalkGraphics.com
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: GPS triggering

  1. #1
    Join Date
    Jul 2023
    Posts
    23

    Default GPS triggering

    Probably asking for the impossible here but....
    Is there any way to use a smartphone's gps position to trigger an action in a Xara built website which is running on the same phone?

  2. #2
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,901

    Default Re: GPS triggering

    Quote Originally Posted by Epyminia View Post
    Probably asking for the impossible here but....
    Is there any way to use a smartphone's gps position to trigger an action in a Xara built website which is running on the same phone?
    Epymina, probably not impossible just very hard.

    You would need to interface with the Geolocation API.
    You would need the right browser and SSL connectivity.
    The API handles all the user interaction for access to the phone's location.

    You need JavaScript code to get the window.navigator.geolocation, like:
    function success(position) { doSomething(position.coords.latitude, position.coords.longitude);
    }
    function error() {
    alert("Sorry, no position available.");
    }
    const options = {
    enableHighAccuracy: true,
    maximumAge: 30000,
    timeout: 27000,
    };
    const watchID = navigator.geolocation.watchPosition(success, error, options);
    The doSomething() call is what to want your Xara website to do when you have the coordinates.

    For a quick check, try running https://www.w3schools.com/jsref/tryi...av_geolocation on a smartphone.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  3. #3
    Join Date
    Jul 2023
    Posts
    23

    Default Re: GPS triggering

    Hi Acorn, thanks for the reply. I tried the link on my phone and effectively it gave my geolocation coordinates. Unfortunately, the coding is way beyond my limited capabilities.
    My idea was to produce an online webpage showing a map of a town or village with several waypoints marked. When the user approaches a waypoint I wanted a vintage postcard and explanatory text to pop up so that they could see and appreciate the changes.
    It was just for fun. Do you have any clues on how to go about this without lots of serious programming knowledge?

  4. #4
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,901

    Default Re: GPS triggering

    Quote Originally Posted by Epyminia View Post
    Hi Acorn, thanks for the reply. I tried the link on my phone and effectively it gave my geolocation coordinates. Unfortunately, the coding is way beyond my limited capabilities.
    My idea was to produce an online webpage showing a map of a town or village with several waypoints marked. When the user approaches a waypoint I wanted a vintage postcard and explanatory text to pop up so that they could see and appreciate the changes.
    It was just for fun. Do you have any clues on how to go about this without lots of serious programming knowledge?
    The programming would not be too onerous, the specification of what you want and the ensuing compliance under GDPR and the like is more problematic.

    Using watchPosition() repeatedly could quickly drain a phone battery.
    Position accuracy is also important so you would need to define how close a walker to the waypoint would have to be before triggering the postcard.
    You need to control the triggering so it is not always popping up after it has been viewed.
    The underlying map probably would need updating too.
    Retention of user data needs to be compliant with GDPR and deletion is also essential.
    If you've never viewed your Google account, try https://myactivity.google.com/activi...ce=my-activity.

    I would show a static map with waypoints, that when touched, open the postcard.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  5. #5
    Join Date
    Jul 2023
    Posts
    23

    Default Re: GPS triggering

    Hello Acorn, once again thank you for your feedback. I came across a company called Stqry that offers an app with features similar to what I have in mind. However, the app is quite expensive and out of my budget. Nonetheless, the fact that they are up and running suggests that the GDPR and battery usage issues can be overcome.

    I never intended to collect user information through the app, but I found your Google link both fascinating and shocking! My long-term idea is to create a collaborative app where people can share their own pictures and text to increase the spread of information.

    I had considered the option of clicking on placemarkers, but I’m concerned that users may simply click through the pictures without leaving the comfort of their armchair or stepping away from their PC screens. My goal is to encourage people to get out of their homes and explore the world around them.

    If you have any suggestions on how to proceed, I would be grateful to hear them. Have a great Sunday! ��

  6. #6
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,901

    Default Re: GPS triggering

    Quote Originally Posted by Epyminia View Post
    Hello Acorn, once again thank you for your feedback. I came across a company called Stqry that offers an app with features similar to what I have in mind. However, the app is quite expensive and out of my budget. Nonetheless, the fact that they are up and running suggests that the GDPR and battery usage issues can be overcome.

    I never intended to collect user information through the app, but I found your Google link both fascinating and shocking! My long-term idea is to create a collaborative app where people can share their own pictures and text to increase the spread of information.

    I had considered the option of clicking on placemarkers, but I’m concerned that users may simply click through the pictures without leaving the comfort of their armchair or stepping away from their PC screens. My goal is to encourage people to get out of their homes and explore the world around them.

    If you have any suggestions on how to proceed, I would be grateful to hear them. Have a great Sunday! ��
    I think the simple point of your found app has to be that it is expensive. It will not be using the navigator method as Android and separately iPhone have their own separate APIs for this feature. Coding then indeed becomes very hard. I stressed the need for a solid specification and requirement creep arose with "collaborative app".

    What you are describing is more like Geocaching and Letterbox Stamping. Your 'activity' on finding the geocache would be to examine a copy of your postcard and compare against the current surroundings.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  7. #7
    Join Date
    Aug 2000
    Location
    Harwich, Essex, England
    Posts
    21,936

    Default Re: GPS triggering

    Probably way off base but worth a try.

    At each waypoint have a sign "Way Point #3" and attach a QR code. This can be scanned to trigger your 'postcard'?
    Egg

    Minis Forum UM780XTX AMD Ryzen7 7840HS with AMD Radeon 780M Graphics + 32 GB Ram + MSI Optix Mag321 Curv monitor
    + 1Tb SSD + 232 GB SSD + 250 GB SSD portable drive + ISP = BT + Web Hosting = TSO Host

  8. #8
    Join Date
    Jul 2023
    Posts
    23

    Default Re: GPS triggering

    Morning Egg,
    I thought this was an excellent idea! I have tried it with abandoned railway stations and plague chapels.
    Unfortunately, the QR codes tend to have a short lifespan....
    I think that I will abandon the project and dream of what might have been... However, a friend tells me that there may be a way with Google MyMaps...

  9. #9
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,901

    Default Re: GPS triggering

    Quote Originally Posted by Epyminia View Post
    Morning Egg,
    I thought this was an excellent idea! I have tried it with abandoned railway stations and plague chapels.
    Unfortunately, the QR codes tend to have a short lifespan....
    I think that I will abandon the project and dream of what might have been... However, a friend tells me that there may be a way with Google MyMaps...
    Look at https://www.qrcode-monkey.com/#maps, it handles SVG, colours and logos, all free.

    I have looked at MyMaps and while you can create routes with waypoints, they are limited and I have seen no way to ensure the postcard pops up when a walker is at the waypoint.
    https://cchikes.com/gps-navigation/.

    Quote Originally Posted by Egg Bramhill View Post
    Probably way off base but worth a try. At each waypoint have a sign "Way Point #3" and attach a QR code. This can be scanned to trigger your 'postcard'?
    @Egg, the main problem with QR Codes is that they can be hijacked so always include a human readable link for safety.

    The alternative using QR Codes is to make it a dynamic QR Code. This allows tracking and validation.
    The downside is the cost; there are no free options.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  10. #10
    Join Date
    Jul 2023
    Posts
    23

    Default Re: GPS triggering

    Thanks Acorn, I have obviously bitten off more here than I can chew!
    I put the question to Chat GPT and they say it is possible!

    Here is their reply, WARNING, It is pretty complicated....

    First, you will need to use the Maps JavaScript API to display the map and the marker at the desired location.
    Next, you will need to use the Geolocation API to get the user’s current location.
    Once you have the user’s location, you can use the Haversine formula to calculate the distance between the user’s location and the location of the marker.
    If the user is within the desired proximity, you can then display the image.

    Here is an example of how you can use the Haversine formula in JavaScript to calculate the distance between two points:

    JavaScript

    function getDistance(lat1, lon1, lat2, lon2) {
    const R = 6371; // Radius of the earth in km
    const dLat = deg2rad(lat2 - lat1); // deg2rad below
    const dLon = deg2rad(lon2 - lon1);
    const a =
    Math.sin(dLat / 2) * Math.sin(dLat / 2) +
    Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
    Math.sin(dLon / 2) * Math.sin(dLon / 2);
    const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
    const d = R * c; // Distance in km
    return d;
    }

    function deg2rad(deg) {
    return deg * (Math.PI / 180)
    }

    Does that sound feasible to you?

    As for the QR codes, they work well but are prone to vandalism and sometimes simply being cleaned away by council officers! I still have a few on chapel doors but I need to keep an eye on them!
    Today somebody suggested using Artificial Reality to insert the postcards, but that is in another dimension !!!
    }

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •