OK here's my first version of a wrapper for the KML packages in the Android Maps Utils.
The classes and methods i have wrapped so far are:
AndroidMapsUtils
Comment: http://googlemaps.github.io/android-maps-utils/javadoc/
Author: Martin Pearman
Version: 0.01
- KMLLayer
Methods:
- AddLayerToMap
- GetContainers As List
- GetPlacemarks As List
- HasContainers As Boolean
- HasPlacemarks As Boolean
- Initialize (GoogleMap1 As GoogleMap, InputStream1 As InputStream)
- Initialize2 (GoogleMap1 As GoogleMap, ResourceId As Int)
- IsInitialized As Boolean
- IsLayerOnMap As Boolean
- RemoveLayerFromMap
- Properties:
- Map As GoogleMap
- KmlContainer
Methods:
- GetContainers As List
Gets a List of nested KmlContainers.
- GetPlacemarks As List
Gets a List of KmlPlacemarks.
- GetProperty (PropertyName As String) As String
Gets a single property value for the given property name.
- GetStyle (StyleId As String) As KmlStyle
Gets a style for the given id.
- HasContainers As Boolean
- HasPlacemarks As Boolean
- HasProperties As Boolean
- HasProperty (PropertyName As String) As Boolean
- IsInitialized As Boolean
- Properties:
- ContainerId As String [read only]
Gets the Container ID if it is specified.
- Properties As Map [read only]
Gets a Map where Map Keys are property names and Map Values are property values.
- KmlPlacemark
Methods:
- GetId As String
- GetProperty (Property As String) As String
- HasGeometry As Boolean
- HasProperties As Boolean
- HasProperty (Property As String) As Boolean
- IsInitialized As Boolean
- Properties:
- InlineStyle As KmlStyle [read only]
- MarkerOptions As MarkerOptions [read only]
- PolygonOptions As PolygonOptions [read only]
- PolylineOptions As PolylineOptions [read only]
- StyleId As String [read only]
- KmlStyle
Methods:
- IsInitialized As Boolean
- SetLineStringWidth (Width As Float)
Sets the width of the LineString in screen pixels.
- SetMarkerHotspot (X As Float, Y As Float, xUnits As String, yUnits As String)
Sets the hotspot / anchor point of a marker.
- SetMarkerRotation (Rotation As Float)
Sets the rotation / heading of the Point in degrees clockwise about the marker's anchor.
- SetPolygonFillColor (FillColor As Int)
- SetPolygonStrokeWidth (StrokeWidth As Float)
Sets the stroke width of the Polygon in screen pixels.
- Properties:
- Rotation As Float [read only]
Gets the rotation of a marker in degrees clockwise about the marker's anchor.
A simple b4a project that loads a KML file from file assets - works for me though the web based infowindow content of the KML is a fail!
#Region Project Attributes
#ApplicationLabel: Android Maps Utils
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
' GoogleMaps additional jar
#AdditionalJar: com.google.android.gms:play-services-maps
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
End Sub
Sub Globals
Dim GoogleMap1 As GoogleMap
Dim MapFragment1 As MapFragment
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
If Not(MapFragment1.IsGooglePlayServicesAvailable) Then
Log("Google Play Services is not available")
ToastMessageShow("Google Play Services is not available", False)
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub MapFragment1_Ready
Log("MapFragment1_Ready")
GoogleMap1=MapFragment1.GetMap
If GoogleMap1.IsInitialized Then
Dim CameraPosition1 As CameraPosition
CameraPosition1.Initialize(52.7523, 0.4049, 10)
GoogleMap1.AnimateCamera(CameraPosition1)
Dim KMLLayer1 As KMLLayer
KMLLayer1.Initialize(GoogleMap1, File.OpenInput(File.DirAssets, "75116131-1-KML0.simple.kml"))
KMLLayer1.AddLayerToMap
If KMLLayer1.HasContainers Then
Dim Containers As List=KMLLayer1.GetContainers
' TODO
End If
If KMLLayer1.HasPlacemarks Then
Dim Placemarks As List=KMLLayer1.GetPlacemarks
' TODO
End If
Else
Log("Error initializing GoogleMap")
ToastMessageShow("Error initializing GoogleMap", False)
End If
End Sub
I'll attach this first version of my library, the simple demo project and a
temporary updated version of GoogleMapsExtras for you all to have a look at.
I shall release a proper update to GoogleMapsExtras over the next week - if you want to try AndroidMapsUtils and use the MarkerOptions object then overwrite you current GoogleMapsExtras jar and xml files with the temporary ones.
@DonManfred
Thanks a lot, once i found the latest version of the play services jar i was able to get SLC to work.
Let's liase later in the week to turn this into a shared collaboration.
Martin.