B4A Library OSMDroid - MapView for B4A

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.
 

Attachments

  • OSMDroid_3_0_8_v3.60.zip
    361.9 KB · Views: 4,226
Last edited:

schimanski

Well-Known Member
Licensed User
Longtime User
O.k., I think, that it is possible to rename the tiles with mobac from .png to .png.tile, but it is one more step to make an offline tile archive.

But did you check your own tile archive? I made the same settings with the mobac as you say, but 20-30 percent of the downloaded tiles are black tiles. It is not possible to see this, when the tiles are downloaded. The black tiles are not shown as errors. When I copy the archive on my device, I see the dilemma...This behavior already exists after less than 10.000 tiles...:BangHead:

Perhaps, the problem only exists in germany???
 

warwound

Expert
Licensed User
Longtime User
Look at the MOBAC dialog that shows the progress of the creation of the tiles archive.
I often see errors where it requests a tile but for some reason the request fails.

You can set MOBAC to ignore errors and continue in the Settings under the Network tab.
If it's set to ignore errors then that may explain why you see black tiles.

I have MOBAC set to not ignore errors, if an error occurs i cancel the creation of the tile archive, wait a short while for my tile server to finish outstanding requests and then restart the creation of the tiles archive.
Bit by bit the request errors diminish until the archive is complete.

These errors tend to occur on my tile server when it gets overloaded with requests.
If my tile server has just a small amount of OSM data in it's database i can hammer it and it works perfectly.
If i have say the OSM data for the whole of Europe imported into the database then it is very slow and errors occur.

If MOBAC has already created tile archives which contain black tiles then i'd guess these invalid tiles have been cached by MOBAC and if you try to create the archive again it will use the invalid tiles.
You'd have to go into the MOBAC settings and under the Tile store tab delete all cached tiles for your tile server.
Then if you set it so that it doesn't continue on an error you should avoid any more invalid tiles being cached.

You could limit the number of parallel download requests to your tile server and limit bandwidth to see if that reduces the number of request errors.

Martin.
 

canalrun

Well-Known Member
Licensed User
Longtime User
OSMDroid updated to version 3.50

These changes are in preparation for the release of a new version which will incorporate the functionality of the OSMBonusPack.

Martin.

First, thanks for a great library.

Back in Nov 2012 you mentioned updating OSMDroid to support the OSMBonusPack. Not to put any pressure on, but this would be an excellent addition. Is this still the works?

Thanks,
Barry.
 

warwound

Expert
Licensed User
Longtime User
Hi Barry.

I did in fact 'more or less' wrap the OSMBonusPack into a b4a library last year.
Then i got busy with other things and simply forgot about the library.
('more or less' means it was a first test version and not ready for uploading to the forum).

Just last week someone has been asking me to create a routing/directions library for use with b4a and a Google Map and that's something i'll be working on over the next week or so.

Keep watching this thread and i'll update it once i've worked more on the OSMBonusPack.

Martin.
 

jchida

Member
Licensed User
Longtime User
How can I change the icon??

Hi Martin,
I´ve been playing with your OSMdroid lib and is awesome!
I need to change the default icon (MyLocationOverlay layer) to show my movements: byke, car, by walk, etc
is this possible?
hope so
Thanks
 

warwound

Expert
Licensed User
Longtime User
With the existing code that is not possible.
The default MyLocationOverlay icon is compiled into the library .jar file and it's name is hardcoded into the MyLocationOverlay code :(.

It's been a while since i looked at the OSMDroid code, i could take a look later.
I guess what you want to be able to do is to dyanmically set the MyLocationOverlay icon in code?

(You don't want to change the default icon and that's it, you want to be able change the icon on the fly?)

Martin.
 

jchida

Member
Licensed User
Longtime User
yes, that´s right
I want to change the icon in the code
Hope you can do it
Thanks for your fast reply
 

warwound

Expert
Licensed User
Longtime User
Can you test the attached updated library?

I've simple added a new (write-only) property to the MyLocationOverlay.

PersonIcon As Bitmap [write only]
Sets the icon used for the MyLocationOverlay.
The default icon is a 'pegman' type person icon.

Then i've updated the tutorial example '08 - OverlayMapMyLocation', added a new menu item 'Change icon'.
So load the project, enable MyLocationOverlay (using the menu option) and once the default MyLocationOverlay icon is displayed (a GPS fix has been found) click the 'Change icon' menu option.
You should see the default icon change to a cycle icon!

Note that the default person icon is 48 pixels square, as is my cycle icon.
The cycle icon aligns perfectly.
If you use a much bigger or much smaller icon it may not be correctly aligned to the 'radius circle'

If you have time to test various icon sizes and report what happens that would be handy.

Martin.
 

Attachments

  • 08 - OverlayMapMyLocation.zip
    8.2 KB · Views: 302
Last edited:

jchida

Member
Licensed User
Longtime User
Different size of icons

Martin:
As you said, if it's diferent from 48x48 pixels doesn´t fit OK

Note that the default person icon is 48 pixels square, as is my cycle icon.
The cycle icon aligns perfectly.
If you use a much bigger or much smaller icon it may not be correctly aligned to the 'radius circle'

If you have time to test various icon sizes and report what happens that would be handy.
Look at the screenshots
I´m going to use only 48x48 pixs...
 

Attachments

  • Mapa-Icon32x32.png
    Mapa-Icon32x32.png
    50.6 KB · Views: 318
  • Mapa-Icon48x48.png
    Mapa-Icon48x48.png
    52.6 KB · Views: 312
  • Mapa-Icon64x64.png
    Mapa-Icon64x64.png
    51.7 KB · Views: 302

electronik54

Member
Licensed User
Longtime User
need help with offline map

i am new to programming. i am makings a app which will use OSMdroid lib and Offline map. i used MOBAC to download offline map. i downloaded it in OSMDroid zip format(i hope thats correct format to use and its 10.1MB in size). how do i link it to map do we have a code or a example source code to do that?
 

ivanomonti

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

B4X:
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

'add markers
ovlMarkers.AddMarkers(Markers)

Posting a ZIP'd project makes answering such a question so much easier.

Martin.

you can set up a market to address only!

Marker1.Initialize("Home sweet home", "bla", "address", Icon)
 
Last edited:

padvou

Active Member
Licensed User
Longtime User
Hi!
First of all, thank you for the great work offered to all of us.
My question is, I'm trying to develop a simple app that would have a user type a couple or more addresses (street, number, area, country) and the pinpoint them on the map.
Could this be possible?
Thank you in advance.
 

warwound

Expert
Licensed User
Longtime User
You'll need to use the Geocoder library to convert the user entered address text into latitude,longitude coordinates that you can then use to place a Marker on a map.

Martin.
 

padvou

Active Member
Licensed User
Longtime User
If I change coordinates for, let's say three balloonmarkers, how do i remove the old and add the new ones?
Or even maybe just add new ones?
Or even maybe remove all of them...
:confused::confused:

OK, scrap the above questions, they are now resolved..
 
Last edited:
Top