Android Tutorial OSMDroid - MapView for B4A tutorial

Discussion in 'Tutorials & Examples' started by warwound, Mar 26, 2012.

  1. MaFu

    MaFu Well-Known Member Licensed User

    Place a slight transparent label above the map.
     
  2. entolium

    entolium Member Licensed User

    Hello,

    I'm running all examples with overlay and always get the same error. Png not found (/resorces/org/osmdroid/...). I'm searching, reading many posts and tried hundreds of things, but is impossible, always the same error. I'm desperate.
    Is possible to copy all pngs in my device? where?

    Thanks a million!!!
     
  3. Spectre

    Spectre Active Member Licensed User

    Hi!
    I do not remember how it fits an personal icon that in Maylocation overlay,
    instead of the triangle of direction...
     
  4. Spectre

    Spectre Active Member Licensed User



    Very nice .. I'm sorry but I did not understand how it should be the structure of the server hosting the tiles of the map!!
     
  5. warwound

    warwound Expert Licensed User

    I'm not sure i understand.
    Are you hoping to bulk download the chartbundle tiles then host them on a server - then display them on an OSMDroid map using UrlTileSource?
    The parameters to initialize the UrlTileSource depend entirely on the location of the tiles on your server.
     
  6. Spectre

    Spectre Active Member Licensed User

    HI! sorry my English...

    I would like to load the map on my server and then distribute it to the apk.

    Use as you said OSMDroid_UrlTileSource.

    But I have not figured out how to be the folder structure that I have to put on the server.

    To generate the tile use MapTiler (http://www.maptiler.com/).

    http://www.Myserver/MAyMAps/10
    11
    12
    10,11,12 is folder on tile png
     
  7. warwound

    warwound Expert Licensed User

    Read about slippy map tile naming.
    This is a common way to structure and name tiles on a server.

    Now look at the UrlTileSource demo:

    Code:
    Dim MyTileSource As OSMDroid_UrlTileSource
    MyTileSource.Initialize(MapView1, MyTileSourceName, 
    "http://a.tile2.opencyclemap.org/transport/%3$d/%1$d/%2$d.png"016256)
    Finally the documentation for the UrlTileSource Initialize method:

    Does MapTiler save your tiles in a folder structure that's identical to the slippy map tile naming scheme?
     
    Johan Schoeman and DonManfred like this.
  8. Spectre

    Spectre Active Member Licensed User

    Ok perfect , the problem was simply in the wrong folder structure ... Thanks Warwound... PS how it fitsan personal icon that in Maylocation overlay,
    instead of the triangle of direction... ?
     
  9. warwound

    warwound Expert Licensed User

    There's no built in method to change the MyLocation overlay icon.
    If you open the library file OSMDroid_4_1.jar with WinRAR or another archive manager and look in the folder /org/osmdroid/ you'll see the various built in icons used by the library.
    direction_arrow.png is the icon used by MyLocation.
    So if you replace direction_arrow.png in the library .jar file you should see your new icon on your map.

    It's not an ideal solution but it is currently the only solution.
     
    Johan Schoeman and nemiroG1 like this.
  10. Spectre

    Spectre Active Member Licensed User

  11. Spectre

    Spectre Active Member Licensed User

    Last edited: Sep 10, 2015
  12. Spectre

    Spectre Active Member Licensed User

    Code:
    Dim MyTileSourceName As String="HikeBike"
        
    Dim TileSourceFactory1 As OSMDroid_TileSourceFactory
            
    Dim MyTileSource As OSMDroid_UrlTileSource
            MyTileSource.Initialize(MapView1, MyTileSourceName, 
    "http://a.tiles.wmflabs.org/hikebike/%3$d/%1$d/%2$d.png",017256)
            TileSourceFactory1.AddTileSource(MyTileSource)
     
    Last edited: Sep 10, 2015
    warwound likes this.
  13. Spectre

    Spectre Active Member Licensed User

    They will " melt " together the two tile to get the nuances altimeter overlaid on the map??

     
  14. jndaniels1

    jndaniels1 Member Licensed User

    Greetings Warwound, Spectre
    (And other osm guru's)


    Does offline tile caching work in the same manner as in the previous v3 library? Creating a osmdroid.zip or osmdroid.sqlite tile cache with
    MOBAC and placing it in the ext stroage /osmdroid ??

    I hope this isn't a repeated question; I did search before posting.

    I got both zip and sqlite working successfully with the previous warwound code example "11 - OfflineMaps" using sqlite (with pretty much ease).
    Zip Vs Sqlite .. Sqlite is way faster!


    Thanks warwound for a awesome library! And all who help!

    Kind Regards
    J Daniels
     
  15. warwound

    warwound Expert Licensed User

    Yes there's no difference in operation between v3.0.8 and v4.1.
    There's syntax differences between the 2 versions but the underlying features remain unchanged.
     
  16. anglia

    anglia Member Licensed User

    I'm fairly new to B4a and I'm very interested in the excellent work Martin has done developing this library.
    I've read most of the posts in this thread, but I'm having trouble understanding the use of offline maps for 'non-geographical' applications.

    Back in post #12, Martin mentioned that the library could possibly be used for circuit diagrams, floor plans etc.
    I've got a large chart which I have cut into 800 png tiles (40x20 each 256x256 pixels).

    I am reasonably familiar with the way that the zoom factor and 'slippy tiles' work, but I can't see how to use them as there are no geopoints, latitudes, longitudes involved.
    Could someone point me in the right direction please?

    Thanks
     
  17. warwound

    warwound Expert Licensed User

    @anglia

    Displaying a non geographical image in a MapView and then referencing cartesian (x, y) coordinates on the image requires you to be able to convert those cartesian coordinates into geographical (latitude, longitude) coordinates and vice versa.

    OSMDroid uses the WGS84 geographical coordinate system.

    Which version of OSMDroid are you using?
    There are 2 versions available: 3.0.8 and 4.1.
    I never had time to properly upload version 4.1 to the forum but it is available from my website: http://b4a.martinpearman.co.uk/osmdroid/.

    To convert between cartesian and geographical coordinates you need to use the OSMDroid Projection object.
    The Projection object was never included in version 3.0.8 but is included in version 4.1.
    Look at this page: http://b4a.martinpearman.co.uk/osmdroid/OSMDroid_4_1.html, search the page for OSMDroid_Projection and you'll see there are various methods to make these coordinate conversions.
     
    Johan Schoeman, anglia and DonManfred like this.
  18. anglia

    anglia Member Licensed User

    Thanks Warwound.

    I'll look into the OSMDroid Projection object and give it a go.

    I'm using version 3.0.8 (v 3.52). I know that version is 4.1 is available and I have downloaded it (version 4.1 (0.04) and tried to use it . However, when I use v4.1 and try to compile your example code for '11 - Offline mapsupdated' - (post #12 of this thread), I get the following error message-

    B4A version: 5.20
    Parsing code. Error
    Error parsing program.
    Error description: Unknown type: geopoint
    Are you missing a library reference?
    Occurred on line: 12 (Main)
    Dim MapCenter As GeoPoint

    If I go back to using version 3.08, the code compiles and runs ok.

    Have I missed some modification I need to make so that I can use v4?

    Thanks again
     
  19. warwound

    warwound Expert Licensed User

    @anglia

    The object names in version 4.1 are all prefixed with OSMDroid_.
    Version 3.0.8's GeoPoint object is named OSMDroid_GeoPoint in version 4.1.
     
  20. anglia

    anglia Member Licensed User

    Sorry warwound, I didn't spot that!

    Thanks
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice