B4A Library OSMDroid - MapView for B4A

peacemaker

Well-Known Member
Licensed User
B4X:
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
java.lang.IndexOutOfBoundsException: Invalid index 2, size is 2


    at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
    at java.util.ArrayList.get(ArrayList.java:304)
    at uk.co.martinpearman.b4a.osmdroid.views.overlays.DeprecatedItemizedOverlayWithFocus.draw(DeprecatedItemizedOverlayWithFocus.java:166)
    at org.osmdroid.views.overlay.OverlayManager.onDraw(OverlayManager.java:119)
    at org.osmdroid.views.MapView.dispatchDraw(MapView.java:901)
    at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
    at android.view.View.draw(View.java:10981)
    at android.view.ViewGroup.drawChild(ViewGroup.java:2887)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
    at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
    at android.view.ViewGroup.drawChild(ViewGroup.java:2885)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)


    at android.view.View.draw(View.java:10981)
    at android.widget.FrameLayout.draw(FrameLayout.java:450)
    at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2126)
    at android.view.ViewRootImpl.draw(ViewRootImpl.java:2026)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1634)
    at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4424)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:592)
    at dalvik.system.NativeStart.main(Native Method)
At tapping the map sometimes i have this error :-(
ArrayList i guess is Markers. But i tap not over a marker.
What is the reason ?
 

warwound

Expert
Licensed User
@peacemaker

Your MarkersFocusOverlay contains 2 Markers indexed as 0 and 1, but the library code tries to get Marker at index 2.
The library is trying to get the Marker with the focus, so somewhere in the code the incorrect index is being set as the index of the focused Marker...

Have you removed any Markers from the MarkersFocusOverlay?
That is - did the MarkersFocusOverlay contain more than 2 Markers and then you've removed 1 or more Markers?

It might be that the index of the Marker with the focus was set, that Marker has been removed and that's left behind an invalid index - an index for a Marker that no longer exists.

Martin.
 

peacemaker

Well-Known Member
Licensed User
Thanks, Martin, will re-check.

For ref: cloudmade.com needs money :-(, email received:

If you wish to continue using the CloudMade services after April 30th you'll need to upgrade to an enterprise plan. Enterprise plans are available for customers with 10,000,000 or more transactions per month....

If your monthly usage is less than 10,000,000 transactions, or you don't wish to upgrade to an enterprise plan, you should take action to update the app or website that's using the CloudMade API keys shown above to use an alternative provider.
 

warwound

Expert
Licensed User
:(

I guess all good (free) things must come to an end.
It's a shame that Cloudmade will no longer allow free access to their tiles.

The other options - the free open street map based servers - just don't have the resources to provide a fast and reliable tile server.

Martin.
 

peacemaker

Well-Known Member
Licensed User
Sure, the good service should be paid, but amont is different, 10M tiles, i guess, it's very big app.
My app has a counter of zooms using your OSM via CloudMade, during development latest months it was about 700 zooms (3 months). No idea how many tiles were downloaded, but always the same area, and cashed.
I guess, it's far from 10M per month.

UPD: so just Mapnik is OK for time being...
 
Last edited:

Kwame Twum

Active Member
Licensed User
library can't seem to download right... stops halfway, cannot open.
tried with several browsers... even with my smartphone... still doesn't work... pls help.
 

warwound

Expert
Licensed User
@Kwame Twum

I just downloaded the library files from the first post in this thread with no problems.
I can only guess a temporary network problem prevented you from doing so earlier.

Can you try again?

Martin.
 

Beja

Expert
Licensed User
Hi warwound,
Today I downloaded and tried to run the example.. but faced by a couple of typos that I corrected, but this one I couldn't..
missingparam.png
Please help
 

warwound

Expert
Licensed User
@Beja
Look at the reference on this page: http://www.basic4ppc.com/android/forum/threads/geocoder-library.17115/

GetFromLocation (Latitude As Double, Longitude As Double, MaxResults As Int, Tag As Object)
Gets an Array of Address objects that describe the area immediately surrounding the given Latitude and Longitude.
The Array of Address objects is passed back to B4A in the GeocodeDone event along with the Tag Object.
Tag is not used by this method, it is simply a means by which you can associate an identifying Object with this task.


You're missing the Tag parameter.
This parameter performs absolutely no function - you pass it to GetFromLocation and it is passed back to you in the GeocodeDone event.
Pass Null or "" empty string if you have no use for it.

The idea was that if you were to geocode more than one address at a time then you could pass a unique Tag value each time you call GetFromLocation and then in the GeocodeDone event you'd be able to identify which GetFromLocation had caused the event to be raised.

Martin.
 

PABLO2013

Active Member
Licensed User
Greetings Martin
How should declare PathOverlay1.STROKE o PathOverlay1.STROKE y FILL_AND_STROKE?
thanks
 

PABLO2013

Active Member
Licensed User
GREETINGS
THANK YOU AGAIN FOR YOUR VALUABLE INFORMATION.
I REVIEWED THIS, BUT WITHOUT UNDERSTANDING REGARDING ONGOING
IF YOU CAN BE POSSIBLE IN A FEW LINES Notify AS USED OR REPRESENT
STROKE constants to the PathOverlay OR SetPathStyle method
THANKS
 

ErickAsas

Member
Licensed User
Hi Martin,

I have been experimenting with OSM droid 3.08, and I have been successful with my requirements. However, i am somewhat at a loss with version 4.01. Can you upload some tutorials on the new version?
 

warwound

Expert
Licensed User
Hi Martin,

I have been experimenting with OSM droid 3.08, and I have been successful with my requirements. However, i am somewhat at a loss with version 4.01. Can you upload some tutorials on the new version?
There's a small number of version 4.1 demo projects available on my website along with the library files themselves.

The latest version 4.1 library files are here:
http://b4a.martinpearman.co.uk/osmdroid/OSMDroid_library_files_v4.1_20140428.zip

4 demo projects in this archive:
http://b4a.martinpearman.co.uk/osmdroid/OSMDroid_v4.1_examples.zip

And a single demo showing the new CircleOverlay here:
http://b4a.martinpearman.co.uk/osmdroid/CircleOverlay-20140505.zip

If you try version 4.1 and find anything from version 3.8 is missing then let me know.

Martin.
 

ErickAsas

Member
Licensed User
Thanks Martin. I'll try to revise my 3.08 project to use version 4.1. By the way, is 3.08 MapsForgeTileSource compatible with OSMDroid 4.1? Or is there a different implementation when using offline maps?

Edit:
Oh, it's compatible Martin. I was able to run the offline map(*.map) using mapsforgetilesource 3.08.

B4X:
'  the MapsForgeTileSource has not been added to the MapView so create it and add it to the map
  Dim MapsForgeTileSource1 As MapsForgeTileSource
  '  set the required MapsForgeTileSourceOptions MapDatabaseFile and TileSourceName
  MapsForgeTileSource1.GetMapsForgeTileSourceOptions.SetMapDatabaseFile(File.DirRootExternal & "/data/com.pldtphilcom.EZSubMining", "philippines.map")
  MapsForgeTileSource1.GetMapsForgeTileSourceOptions.SetTileSourceName("MapsForge1")
   
  '  example of setting an optional MapsForgeTileSourceOptions
  '  MapsForgeTileSource1.GetMapsForgeTileSourceOptions.SetTextScale(2.0)
  '  now that the required MapsForgeTileSourceOptionshave been set we can call the MapsForgeTileSource Initialize method
  MapsForgeTileSource1.Initialize
 
  MapView1.Initialize("MapView1")
  MapView1.SetBuiltInZoomControls(True)
  MapView1.SetMultiTouchControls(True)

  MapView1.SetTileSource(MapsForgeTileSource1)
 
Last edited:

warwound

Expert
Licensed User
I see you got it to work.
I did in fact recompile the MapsForgeTileSource to for OSMDroid version 4.1, that's available here:
[edit]url removed[/edit]

Martin.
 
Last edited:

ErickAsas

Member
Licensed User
Can you compile this library to be used in b4a? I don't have any know-how of eclipse. Sorry...

Thanks in advance.
 
Top