How to load osmdroid tiles at the end of the user?

I already managed to download map fragments from the osmdroid SD card (Mapnik)

But now I want to indicate in the Android application to download the map that the user wants to use; the middle map shows online; the user selects a specific area and uses it to use it; I don’t know how to do this, please help, thanks

+4
source share
1 answer

I am not sure what this question points to. As far as I understand, the user selects an area that is expressed in geographical coordinates, and then uses these coordinates to calculate the fragments found.

The Slippy map tilenames in the OSM quiz has a very good explanation on how to do this:

  • Redesign the coordinates of 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)

  • Conversion range xand yto 0- 1and slide beginning in the upper left corner:

    x = [1 + (x / π)] / 2
    y = [1 − (y / π)] / 2
    
  • Calculate the number of fragments on the map n, using2^zoom
  • Multiply xand yon n. A round of results down to give tilexand tiley.
0
source

Source: https://habr.com/ru/post/1524077/


All Articles