B4A Library GoogleMapsExtras

GoogleMapsExtras is an ongoing project to implement more of the Google Maps Android v2 classes in Basic4Android.

Currently the library allows you to create these objects:

Tutorials for each object will be uploaded to the Google Maps Android v2 tutorial thread.

Martin.
 

Attachments

  • GoogleMapsExtras_v1_71.zip
    59.6 KB · Views: 2,853
  • MapsForgeTileProvider_v1.01.zip
    173.1 KB · Views: 2,733
  • GoogleMapsExtras_v2_0_library_files.zip
    82.5 KB · Views: 3,154
Last edited:

Blueforcer

Well-Known Member
Licensed User
Longtime User
it works when i rename the class..thanks:
I have another question:
i live in a big city(Frankfurt, germany)
On www.google.de/maps i can view the Map in 3D with all 3D buildings.
but when i use googlemapsextras it show me the same flat thing as before.
B4X:
gmapsextra.SetBuildingsEnabled (gmap, True)

Is "Turns the 3D buildings layer on or off." the same as i can see on the googlemaps website?
 

jchal

Active Member
Licensed User
Longtime User
GoogleMapsExtras is an ongoing project to implement more of the Google Maps Android v2 classes in Basic4Android.

Currently the library allows you to create these objects:

Tutorials for each object will be uploaded to the Google Maps Android v2 tutorial thread.

Martin.
i tryed to run this example but i got this error
Cannot find: C:\Program Files (x86)\Anywhere Software\Basic4androidv6\libraries\google-play-services.jar
i know that google-play-services.jar does not exisi any more how can i alter the code and mae it work?
 

DonManfred

Expert
Licensed User
Longtime User

MarcoRome

Expert
Licensed User
Longtime User
Hi @warwound
The method GeoJSON is a common standard for sharing geospatial data on the internet.
The Google Maps Data Layer provides a container for arbitrary geospatial data (including GeoJSON)
GeoJSON uses JSON (JavaScript Object Notation) to represent its data, in the same way that KML uses XML.
Also another tools example ( ARcGis ) export data in json
This would be a big and important feature to add, if possible.
Thank you in advance for your answer
 

Attachments

  • example-json.zip
    54.7 KB · Views: 267

warwound

Expert
Licensed User
Longtime User
I've spend some time on this update but have nothing to upload yet.
There's an awful lot of useful features in the AndroidMapsUtil and i bet someone at at some point will want each and every feature.

Simple import of KML files will be the first thing i get working, after that we'll see what's most wanted by you forum members.
I'll post again during the week as i make progress.
 

MarcoRome

Expert
Licensed User
Longtime User
I've spend some time on this update but have nothing to upload yet.
There's an awful lot of useful features in the AndroidMapsUtil and i bet someone at at some point will want each and every feature.

Simple import of KML files will be the first thing i get working, after that we'll see what's most wanted by you forum members.
I'll post again during the week as i make progress.
Very Big work Warwound. Thank you again a lot
 

DonManfred

Expert
Licensed User
Longtime User
I've spend some time on this update but have nothing to upload yet.
I´ve spend some time too. I have a GeoJsonLayout working loading a json from a string given from b4a

Screenshot_20170729-115320_new.png



And i see what you mean when saying
awful lot of useful features in the AndroidMapsUtil and i bet someone at at some point will want each and every feature
:)

I would like to contribute to your wrapper if you decide to opensource it
 

warwound

Expert
Licensed User
Longtime User
I would like to contribute to your wrapper if you decide to opensource it

I shall do that once i can compile it....

How do we compile a library that depends on Play Services these days?
There's no google-play-services.jar files available to use within Eclipse.
My AndroidMapsUtils b4a library is an Android Library project in AndroidStudio, it compiles to an .aar file no problems.
BUT how do i generate my XML file?

SimpleLibraryCompiler refuses to compile my library source as i cannot figure out a way to include the GoogleMaps component of Play Services.

Can you help?
 

DonManfred

Expert
Licensed User
Longtime User
How do we compile a library that depends on Play Services these days?
There's no google-play-services.jar files available to use within Eclipse.
You are right. It is gone in the way we know it.
Google has splitted it into smaller parts.
If you already updated to B4A 6+ then you have the maven repositories installed i guess.

Start with this zip. It contains my wrappercode as of today (still working on it).
I zipped the hole eclipse projectfolder.

https://www.dropbox.com/s/wxsdirdvqifr42f/GoogleMapKML.zip?dl=0

Ectract it and focus on the content of the libs folder.

Snap8.png

the jars are the extracted classes.jar from the AAR file.
You need to reference this in Eclipse to get the Objects....

Now. Where do i get them?

In my case (Android.SDK-path)\extras\google\m2repository\com\google\android\gms\play-services-maps\11.0.2
Look at (Android.SDK-path)\extras\google\m2repository\com\google\android\gms for the single packages

My AndroidMapsUtils b4a library is an Android Library project in AndroidStudio, it compiles to an .aar file no problems.
I never worked with AS in the way i write my wraps with it. I usually use it to compile 3rd Party Libs.

i write my wraps all with eclipse. If i want to include code from an aar i ectract the classes.jar and include it into eclipse to reference the objects.
I use slc to compile my projects based on the projectname in the Eclipseworkspace.

I use the external tools configuration inside eclipse.
Snap9.png


The point is that you always need to update the referenced "classes.jars"s into the libs folder...

@corwin42 is using Android Studio too. He is using a batch-file to create the XML or so.
Don´t know exactly. I would like to know how it would work with Android Studio.

Maybe this can help you?
https://www.b4x.com/android/forum/t...raries-maybe-in-the-future.75307/#post-478221
 

warwound

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

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

Attachments

  • AndroidMapsUtils-KML-20170730.zip
    269.4 KB · Views: 369

warwound

Expert
Licensed User
Longtime User
Take a look at this demo apk, i compiled it from the (java) AndroidMapUtils source.
Some parts of the demo do not 'work', for example the heatmap displays a toast telling you to register an api key and recompile.
I was impressed to see that the KMLLayer handles KML with 'floor levels', the clustering example is cool and tbh most of the demo is very impressive!

Looks like a lot of work to wrap the lot so lets decide what's most important (fun?) and wrap that first.

@DonManfred Can you work with an SVN repo?
You'd just need to pull and commit, nothing fancy.
If so i'll let you have access to a repo with my (android studio based) source project.
 
Top