How to get lat/long of RMTile?

131 views
Skip to first unread message

BUDDAx2

unread,
Oct 29, 2012, 7:54:06 AM10/29/12
to route-...@googlegroups.com
Hi!
How can I get lat/long of some RMTile?
Maybe somebody can give me an advise how to add some tiles layer to my map? As I know I can't use more than one TileSource at the same time. So I tried to add my custom tiles as a RMMarkers. I have XYZ position of tile, but how convert it to lat/long coordinates?

Vladimir Vyskocil

unread,
Oct 29, 2012, 1:51:52 PM10/29/12
to route-...@googlegroups.com
Hi,

I use the following code :

#define kDefaultTileSize 256
static double initialResolution = 2 * M_PI * 6378137 / kDefaultTileSize;
static double originShift = M_PI * 6378137;

-(RMLatLong)centerLatLonForTileX:(unsigned int) tx tileY:(unsigned int) ty zoom:(unsigned int) zoom {
    RMLatLong center;
    double px = (tx+0.5)*kDefaultTileSize;
    double py = (ty+0.5)*kDefaultTileSize;

    

    double res = initialResolution / exp2(zoom);
    double x = px * res - originShift;
    double y = py * res - originShift;

    

    center.longitude = (x / originShift) * 180.0;
    center.latitude = 180 / M_PI * (2 * atan( exp( (y / originShift) * M_PI)) - M_PI_2);

    

    return center;
}


--
You received this message because you are subscribed to the Google Groups "route-me" group.
To view this discussion on the web visit https://groups.google.com/d/msg/route-me-map/-/FEN90SAlFfAJ.
To post to this group, send email to route-...@googlegroups.com.
To unsubscribe from this group, send email to route-me-map...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/route-me-map?hl=en.

BUDDAx2

unread,
Oct 30, 2012, 6:49:16 AM10/30/12
to route-...@googlegroups.com
Thank you!
Reply all
Reply to author
Forward
0 new messages