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,855
  • MapsForgeTileProvider_v1.01.zip
    173.1 KB · Views: 2,736
  • GoogleMapsExtras_v2_0_library_files.zip
    82.5 KB · Views: 3,157
Last edited:

warwound

Expert
Licensed User
Longtime User
GoogleMapsExtras updated to version 1.01

This minor update adds support for Polygon holes, you can now create complex polygons!

The Polygon object now has a read/write property named Holes.

The PolygonOptions object has a read-only property named Holes and an AddHole method.

The PolygonOptions object Points property is now read-only, instead of writing to the Points property (as with version 1.00) you instead use the new AddPoint or AddPoints methods.
This is syntactically better as the library actually adds any points passed to any existing points - it does not replace existing point.

The Polygon object however still has a read-write property named Points - setting this property will replace any existing points.

I'll upload a code example to the Google Maps Android v2 tutorial thread shortly.

Version 1.01 is attached to the first post in this thread.

Martin.
 
Last edited:

warwound

Expert
Licensed User
Longtime User
GoogleMapsExtras updated to version 1.20

This update adds support for the GoogleMap.InfoWindowAdapter.

You can now use your own View as either the InfoWindow or just the default InfoWindows content.

InfoWindowAdapter
Events:
  • GetInfoContents (Marker1 As Marker) As View
  • GetInfoWindow (Marker1 As Marker) As View
Methods:
  • Initialize (EventName As String)
  • IsInitialized As Boolean

I have also added a new method to the GoogleMapsExtras object:

AnimateToBounds (GoogleMap1 As GoogleMap, LatLngBounds1 As LatLngBounds, Padding As Int)
Adjust and animate the map center and zoom level so that it fully contains the LatLngBounds.
Padding is defined in units of pixels.


This method will be handy to fit the map to a number of markers.
You can create a LatLngBounds object that represents the geographical area that your markers are within and then animate the map to this bounds (fit the map to the markers).

I'll upload some example code to the Google Maps Android v2 tutorial thread shortly.

Version 1.20 is attached to the first post in this thread.

Martin.
 

bluedude

Well-Known Member
Licensed User
Longtime User
Great work, what about heatmaps?

Hi warhound,

Great work on the Android maps stuff. Have you ever taken a look at heatmaps?

There is a project here that might be interesting: https://code.google.com/p/mapex/

With this we could visualize a lot of information :)

Cheers,
 

warwound

Expert
Licensed User
Longtime User
Hi.

That heat map library is in fact written for the original android v1 map library, not the android v2 map library that we have in b4a.

Verison 2 of the map library is 100% different to verison 1 - any classes that were used in version 1 simply don't exist in version 2, so it's not possible to use that heatmap library in b4a.
Google have made all the java classes in version 2 final classes - they cannot be extended to add extra functionality - and that makes creating libraries such as the heatmap just about impossible.

Martin.
 
Last edited:

warwound

Expert
Licensed User
Longtime User
Hi Martin,

Can you possibly incorporate this request with your GoogleMapsExtras?

You can find more info on this at Using the ELabel extension.

Thanks in advance.

Erick

As i just posted - Google have very much limited the developers ability to create new map objects such as a custom overlay (an elabel would be a custom overlay).

I am part way through adding support for the Projection object to GoogleMapsExtras.
The Projection has methods: FromScreenLocation and ToScreenLocation which convert LatLng to and from a Point.
A Point represents 'screen coordinates' which i'd guess are coordinates relative to the View that contains the MapFragment.

So it may be possible to place a b4a View such as a Label at a geographical position by converting that position to screen coordinates and then adding the Label to the MapFragment container using the screen coordinates.
BUT you'd need to reposition that Label whenever the map camera moves - doesn't sound like it'd work very smoothly and could take a fair amount of processing to re-position just a handful of Labels.

If you want to add labels to your map and there is no requirement for these labels to be clickable then you could create a semi-transparent set of custom map tiles.
These tiles would be blank except where your labels have been drawn onto them.
Then you'd add these custom tiles to the map as a TilesOverlay.
Sounds possible and performance would be no problem.
BUT (another but!) you'd need to host these tiles online or experiment to see if a TilesOverlay can load tiles from the device external memory.

Martin.
 

warwound

Expert
Licensed User
Longtime User
GoogleMapsExtras updated to version 1.30

This update adds support for these objects:

