I need to be able to get the tiles that are contained in the map I’m showing.
My partner is using Android and he is using this algorithm to translate Coordinates to Tiles, apparently Google Maps has divided the world in tiles, and I need the tiles that are contained in the maps in order to request info to my server that is related to those tiles.
Do you know how it can be done for iOs?
Here’s the way to do it in android(maybe it will help):
lat = mapView.getBounds()[1][0]/1E6;
lon = mapView.getBounds()[0][1]/1E6;
int xtile1 = (int)Math.floor( (lon + 180) / 360 * (1<<zoom) ) ;
int ytile1 = (int)Math.floor( (1 - Math.log(Math.tan(Math.toRadians(lat)) + 1 / Math.cos(Math.toRadians(lat))) / Math.PI) / 2 * (1<<zoom) ) ;
lon = mapView.getBounds()[1][1]/1E6;
int xtile2 = (int)Math.floor( (lon + 180) / 360 * (1<<zoom) ) ;
lat = mapView.getBounds()[0][0]/1E6;
int ytile2 = (int)Math.floor( (1 - Math.log(Math.tan(Math.toRadians(lat)) + 1 / Math.cos(Math.toRadians(lat))) / Math.PI) / 2 * (1<<zoom) ) ;
First problem, zoom in Android and iOs is not the same, so I will getting different data even though Im showing the same piece of map.
I need a way to work it around that. Or another way of getting the tiles in iOS
Thanks.
In this example you will see how it is done.
A very well done approach
https://github.com/mtigas/iOS-MapLayerDemo