user2433098
user2433098

Reputation: 41

How to download osmdroid tiles on user end?

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

Answers (1)

glglgl
glglgl

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 and y to 01 and shift origin to top left corner:

    x = [1 + (x / π)] / 2
    y = [1 − (y / π)] / 2
    
  • Calculate the number of tiles across the map, n, using 2^zoom
  • Multiply x and y by n. Round results down to give tilex and tiley.

Upvotes: 0

Related Questions