Android Question OSMDroid - MapView library still missing

Wosl

Member
Dear All,

as a beginner on OSMDroid I need some guidance to the OSMDroid project. I wanted as starting point to test the first example on this link

Before execution I copyied the lib files from link https://www.b4x.com/android/forum/threads/osmdroid-mapview-for-b4a.16309/#post92643
OSMDroid_3_0_8.jar
OSMDroid_3_0_8.xml
to my B4A additional libraries folder as usual.

However, I still receive for the declaration 'Dim MapView1 As MapView'
missing library OSMDRoid

Did I missed a lib or something else?

Wosl
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

teddybear

Well-Known Member
Licensed User
Did I missed a lib or something else?

Wosl
In most cases, you put them into incorrect path, check your additional libraries path out
 
Upvote 0

Wosl

Member
Hi,

Good hint. I already refreshed the list of libs! The lib 'OSMDroid_3_0_8' had been sellected correctly. I saved the project and reopend it. And now,
when opening the simplemap.b4a file the following message appears in the log ...

1657009497130.png

However the compilation works correctly. So, it seems it a warning only which disappears after starting the execution of the compilated project. The mentioned native lib seems not to be needed.

With that I can live with it even it's irritating. Thank you.

Wosl
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
If I translate that correctly you have a "Missing missing jar file: NativeOSMDroid.xml"

This means that you have a NativeOSMDroid.xml file in one of your library folders, probably the additional one, without a matching jar file. I don't recognise NativeOSMDroid as a known library - perhaps you inadvertently copied it from somewhere by accident.
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Dear All,

as a beginner on OSMDroid I need some guidance to the OSMDroid project. I wanted as starting point to test the first example on this link

Before execution I copyied the lib files from link https://www.b4x.com/android/forum/threads/osmdroid-mapview-for-b4a.16309/#post92643
OSMDroid_3_0_8.jar
OSMDroid_3_0_8.xml
to my B4A additional libraries folder as usual.

However, I still receive for the declaration 'Dim MapView1 As MapView'
missing library OSMDRoid

Did I missed a lib or something else?

Wosl
I used to use OSMDroid, but moved to another OSM viewer as it was simpler and gave me full control over the source code:

Been using this for over a year now and all working very well and pleased with it.

RBS
 
Upvote 0

Wosl

Member
Hallo All!

Thank you for your responses ... very helpful. As agarham said, the message disappers when I deleted NativeOSMDroid.xml and slf4j-android-1.5.8.xml (and jar) out of my additional lib folder. As mentioned in the threat later the native libraries are not required anymore from OSMDroid version 3.xx on.

