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,218
Last edited:

warwound

Expert
Licensed User
Longtime User
@androidvh

Take a look at these posts of mine:

http://www.b4x.com/android/forum/threads/osmdroid-mapview-for-b4a-tutorial.16310/page-19#post-243189
http://www.b4x.com/android/forum/threads/osmdroid-mapview-for-b4a-tutorial.16310/page-19#post-243189

The parameter is radius and can be configured as a fixed pixel size or as 'units of meters' relative to the map's current zoom level.
The second post i linked to explains inaccuracies due to how far from the equator your circle is.

Try drawing a circle on the equator and checking it's size - does this appear to be correct?

Martin.
 

PABLO2013

Well-Known Member
Licensed User
Longtime User
Tks for osm lib 4.1 and samples, greetings Martin,


I Do some questions:


1: How implemented in the new version 4.1, markersfocusoverlay options.


2: What is the best way to read files shape with osm, i have seen some applications (play-store), i think its used osm to read ... or in any case, not drawing lines between polygons.


3: Whe my app "pause" and “loading” it disable map tiles, what was happening?


4. Not find the way to show scale overlay , i reviewed your work samples 4.1, but not , do you have any idea?... today i have some practical and compas overlay and scale overlay and nothing?


Thanks
 
Last edited:

PABLO2013

Well-Known Member
Licensed User
Longtime User
GREETINGS
WHAT HAPPENS WHEN I USE FILL.STROKE, THE DRAWINGS is distorted TO THE LIMITS OF THE SCREEN . TKS
upload_2014-5-25_19-44-26.png
upload_2014-5-25_19-45-41.png
 

androidvh

Member
Licensed User
Longtime User
Hallo Martin,

I solve the problem with the circle as followed:

Dim pp As Float = distanceinpixel

distancepixel is the result in pixel with the given radius(m), point(lat and lon) and zoomfaktor(mapview)

that´s working fine

CircleOverlayItem1=CircleOverlay1.AddCircleOverlayItem(point,pp, CircleOverlay1.RADIUS_UNITS_TYPE_PIXELS, 1, Colors.ARGB(32, 255, 10, 10))


Kind regards Volker
 

merlin2049er

Well-Known Member
Licensed User
Longtime User
Hmm, I just re-created a few maps using mobac. I used osmdroid.zip as a format and mapquest maps for a tilesource (I grabbed zoom level 16 & 17).

What tile source should I use in my application? It was previously set to mapnik.
 

westingenieria

Active Member
Licensed User
Longtime User
Hmm, I just re-created a few maps using mobac. I used osmdroid.zip as a format and mapquest maps for a tilesource (I grabbed zoom level 16 & 17).

What tile source should I use in my application? It was previously set to mapnik.

I have the same question.... help!!!!!
 

merlin2049er

Well-Known Member
Licensed User
Longtime User
Thanks. I've just downloaded MapsForgeTileSource recompiled for version 4.1 of OSMDroid. Is this an upgrade? I've got 3_0_8 installed.
 

westingenieria

Active Member
Licensed User
Longtime User
know the tool Maperitive? I have a few minutes testing the generation mapnik through this and apparently it works ...
 

warwound

Expert
Licensed User
Longtime User
Thanks. I've just downloaded MapsForgeTileSource recompiled for version 4.1 of OSMDroid. Is this an upgrade? I've got 3_0_8 installed.

No the underlying code is the same - just required a few internal changes to make it 100% compatible with version 4.1 of OSMDroid.

Martin.
 

jamesnz

Active Member
Licensed User
Longtime User
know the tool Maperitive? I have a few minutes testing the generation mapnik through this and apparently it works ...
I have downloaded and restyled my country maps using maperitive, but how does one use these with the 4.1 library. I have loaded the above library but do I use the standard naming conventions, Is there an example anywhere ?
 

jamesnz

Active Member
Licensed User
Longtime User
Tilesourcespinner.AddAll(MapView1.GetTileProvider) <-- java.lang.ClassCastException: org.osmdroid.tileprovider.MapTileProviderBasic cannot be cast to java.util.List

MapView1.SetTileSource(tilesourcefactory1.GetTileSource("Mapnik")) <-- error : array expected

can't for the life of me get maps to display offline...
Since I could not work out how to set the tile source I loaded some of the unzipped raster tiles into /osmdroid/tiles/Mapnik , now they load, but, only from the unzipped file, not from the tile source(zip) file. This is a gps app so perhaps I will need to figure out a method of downloading and extracting zip files for relevant areas as I wont be able to package the whole country in the assets folder
 
Last edited:

warwound

Expert
Licensed User
Longtime User
If i can just let you all know that i am following this thread but currently having a 2 or 3 week break from programming.
It's summer in the UK and time for a holiday.

Please be patient and i'll catch up at a later date :).

Martin.
 

schimanski

Well-Known Member
Licensed User
Longtime User
Is it possible to save the tiles on the external sd-card? The /osmdroid-directory is on the internal storage by default. For using offline maps, it is much simpler and faster to save the tiles on the sd-card...

Thanks for help...
 

androidvh

Member
Licensed User
Longtime User
Hello Martin,

in older versions it was possible to create a local host as followed:

Dim Myxy AsXYTileSource
Myxy.Initialize("MapnikOffline", 10, 22, 256, ".png", "http://localhost/")
Mapview1.AddTileSource(Myxy)
Mapview1.SetTileSource("MapnikOffline")

I have found OSMDroid_TileSource...

Please what´s the way/syntax to do it in the new Version?

Kind regards
Volker
 
Top