Please follow the links for each new object to get more more info about the features the new object provides.
(I don't have time to create and upload examples code for all of these new objects at the moment so will leave you all to work out usage and syntax).

There is some example code already posted that may be of interest though:

IMPORTANT
The Google Maps Android API v2 library was updated Feb 2013, you will need to update your SDK to the latest version to use some of the new features of GoogleMapsExtras:

https://developers.google.com/maps/documentation/android/releases#february_2013

After updating your SDK be sure that you also copy the new (updated) google-play-services.jar to your b4a additional libraries folder, overwriting the old version.

I see a new Circle overlay has been introduced and will make that a part of the next GoogleMapExtras update.

Version 1.30 is attached to the first post in this thread.

Martin.
 

warwound

Expert
Licensed User
Longtime User
GoogleMapsExtras updated to version 1.31

This update adds support for the new Circle and CircleOptions classes.

Circle
Methods:
  • IsInitialized As Boolean
  • Remove
    Remove the Circle from the map.
Properties:
  • Center As LatLngWrapper
    Get or Set the Circle center.
  • FillColor As Int
    Get or Set the Circle fill color.
  • Id As String [read only]
    Get the Circle Id.
  • Radius As Double
    Get or Set the Circle radius in meters.
  • StrokeColor As Int
    Get or Set the Circle stroke color.
  • StrokeWidth As Float
    Get or Set the Circle stroke width.
  • Visible As Boolean
  • ZIndex As Float
    Get or Set the Circle ZIndex.
CircleOptions
Methods:
  • Center (LatLng1 As LatLng) As CircleOptions
    Sets the center using a LatLng.
  • Center2 (Latitude As Double, Longitude As Double) As CircleOptions
    Sets the center using latitude and longitude.
  • FillColor (FillColor As Int) As CircleOptions
    Sets the fill color.
  • GetCenter As LatLngWrapper
    Gets the center as a LatLng.
  • GetFillColor As Int
    Gets the fill color.
  • GetRadius As Double
    Gets the radius in meters.
  • GetStrokeColor As Int
    Gets the stroke color.
  • GetStrokeWidth As Float
    Gets the stroke width.
  • GetZIndex As Float
    Gets the ZIndex.
  • Initialize
    Creates a new CircleOptions.
  • IsInitialized As Boolean
  • IsVisible As Boolean
    Gets the visibility of this circle.
  • Radius (Radius As Double) As CircleOptions
    Sets the radius in meters.
  • StrokeColor (StrokeColor As Int) As CircleOptions
    Sets the stroke color.
  • StrokeWidth (StrokeWidth As Float) As CircleOptions
    Sets the stroke width.
  • Visible (Visible As Boolean) As CircleOptions
    Sets the visibility.
  • ZIndex (ZIndex As Float) As CircleOptions
    Sets the ZIndex.

GoogleMapsExtras object has a new method:

AddCircle (GoogleMap1 As GoogleMap, CircleOptions1 As CircleOptions) As Circle
Add a circle to the map.

As mentioned in my last post, you will need to update your SDK to the latest version of the google-play-services.jar library and make sure that you copy the new version from your SDK folder to your B4A additional libraries folder.

Version 1.31 is attached to the first post in this thread.

Martin.
 

warwound

Expert
Licensed User
Longtime User
GoogleMapsExtras updated to version 1.32

This is just a bug fix.
The Point object can now be successfully initialized.

Version 1.32 is attached to the first post in this thread.

Martin.
 

b4AMarkO

Member
Licensed User
Longtime User
I have been enjoying this .... and already adapting it to apps ....

But, question .... unless I have overlooked it .... I cant seem to find anything about how to fire an address and get back lat long cords

Seems this would be the fundamental aspect of using a map yes?

IS there an example or tutorial of how this is done?

Knowing the addresses I made a few changes to your code and ran it so my markers were correct

IM sure it can be done better but it works

B4X:
     Dim myList(4) As String 
       myList(0) = "7700 Riverside Dr."
       myList(1) = "71st & Riverside Dr."
       myList(2) = "71st & Yale"
       myList(3) = "81st & Riverside Dr."
       
        Dim Coords() As Double=Array As Double(36.051458, -95.971462, 36.0606416155383, -95.9758329391479, 36.060849, -95.922146, 36.046446, -95.9652328491211 )
        Dim i As Int
        For i=0 To Coords.Length-2 Step 2
            Dim Marker1 As Marker
            Marker1=GoogleMap1.AddMarker(Coords(i), Coords(i+1), myList(i/2)) '"Marker #"&(i/2))
            Marker1.Draggable=True
        Next
 
Last edited:

ivanomonti

Expert
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.

ERROR

Parsing code. 0.01
Compiling code. 0.02

ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code. 0.00
Generating R file. 0.07
Compiling generated Java code. Error
B4A line: 58
GoogleMapsExtras1.SetOnMarkerDragListener(mGmap, OnMarkerDragListener1)
javac 1.6.0_27
src\b4a\example\main.java:342: package com.google.android.gms.maps does not exist
_googlemapsextras1.SetOnMarkerDragListener((com.google.android.gms.maps.GoogleMap)(mostCurrent._vvvvv1.getObject()),(com.google.android.gms.maps.GoogleMap.OnMarkerDragListener)(_onmarkerdraglistener1.getObject()));
^
1 error

what's missing!! sdk

intalled google play service rev7 ok
 

warwound

Expert
Licensed User
Longtime User
Do you get the same problem if you compile in Release or Debug mode instead of Release(obfuscated) mode?

Martin.
 

warwound

Expert
Licensed User
Longtime User
GoogleMapsExtras updated to version 1.34

This update adds support for the deprecated OnMyLocationChangeListener:

OnMyLocationChangeListener
Events:
  • MyLocationChange (Location1 As Location)
Methods:
  • Initialize (EventName As String)
  • IsInitialized As Boolean

And a new GoogleMapsExtras method:

SetOnMyLocationChangeListener (GoogleMap1 As GoogleMap, OnMyLocationChangeListener1 As OnMyLocationChangeListener)
Sets a callback that's invoked when the my location dot changes location.
To unset the callback use Null.


Example usage syntax:

B4X:
Dim OnMyLocationChangeListener1 As OnMyLocationChangeListener
OnMyLocationChangeListener1.Initialize("OnMyLocationChangeListener1")
GoogleMapsExtras1.SetOnMyLocationChangeListener(GoogleMap1, OnMyLocationChangeListener1)

' and a Sub

Sub OnMyLocationChangeListener1_MyLocationChange(Location1 As Location)
    ' handle the location change here
End Sub

Version 1.34 is attached to the first post in this thread.

Martin.
 
Top