Extract points from location on screen relative to center of screen which equals current location.

If the center of the screen was equal to your location, is it possible that tapping on the screen (or in the case of button watches perhaps using a set distance in projected location and the direction you are facing to select) on for example the top left part could result in extracting coords (say for a waypoint) and save them somewhere then set that waypoints location to the center of the screen thus allowing you to select multiple waypoints that then connect as a route?

Just wonderingnif that would be possible for non map devices.

Crude example:

 The birds eye map is just to give an idea of distance.

  • Ok, that's a start. There are about 60 miles in a degree of latitude, longitude varies with latitude (the lines get closer as you near the poles)

    If you know the projection of the large map image (or the width in km at the top and bottom), and the total map height in km we can work out the maths.

  • Equarectangular, map height is roughly 5751km. 
    highest latitude is roughly 84.0
    Lowest latitude is roughly 32.0

  • Thanks. It looks like the map is about 11 degrees wide (that projection is a fixed number of degrees wide which is convenient). If youi can confirm that, you can plug the details in below. I've written two functions which convert pixels to degrees and vice-versa.

    var mapWidthPixels = 3000;
    var mapHeightPixels = 3000;
    var mapWidthDegrees = 11; //worked this out from the width at 82 degrees being ~165km (165 / (cos(82) * 111.325))
    var mapHeightDegrees = 52;
    
    var widthInPixelsOfOneDegree = mapWidthPixels/mapWidthDegrees;
    var heightInPixelsOfOneDegree = mapHeightPixels/mapHeightDegrees;  
    
    //converts a number of pixels to a number of degrees
    //Returns [degreesLat, degreesLong] //!note this is [y,x] due to convention with lat,long
    function screenDistanceToDegrees(widthPixels, heightPixels){
    
    	return [heightPixels *(1/heightInPixelsOfOneDegree),
    	        widthPixels * (1/widthInPixelsOfOneDegree)];
    }
    
    //converts a distance in degrees to screen pixels.
    //Returns [pixelsX, pixelsY]
    function degreesToScreenDistance(widthDegrees, heightDegrees){
    
    	return [widthDegrees * widthInPixelsOfOneDegree, 
    	        heightDegrees * heightInPixelsOfOneDegree];
    }
    

    You need to use your pixel differences to calculate degrees and store that (and vice-versa to display it when you retrieve it).

    This presumes that the map is one pixel of the image to one pixel on the screen. If it is zoomed in any way, this won't work correctly.

  • Do I replace the previous maths that converts the screen coords (in the delegate) with this maths? 

    For example  

    function on tap:

    {the code you’ve just shared}

  •  Heres a map thats the same as mine (projection and location anyway, you say that’s 11 degrees wide yes? Both top and bottom? It shows on the watch 1px = 1px. I’m a bit confused regarding the code. (I am away from my computer so cannot test it at the moment) Where it says converts a number of pixels to a number of degrees (and vice versa) that is where i’ve tapped on the screen yes? Thus making the previous maths calculation unnecessary (while preserving the storage code)

  • That map looks to be perhaps 60 degrees wide, but it's quite hard to tell from such a small image. It's certainly 5-7000k wide at the bottom rather than 1100km

    You need to take those two functions (with the correct scaling factors) and when you save the values, you need to convert from pixels to lat/long and when you retrieve them you need to find the relative lat/long of the point compared  to the centre of your map and convert that distance into pixels and draw it.  

    If you can share/upload the code somewhere I can try to insert it for you.

  • The alternative is to convert the current lat/long to pixels, work out the differences and then save those relative pixels to the top-left of the large image. Both will work.

  • I’ll share it when I get the chance, Right now i’m away from the computer with the code on. I did comment somewhere in this thread with the delegate code that changes screen coords to lat,lon on a tap, thats where i’d try and insert your provided screen distance to degrees function.