is there a way of calculation distance in geolocation?

0 favourites
  • 4 posts
  • I was wondering if there's a way of tracking distance travelled using geolocation. it will be shown as a progress bar so it doesn't need to be accurate to a map it just needs to show distance travelled in metres/feet.

    thank you

  • I don't know exactly , but have a look at this http://www.movable-type.co.uk/scripts/latlong.html

    What I would do:

    Go to google maps, set your destination to lat0,long0, (zoom in and click until you find it) then go to lat 1 and see how many km are, then divide one by the other to find out a multiplication factor. Do the same for the longitude. Use Google dev console to modify gps coordinates so you can test your code

    But from the above link, I can see that 1 degree = 111.2 km, so you can test using this value as a multiplication factor for the values that you get from Browser.location

  • To actually calculate the the distance traveled, create 3 variables: DistanceTraveled, LastLocationLat and LastLocationLong

    Add geolocation plugin to your project then every time the geolocation is updated do like this:

    DistanceTraveled = DistanceTraveled + distance(LastLocationLat,LastLocationLong,Geolocation,Latitude,Geolocation.Longitude)

    LastLocationLat = Browser.Lat

    LastLocationLong = Browser.Long

    You cand find the distance(X1,Y1,X2,Y2) in System object, under math section I think

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you so much this helped a lot

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)