Is there something like OSM for B4J?
Dim ml As DefaultMapLine
Dim lc As List
lc.Initialize
Dim C0,C1 As Coordinate
C0.Initialize(46.0,2.0)
C1.Initialize(46.0,3.0)
lc.Add(C0)
lc.Add(C1)
ml.Initialize(lc)
java.lang.ClassCastException: anywheresoftware.b4a.objects.collections.List cannot be cast to java.util.List
Thank Martin for this library.
I try to draw a polyline with this code
B4X:Dim ml As DefaultMapLine Dim lc As List lc.Initialize Dim C0,C1 As Coordinate C0.Initialize(46.0,2.0) C1.Initialize(46.0,3.0) lc.Add(C0) lc.Add(C1) ml.Initialize(lc)
but I get this error:
B4X:java.lang.ClassCastException: anywheresoftware.b4a.objects.collections.List cannot be cast to java.util.List
in B4J a list is not a java list?
Any idea
Thank you
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private MapPane1 As MapPane
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.Title="jFXtrasMapPane demo"
' the offline tiles used in this example can be downloaded from
' http://b4j.martinpearman.co.uk/jfxtras.labs.map/tiles/map_of_the_uk.zip
' be sure to modify the path to the offline tiles in CustomTileSource1.Initialize2
Dim CustomTileSource1 As CustomTileSource
CustomTileSource1.Initialize2("Panorama", "C:\Users\martin\Programming\Basic4Java\jFXtrasMapPane\CustomTileSource-demo\map_of_the_uk", 0, 3)
' the offline custom tiles are JPG images
' so i'll use a CustomTilePathBuilder so jpg tiles are requested
' (by default png tile are requested)
Dim CustomTilePathBuilder1 As CustomTilePathBuilder
CustomTilePathBuilder1.Initialize
CustomTilePathBuilder1.SetTileType("jpg")
CustomTileSource1.SetTilePathBuilder(CustomTilePathBuilder1)
MapPane1.Initialize3("", CustomTileSource1, 0, 0, 640, 480, 0)
MapPane1.SetDisplayPositionByLatLon(0, 0)
MainForm.RootPane.AddNode(MapPane1, 0, 0, 640, 480)
MainForm.Show
End Sub
''check zoom and center to apply to map pane 1
Dim zoomscale As Int
Dim cenPoint As Coordinate
cenPoint=MapPane1.GetCenterCoordinate
zoomscale=MapPane1.GetZoom
MapPane2.SetDisplayPositionByLatLon2(cenPoint.GetLatitude,cenPoint.GetLongitude,zoomscale)
You can use the MapPane_Rendered event.
Sub MapPane2_Rendered
Dim zoomscale As Int
Dim cenPoint As Coordinate
cenPoint=MapPane2.GetCenterCoordinate
zoomscale=MapPane2.GetZoom
MapPane1.SetDisplayPositionByLatLon2(cenPoint.GetLatitude,cenPoint.GetLongitude,zoomscale)
End Sub
@gvoulg
Yes that's possible.
Here's a snippet that contains everything you need:
B4X:Sub Process_Globals Private fx As JFX Private MainForm As Form Private MapPane1 As MapPane End Sub Sub AppStart (Form1 As Form, Args() As String) MainForm = Form1 MainForm.Title="jFXtrasMapPane demo" ' the offline tiles used in this example can be downloaded from ' http://b4j.martinpearman.co.uk/jfxtras.labs.map/tiles/map_of_the_uk.zip ' be sure to modify the path to the offline tiles in CustomTileSource1.Initialize2 Dim CustomTileSource1 As CustomTileSource CustomTileSource1.Initialize2("Panorama", "C:\Users\martin\Programming\Basic4Java\jFXtrasMapPane\CustomTileSource-demo\map_of_the_uk", 0, 3) ' the offline custom tiles are JPG images ' so i'll use a CustomTilePathBuilder so jpg tiles are requested ' (by default png tile are requested) Dim CustomTilePathBuilder1 As CustomTilePathBuilder CustomTilePathBuilder1.Initialize CustomTilePathBuilder1.SetTileType("jpg") CustomTileSource1.SetTilePathBuilder(CustomTilePathBuilder1) MapPane1.Initialize3("", CustomTileSource1, 0, 0, 640, 480, 0) MapPane1.SetDisplayPositionByLatLon(0, 0) MainForm.RootPane.AddNode(MapPane1, 0, 0, 640, 480) MainForm.Show End Sub
Martin.
is possible .map file?
This library will be further implemented?No.
I'm assuming by .map file you mean a MapsForge file?
You can display a MapsForge .map file in b4a using either OSMDroid or GoogleMaps but not in b4j.
If Martin be bored during the long winter evenings .....
Let's say it's on the back burner.
@gvoulg
Yes that's possible.
Here's a snippet that contains everything you need:
B4X:Sub Process_Globals Private fx As JFX Private MainForm As Form Private MapPane1 As MapPane End Sub Sub AppStart (Form1 As Form, Args() As String) MainForm = Form1 MainForm.Title="jFXtrasMapPane demo" ' the offline tiles used in this example can be downloaded from ' http://b4j.martinpearman.co.uk/jfxtras.labs.map/tiles/map_of_the_uk.zip ' be sure to modify the path to the offline tiles in CustomTileSource1.Initialize2 Dim CustomTileSource1 As CustomTileSource CustomTileSource1.Initialize2("Panorama", "C:\Users\martin\Programming\Basic4Java\jFXtrasMapPane\CustomTileSource-demo\map_of_the_uk", 0, 3) ' the offline custom tiles are JPG images ' so i'll use a CustomTilePathBuilder so jpg tiles are requested ' (by default png tile are requested) Dim CustomTilePathBuilder1 As CustomTilePathBuilder CustomTilePathBuilder1.Initialize CustomTilePathBuilder1.SetTileType("jpg") CustomTileSource1.SetTilePathBuilder(CustomTilePathBuilder1) MapPane1.Initialize3("", CustomTileSource1, 0, 0, 640, 480, 0) MapPane1.SetDisplayPositionByLatLon(0, 0) MainForm.RootPane.AddNode(MapPane1, 0, 0, 640, 480) MainForm.Show End Sub
Martin.