Reputation: 41
I already successful to load map tiles from SD Card of osmdroid (Mapnik)
But now i want to give a option in my android app to download map tile that user want to use mean map show online user select a specific area and cashes it for his use i don't know how to do please help thanks
Upvotes: 4
Views: 288
Reputation: 91109
I am not sure where the question points to. As far as I understand it, you have the user select an area - which is expressed in geographical coordinates - and then use these coordinates to calculate the tiles to be retrieved.
Under Slippy map tilenames in the OSM wiki there is a very good explanation how to do this:
Reproject the coordinates to the Mercator projection (from EPSG:4326 to EPSG:3857):
x = lon y = arsinh(tan(lat)) = log[tan(lat) + sec(lat)]
(lat and lon are in radians)
Transform range of
x
andy
to0
–1
and shift origin to top left corner:x = [1 + (x / π)] / 2 y = [1 − (y / π)] / 2
- Calculate the number of tiles across the map,
n
, using2^zoom
- Multiply
x
andy
byn
. Round results down to givetilex
andtiley
.
Upvotes: 0