B4A Library OSMDroid - MapView for B4A

Discussion in 'Additional libraries, classes and official updates' started by warwound, Mar 26, 2012.

  1. warwound

    warwound Expert Licensed User

    Here we have my latest library - OSMDroid provides a MapView for B4A.

    More info on the original (native Android) OSMDroid project can be found here: osmdroid - OpenStreetMap-Tools for Android - Google Project Hosting.

    Library reference is no longer included in this post due to limits on the number of characters allowed in a single post.

    I have created some tutorials to show basic usage of the library and will update this thread with a link to them as soon as i have them all uploaded.

    ** Your attention is drawn to the included file Apache License Version 2.0.txt, which is a copy of the Apache License Version 2.0 under which the native Android OSMDroid library is released **

    Martin.
     

    Attached Files:

    Last edited: Jan 26, 2014
  2. warwound

    warwound Expert Licensed User

  3. Erel

    Erel Administrator Staff Member Licensed User

    Amazing work. Thank you for sharing it!
     
  4. thedesolatesoul

    thedesolatesoul Expert Licensed User

    Your efforts finally lead to fruition! :icon_clap::icon_clap::icon_clap:
    Nice work.
    I'm just a bit hazy on LGPL. The library itself can now be distributed (as it is not a modified source?) and any app using it can also be distributed under any license.

    Anyway, this was an immense work :sign0188::sign0188::sign0188:
     
  5. bluedude

    bluedude Well-Known Member Licensed User

    Offline mode

    Am I correct if I conclude that the cache is used (SD card) for offline mode? So if you have been somewhere there is a cache available for that location?

    Great work on the library!
     
  6. warwound

    warwound Expert Licensed User

    Yes if you look on the device SD card for a folder named osmdroid that is the cache folder.

    It's shared by all (installed) applications that use an OSMDroid based map - whether using this library or the native Android library.

    Inside the cache folder is a folder named tiles and inside that are folders named after the tilesource (Mapnik for example).
    Each tilesource folder contains all cached tiles for that tilesource named and structured according to the Sllippy map tile naming convention.

    That makes it possible to use your own custom tiles if you have access to any.

    And you can even create a tileset from a panorama and use the MapView as a panorama viewer - something that's been discussed recently on the forum.

    I'm working on an example of how to use offline tiles and will hopefully have that uploaded later or tomorrow.

    Martin.
     
  7. warwound

    warwound Expert Licensed User

    Hmmm i shall have to look into this - i was under the impression that as long as i made available the source code for any modifications to the original code that i would be ok to distribute such modifications.

    I'll post again as i find out more about the technicalities of LGPL.

    Martin.
     
  8. Jost aus Soest

    Jost aus Soest Active Member Licensed User

    Wow, that's a great lib!
     
  9. Tom Christman

    Tom Christman Active Member Licensed User

    :sign0098:Thank you for this work Martin.
     
  10. dealsmonkey

    dealsmonkey Active Member Licensed User

    Amazing, thankyou.
     
  11. timwil

    timwil Active Member Licensed User

    REALLY AMAZING!!!!

    Thanks!

    :):):):):)
     
  12. warwound

    warwound Expert Licensed User

    OSMDroid updated to version 1.01

    This is a minor update that adds supports for using a Cloudmade API key.

    If are are not going to use a Cloudmade API key there is no need to update your library files.

    An example of using a Cloudmade API key can be found here: http://www.basic4ppc.com/forum/basi...smdroid-mapview-b4a-tutorial-2.html#post92864.

    Latest version of the library is attached to the first post in this thread.

    You do NOT need to update the native_android_libraries.zip files, just the B4A library files.

    Martin.
     
  13. barx

    barx Well-Known Member Licensed User

    Looks awsome. :sign0142::sign0098:
     
  14. warwound

    warwound Expert Licensed User

    I have now updated the attachment in the first post which contains the additional native Android libraries.

    Users of versions of B4A prior to the current 1.8 will need the two dummy XML files that i have added to that attachment - now named native_android_libraries_20120328.zip.

    The readme.txt file in that attachment explains what is required:

    I've attached the 2 extra dummy XML files to this post - if you have already copied the native Android libraries to your B4A additional libraries folder then you can download just these two dummy XML files rather than the entire native_android_libraries_20120328.zip file.

    Martin.
     

    Attached Files:

  15. warwound

    warwound Expert Licensed User

    OSMDroid updated to version 1.02

    • Updated MapView AddOverlay method so an Overlay cannot be added to the MapView more than once.
    • Updated RemoveOverlay and RemoveOverlays methods, if an Overlay is not actually removed from the MapView then the MapView is not invalidated (internally).
    • BoundingBox object now has Initialize and Initialize2 methods:

      Initialize (LatitudeNorth As Double, LongitudeWest As Double, LatitudeSouth As Double, LongitudeEast As Double)

      Code:
      Dim UKBounds As BoundingBox
      UKBounds.Initialize(
      58.77, -13.850.493.4)
      Initialize2 (NorthWest As GeoPoint, SouthEast As GeoPoint)

      Code:
      Dim UKBounds As BoundingBox
      Dim NorthWest, SouthEast As GeoPoint
      NorthWest.Initialize(
      58.77, -13.8)
      SouthEast.Initialize(
      50.493.4)
      UKBounds.Initialize2(NorthWest, SouthEast)
      Both those code examples will produce the same result - a BoundingBox that represents (roughly!) the geographical bounds of the UK.

      The MapView FitMapToBoundingBox method can now be used to pan and zoom the map to fully contain the BoundingBox:

      Code:
      MapView1.FitMapToBoundingBox(UKBounds)

    b4a_library_v1_02.zip is attached to the first post in this thread.

    Martin.
     
  16. bluedude

    bluedude Well-Known Member Licensed User

    Adding markers from json

    Hi,

    I'm parsing a JSON file with long, lat and want to add that to the marker layer.

    For some reason I don't seem to be able to do something like:

    Dim Markers As List
    Markers.Initialize

    for i=0 to 10
    Dim Marker1 As Marker
    Marker1.Initialize("Home sweet home", "bla", 52.75610, 0.39748, Icon)
    Markers.add

    next
    'add markers
    ovlMarkers.AddMarkers(Markers)

    Cheers,
     
  17. warwound

    warwound Expert Licensed User

    Have you created an Icon object?
    Try passing Null for the Icon value - a default icon will be used.

    Is Markers.add a typo or bad copy/paste?
    Markers.add(Marker1) is what's required.

    Is ovlMarkers a MarkersOverlay or a MarkersFocusOverlay?
    Has it been initialzed?
    Has it been added to the MapView?

    Code:
    Dim Markers As List
    Markers.Initialize

    For i=0 to 10
     
    Dim Marker1 As Marker
     Marker1.Initialize(
    "Home sweet home""bla"52.756100.39748, Icon)
     Markers.add(Marker1)
    Next

    'add markers
    ovlMarkers.AddMarkers(Markers)
    Posting a ZIP'd project makes answering such a question so much easier.

    Martin.
     
  18. bluedude

    bluedude Well-Known Member Licensed User

    The zip

    Hi,

    Hereby the zip. Looking for the best way to add lots of markers (from a JSON file) fast.

    I have the json processing in place (poi's from a web service).

    Cheers,
     

    Attached Files:

  19. warwound

    warwound Expert Licensed User

    Well this is rather strange...

    I added a Log statement to the OSMDroid library and recompiled, the Log simply Logs the Class of the Marker in the List passed to MapView AddMarkers.

    Code:
    Log.d("B4A""Class="+Markers.Get(count).getClass().getName());
    I run your project and it Logs:

    Your project fails - AddMarkers is expecting a List over OverlayItemWrappers.

    I run the example code from the MarkersOverlay example (09 - OverlayMap), and the Logs shows (as expected):

    So why in your project are the OverlayItemWrappers becoming OverlayItems and causing the ClassCastException???

    I commented out your for loop and copied a line from the working example:

    Code:
    Dim Markers As List
       Markers.Initialize

    '   For i=0 To 10
    '       Dim Marker1 As Marker
    '       Marker1.Initialize("Home sweet home", "bla", 52.75610, 0.39748, Icon)
    '       Markers.add(Marker1)
    '   Next

       
    Dim Marker2 As Marker
       Marker2.Initialize(
    "Elsewhere""Downham Market"52.608010.39047Null)
       Markers.Add(Marker2)

       
    'add markers to overlay
       ovlMarkers.AddMarkers(Markers)
    Still the Marker in your project is becoming an OverlayItem instead of remaining an OverlayItemWrapper.

    The working project open in another window compiling and running on the same version of the library and the same device works perfectly.

    All very strange, i shall apply the classical solution - take a break for lunch and come back to my computer with a fresh head.

    BBL.

    Martin.
     
  20. bluedude

    bluedude Well-Known Member Licensed User

    Difference

    Well there is a difference of course. You initialize Markers with marker1 and marker2 in the end in your original project by using initialize.

    However, it seems to me this isn't usable if you need to define maybe 10-30 markers.

    Just wondering how to add multiple markers to a list and add it to the overlay.

    Cheers,
     
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