Android Tutorial OSMDroid - MapView for B4A tutorial

jsk001

Member
Licensed User
Longtime User
...Is there a way to display the marker info immediately (without clicking) ???


 

shashkiranr

Active Member
Licensed User
Longtime User
Hi Warwound,

I want to create an offiline map. I am using MOBAC but i am not able to download for mapnik as they have removed the support to download. Is there any way i can download and create the files for osm?

Regards,
SK
 

warwound

Expert
Licensed User
Longtime User
Hi Warwound,

I want to create an offiline map. I am using MOBAC but i am not able to download for mapnik as they have removed the support to download. Is there any way i can download and create the files for osm?

Regards,
SK

Take a look here:
https://switch2osm.org/serving-tiles/

You could set up your own tile server and connect to your tile server with MOBAC.

If you don't have a linux box available I'd suggest using VirtualBox to create a virtual Ubuntu 12.04 box.
Install the packages: https://switch2osm.org/serving-tiles/building-a-tile-server-from-packages/
Then download the binary map data and you can then generate your own tiles.
 

Carlo2015

Member
Licensed User
Longtime User
hi! Im new to b4a and I am impressed with its capabilities. and to you warwound for this great lib.

now my question is can I use this http://download.geofabrik.de/asia.html with your library? and if yes then can you please show some example?

when i browsed the folder where the tiles are found the format of the files are in .png.tile but the file from the above link is in pbf and it says "suitable for Osmium, Osmosis, imposm, osm2pgsql, mkgmap, and others".

I am confused about this one.

Or can you please give me a link where I can download mapnik tiles for asia or just for the Phlippines?

I need to let my users have it preinstalled before they went on their way.

Thanks

Edit: Im now experimenting with Mobile Atlas Creator. Will ask more questions if I hit a wall again.
 
Last edited:

warwound

Expert
Licensed User
Longtime User
@Carlo2015

There links to .osm.pbf file on the Geofabrik page and you can download these and display them offline on either OSMDroid or GoogleMaps.
Search the forum for MapsforgeTileSource (for OSMDroid) and MapsForgeTileProvider (GoogleMaps).

These .osm.pbf files are binary databases containing Open Street Map data and are far smaller in size than an equivalent 'offline tile archive' created by MOBAC which would contains 1000s of tile images.
 

Carlo2015

Member
Licensed User
Longtime User
warwound thanks for the fast reply, I was able to download maps for OSMPublicTransport but the files inside the folders(zip) are just .png whereas the files created by your examples are in .png.tile

I am more confused now.

Anyway I'm no way near giving up.
 
Last edited:

warwound

Expert
Licensed User
Longtime User
.png and .png.tile are identical...

I think that naming a .png to .png.tile simply prevents the android media scanner finding the tile images and so prevents the tile images from appearing in the device's Gallery.
 

Carlo2015

Member
Licensed User
Longtime User
Great!

I am currently fetchng tiles for the whole Philippines. I will just use a windows application to rename all png in the folder.

I will update here for the results.


Thanks.
 

warwound

Expert
Licensed User
Longtime User
Great!

I am currently fetchng tiles for the whole Philippines. I will just use a windows application to rename all png in the folder.

I will update here for the results.


Thanks.

http://download.geofabrik.de/asia.html
See the .oms.pbf binary data for the entire Philippines is 'just' 111MBs?
Once converted from .osm.pbf format to the MapsForge .map format that's likely to be around 60MBs.

So your choice is to have either:
  • A (massive) tile archive containing many .png tile images.
    This will look best on the device - the tiles should be quick to load.
    Coverage of different areas and zoom levels will depend entirely on what tile images you have in your tile archive.
    The tile archive will likely be far larger than 60MBs.
  • A single MapsForge binary database of around 60MBs.
    Rendering map tiles on the fly on the device is a single threaded solution.
    So when your map requires tiles they get queued and rendered one at a time.
    That results in a not so good user experience - not as good as an offline tile archive.
    But the MapsForge .map file will give you coverage of the entire Philippines at all zoom levels.

I've downloaded and am converting the Philippines .osm.pbf file to MapsForge .map format now and i'll post again when the conversion is complete.
You can compare an offline tile archive to a MapsForge binary database and choose which one to use.

Martin.
 

warwound

Expert
Licensed User
Longtime User
The Philippines .osm.pbf file converted to a MapsForge .map database of 111Mbs in size.
Normally the conversion results in a much smaller file but i guess with all the coastline data for the Philippines, the file size didn't reduce.

You can download the Philippines MapsForge .map file here:
http://b4a.martinpearman.co.uk/osmdroid/philippines.map.zip

Can you let me know when you have downloaded it - i'll then delete it from my server.

Thanks.
 

rayofcumbria

Member
Licensed User
Longtime User
Hi Warwound,

I want to create an offiline map. I am using MOBAC but i am not able to download for mapnik as they have removed the support to download. Is there any way i can download and create the files for osm?

Regards,
SK
Hi SK, try here for offline maps
http://download.mapsforge.org/maps/

here's how I load them too:
' OSM 4.1 library used
Private osmMaps As OSMDroid_MapView
Private MFTSrc As MapsForgeTileSource

MFTSrc.GetMapsForgeTileSourceOptions.SetMapDatabaseFile(File.DirRootExternal, "mapname.map")
MFTSrc.GetMapsForgeTileSourceOptions.SetTileSourceName("MyOwnMap")
MFTSrc.Initialize

osmMaps.Initialize("osmMap")

osmMaps.SetUseDataConnection(True)
osmMaps.SetTileSource(MFTSrc)
 
Last edited:

warwound

Expert
Licensed User
Longtime User
thanks, done that but it moves too frequently based on gps movement

You'll have to implement some sort of 'smoothing' algorithm into your code to smooth/normalize the changes in orientation.
Not sure what technique is required though.
 

G-ShadoW

Active Member
Licensed User
Longtime User
how to change personicon as android.graphics.bitmap
MyLocationOverlay1.PersonIcon ?
 

Tom1s

Member
Licensed User
Longtime User
I couldn't find osmroid 4.1 mapsforgetilesource example ? Is the older one still working with 4.1?
 

Tom1s

Member
Licensed User
Longtime User
I got it working. It works with Activity.AddView(MapView1, 0,0, 100%x, 100%y)
Not with panel7.AddView(MapView1, 0,0, 100%x, 100%y)

Is it possible to use it somehow like this:
Activity.LoadLayout("Pagemain") 'containts actionbar and pcontent

pContent.LoadLayout("page1")'contains panels

pContent.AddView(MapView1, 0,0, 100%x, 100%y) ' this works one time. I have a menu and i like to switch between panels and this map?

Removeviews and then again?
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…