However, I can compile without error and the app starts (example #1 and same for all following examples) but other than a grid I don't see anything. In other words, no tile is loaded at all (even for different sources) and I could not find on my sdcard a folder named osmdroid that should be the cache folder.

I'm missing something essential but I can't get it! Grrr!

The alternative:

Thank you to RBS regarding the other OSM viewer. I ran the attached example and it worked. More education on this custom view (cvMap) would be helpful for me. Do you have links to other examples showing more details how to use/customize it? I like to integrate in an existing development an OSM viewer. But here I need to use cvMap custom view without designer. This should possible but how? Another aspect is to use other tile servers or better offline tiles.

Any hint is appreciated.
Wosl
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Hallo All!

Thank you for your responses ... very helpful. As agarham said, the message disappers when I deleted NativeOSMDroid.xml and slf4j-android-1.5.8.xml (and jar) out of my additional lib folder. As mentioned in the threat later the native libraries are not required anymore from OSMDroid version 3.xx on.

However, I can compile without error and the app starts (example #1 and same for all following examples) but other than a grid I don't see anything. In other words, no tile is loaded at all (even for different sources) and I could not find on my sdcard a folder named osmdroid that should be the cache folder.

I'm missing something essential but I can't get it! Grrr!

The alternative:

Thank you to RBS regarding the other OSM viewer. I ran the attached example and it worked. More education on this custom view (cvMap) would be helpful for me. Do you have links to other examples showing more details how to use/customize it? I like to integrate in an existing development an OSM viewer. But here I need to use cvMap custom view without designer. This should possible but how? Another aspect is to use other tile servers or better offline tiles.

Any hint is appreciated.
Wosl
>> But here I need to use cvMap custom view without designer. This should possible but how?
Just add the customview with code.

>> Another aspect is to use other tile servers or better offline tiles.
This is quite simple as well. I use offline tiles, stored in a SQLite database.

I found it easier to add the classes and code modules in the b4xlib to my project and have made quite a few changes to those classes.
Attached a .zip file of all those modules as I have it now.

RBS
 

Attachments

  • OSMViewer.zip
    19.2 KB · Views: 130
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
But here I need to use cvMap custom view without designer.
Add it to a Layout and load the layout. This is the recommended way to add customviews.

 
Upvote 0

Wosl

Member
Thank you DonManfred and RBS,

Yes, I know the usage of designer is the recommended way for custom views. But I plan to modify an older app with adding a simple OSM viewer. This app is using customviews with code and I don't want to change the whole thing now ... may be later ;-)

RBS, thank you for your input. I'll have a deep look to it now. First step would be to write a very simple OSM viewer and learn how to customize it.

Best Regards
Wosl
 
Upvote 0

Wosl

Member
>> But here I need to use cvMap custom view without designer. This should possible but how?
Just add the customview with code.

>> Another aspect is to use other tile servers or better offline tiles.
This is quite simple as well. I use offline tiles, stored in a SQLite database.

I found it easier to add the classes and code modules in the b4xlib to my project and have made quite a few changes to those classes.
Attached a .zip file of all those modules as I have it now.

RBS

Dear RBS

I tested the Open Street Map viewer with some success:
- Could get up and running the test sample
- Modified the module clMapShapeCircle to achieve an overlay circle of constance distance (always showing same radius in m/km independent of the zoom level). Of course, this modification is not perfect ('quick and dirty') but works.

But what not worked ..
- add the customview cvMap with code in a panel view (without designer - i know its not recommended). Can you help me out here?
- not all zoom levels are working (only level 12 to 16 of totally 17). The other levels returned with error message:
'ResponseError. Reason: , Response: Access denied. See https://operations.osmfoundation.org/policies/tiles/'
Is it not allowed to use them or is something missing (e.g. access rights)? Any suggestion?

Wosl
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Dear RBS

I tested the Open Street Map viewer with some success:
- Could get up and running the test sample
- Modified the module clMapShapeCircle to achieve an overlay circle of constance distance (always showing same radius in m/km independent of the zoom level). Of course, this modification is not perfect ('quick and dirty') but works.

But what not worked ..
- add the customview cvMap with code in a panel view (without designer - i know its not recommended). Can you help me out here?
- not all zoom levels are working (only level 12 to 16 of totally 17). The other levels returned with error message:
'ResponseError. Reason: , Response: Access denied. See https://operations.osmfoundation.org/policies/tiles/'
Is it not allowed to use them or is something missing (e.g. access rights)? Any suggestion?

Wosl
What was the reason again you are trying to avoid using the designer?
What map data are you using? I have no problem accessing zoom level 19 with a SQLite database, where the tiles were added as in the code in DownLoadTiles in clsMapTileManager.

RBS
 
Upvote 0

Wosl

Member
ad #1: the reason to avoid designer (which is a great tool !!) is only because I like to integrate a small OSM viewer in an older B4A application without any designer implication. However, a mix between with/without designer may be possible but makes this tweak more complex.

This is my try ...
- Create a AddToParent routine in the class

B4X:
Public Sub AddToParent(Parent As Activity, Left As Int, Top As Int, Width As Int, Height As Int)
     mBase = fxui.CreatePanel("mBase")
    Parent.AddView(mBase, Left, Top, Width, Height)
End Sub

- Define a panel (<100% dimension of screen)

Initialization without Designer:
''    Activity.LoadLayout("main")
    fcvPanel.Initialize("")
    Activity.Addview(fcvPanel,0dip,0dip,90%x,90%y)
    fcvPanel.Color=Colors.Cyan  
    fcvMap.Initialize(Me,"fcvMap")
    fcvMap.AddToParent(fcvPanel,0dip,0dip,100%x,100%y)

Result is a nice cyan colored panel but no map at all. When I open the LoadLayout (what I don't want to do) and comment the fvMap.initialize statement everything is fine. The map is showing up in the panel as expected. The fvMap.initialize statement seems to be wrong (wrong callback function?).

ad #2: I saw the SQLite usage in clsMapTileManager (which is a good solution) and I'm wondering why I run in such a situation. I have not changed anything in the tile management at all. When I compile and run the app again the resulting access problems are the same. The planned (integrated) usage is only about a small region in Germany. Small means maximum 25km radius around a fix point (could be a different point over time but mostly the same all times) meaning not so much tiles are impacted. This amount of tiles should be easily fetched through internet and stored in DB. I will look into the SQLite DB in detail after solving #1. Of course, my final idea is to use the tiles (in addition?) which are already stored on my device by the OSMAnd+ app (perfect for offline usage) with the hope that the data format matches ;-)

Wosl
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
ad #1: the reason to avoid designer (which is a great tool !!) is only because I like to integrate a small OSM viewer in an older B4A application without any designer implication. However, a mix between with/without designer may be possible but makes this tweak more complex.

This is my try ...
- Create a AddToParent routine in the class

B4X:
Public Sub AddToParent(Parent As Activity, Left As Int, Top As Int, Width As Int, Height As Int)
     mBase = fxui.CreatePanel("mBase")
    Parent.AddView(mBase, Left, Top, Width, Height)
End Sub

- Define a panel (<100% dimension of screen)

Initialization without Designer:
''    Activity.LoadLayout("main")
    fcvPanel.Initialize("")
    Activity.Addview(fcvPanel,0dip,0dip,90%x,90%y)
    fcvPanel.Color=Colors.Cyan 
    fcvMap.Initialize(Me,"fcvMap")
    fcvMap.AddToParent(fcvPanel,0dip,0dip,100%x,100%y)

Result is a nice cyan colored panel but no map at all. When I open the LoadLayout (what I don't want to do) and comment the fvMap.initialize statement everything is fine. The map is showing up in the panel as expected. The fvMap.initialize statement seems to be wrong (wrong callback function?).

ad #2: I saw the SQLite usage in clsMapTileManager (which is a good solution) and I'm wondering why I run in such a situation. I have not changed anything in the tile management at all. When I compile and run the app again the resulting access problems are the same. The planned (integrated) usage is only about a small region in Germany. Small means maximum 25km radius around a fix point (could be a different point over time but mostly the same all times) meaning not so much tiles are impacted. This amount of tiles should be easily fetched through internet and stored in DB. I will look into the SQLite DB in detail after solving #1. Of course, my final idea is to use the tiles (in addition?) which are already stored on my device by the OSMAnd+ app (perfect for offline usage) with the hope that the data format matches ;-)

Wosl
> in an older B4A application without any designer implication
What do you mean with: without any designer implication?

> Create a AddToParent routine in the class
Which class?

RBS
 
Upvote 0

roberto64

Active Member
Licensed User
Longtime User
Hi RBS, I am also trying to load the maps I see that you are doing the same thing too, I see that you have added a few more things on the cvmap library ask you some questions 1 in class clsMapTileManager sub DownLoadTiles I see this instruction "General.StartSW (2)" I think it is Starter that is missing in the library you have published, a second question where do you download offline maps? Greetings
 
Upvote 0
Top