Android Tutorial OSMDroid - MapView for B4A tutorial

entolium

Member
Licensed User
Longtime 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!!!
 

Spectre

Active Member
Licensed User
Longtime User
Hi!
I do not remember how it fits an personal icon that in Maylocation overlay,
instead of the triangle of direction...
 

Spectre

Active Member
Licensed User
Longtime 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!!
 

warwound

Expert
Licensed User
Longtime 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!!

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.
 

Spectre

Active Member
Licensed User
Longtime 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
 

warwound

Expert
Licensed User
Longtime 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:

B4X:
Dim MyTileSource As OSMDroid_UrlTileSource
MyTileSource.Initialize(MapView1, MyTileSourceName, "http://a.tile2.opencyclemap.org/transport/%3$d/%1$d/%2$d.png", 0, 16, 256)

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?
 

Spectre

Active Member
Licensed User
Longtime 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... ?
 

warwound

Expert
Licensed User
Longtime User
PS how it fitsan personal icon that in Maylocation overlay,
instead of the triangle of direction... ?

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.
 

Spectre

Active Member
Licensed User
Longtime User
B4X:
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",0, 17, 256)
        TileSourceFactory1.AddTileSource(MyTileSource)
 
Last edited:

Spectre

Active Member
Licensed User
Longtime User
They will " melt " together the two tile to get the nuances altimeter overlaid on the map??

 

jndaniels1

Member
Licensed User
Longtime 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
 

warwound

Expert
Licensed User
Longtime User
Does offline tile caching work in the same manner as in the previous v3 library?

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.
 

anglia

Member
Licensed User
Longtime 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
 

warwound

Expert
Licensed User
Longtime 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.
 

anglia

Member
Licensed User
Longtime 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 m-

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
 

warwound

Expert
Licensed User
Longtime 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.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…