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:

monki

Active Member
Licensed User
Longtime User
Hello Martin,

I use in my app the snapshot but this function does not work with the version 1.80 of Google Maps extra, compiler to die with the following error message


Parsing code. 12:16
Compiling code. 00:14
Compiling layouts code. 12:01
Generating R file. 0.74
Compiling generated Java code. Error
B4A line: 242
gmext.Snapshot (mGmap, \
javac 1.6.0_21
src \ btclient \ dfe \ gm.java: 414: can not find symbol
symbol: class GoogleMap
location: class btclient.dfe.gm
_gmext.Snapshot (ba, (GoogleMap) (_mgmap.getObject ()), "Mcopie");


With V 1.71 it works.
Monki
 

Euxaes

Member
Licensed User
Longtime User
I updated also mine and now I cannot debug my app.

here are the details:
B4X:
Parsing code.                          0.28
Compiling code.                        1.02
Compiling layouts code.                0.16
Generating R file.                      21.85
Compiling generated Java code.          Error
B4A line: 182
carMark=gmapextras.AddMarker(gmap,customMarker)
javac 1.7.0_45
src\b4a\gsmlocator\main.java:1158: error: cannot find symbol
_carmark = mostCurrent._gmapextras.AddMarker((GoogleMap)(mostCurrent._gmap.getObject()),(com.google.android.gms.maps.model.MarkerOptions)(_custommarker.getObject()));
                                              ^
  symbol:  class GoogleMap
  location: class main
 

warwound

Expert
Licensed User
Longtime User
Version 1.80 re-uploaded - hopefully fixes the corrupt xml previously uploaded.

@monki and @Euxaes
Can you download version 1.80 again and give it a try - i'm not sure what the problem was but i rebuilt the xml file and it seems to work now.

Martin.
 

rboeck

Well-Known Member
Licensed User
Longtime User
Hi Martin,

thanks for your work! Now it compiles and starts, but..

in the line: if MapFragment1.IsGooglePlayServicesAvailable = false then
i get:
java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4452000 but found 4030500. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

I have checked it more than once, i cannot find a difference between the lines in your sample and my manifest file.
Thanks,
Reinhard
 

warwound

Expert
Licensed User
Longtime User
@rboeck

The problem is either an old version of the Google Play Services in your b4a additional libraries folders OR an old version of the Google Play Services is installed on the android device.
You can copy the version of google-play-services.jar from the android SDK folders to your b4a additional libraries folder to make sure that is not the problem.
If the problem continues then i'd suspect that the device has not yet received the May 2014 Google Play Services update from the Play Store - you can visit the Play Store on the device and hope that this forces the latest update to install but i'm not 100% sure what else can be done.

Martin.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Make sure that Google Play services version on the device is 4.4.52:
upload_2014-6-3_10-41-3.png


2. Update Google Play Services in Android SDK Manager and copy the latest google-play-services.jar from ...extras\google\google_play_services\libproject\google-play-services_lib\libs to the additional libs folder.
 

rboeck

Well-Known Member
Licensed User
Longtime User
Hi Martin and Erel,

i checked all google play versions and found one older properties file, which i changed without any sucess.
The version on the tablet is the correct one, also any versions on the pc.

But now i looked in the path Objects\projects\res\values and found one file from october 2013: version.xml, write protected
Inside this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="google_play_services_version">4030500</integer>
</resources>

Now i changed this value to the correct one, saved it write protected and now it works. I dont know, why this value is there, now i renamed it to another name and it works without the original file.

I have no idea, why this file is there, maybe from an old tipp from the forum...
Thanks for your work
 

warwound

Expert
Licensed User
Longtime User
I have no idea, why this file is there, maybe from an old tipp from the forum...
Thanks for your work

Before the AdditionalRes project attribute was available, there was only one way to include additional resources in your project - that was to copy the additional resources to your project's Objects\res folder and mark them read only.

I'd guess that previously you'd copied some or all of the Google Play Services to your project's Objects\res folder, marked them read only and then forgotten about them?

Martin.
 

iz0ndg

Active Member
Licensed User
Longtime User
Hi Martin,
sorry for my english, and thank's for your time !
I have a small problem with the function MyLocationChange, check if I'm moving and I update the map, centering on my position.
With a zoom of 15, however, moving a few miles by car (perhaps by changing tile?), The map does not update properly, it remains as if it were a much larger gif. Just make a zoom with your fingers and the map is reloaded well.
How can I force it to do a refresh to reload it?
This is the part of my code:

B4X:
Sub OnMyLocationChangeListener1_MyLocationChange(Location1 As Location)
Log("OnMyLocationChangeListener1_MyLocationChange")
    Dim zoom As Int = 14
    mylocation = Location1
    Log(mylocation)

    lblgps.Text = "Lat. : " & NumberFormat(Location1.Latitude,1,8) & " Long. : " & NumberFormat(Location1.Longitude,1,8)
    Log(Location1.Latitude & "-" & Location1.Longitude)
    If tbsegui.Checked = True OR gpsfix = False Then
        Dim cp As CameraPosition
        Dim CameraUpdateFactory1 As CameraUpdateFactory
        Dim CameraUpdate1 As CameraUpdate
    
        If gpsfix = False Then
            cp.Initialize(Location1.Latitude, Location1.Longitude, zoom)
        Else
            cp.Initialize2(Location1.Latitude, Location1.Longitude, zoom,Location1.Bearing,0)
        End If
    
        CameraUpdate1=CameraUpdateFactory1.NewCameraPosition(cp)
        GoogleMapsExtras1.MoveCamera(gmap,CameraUpdate1)
         lblkmh.Text = NumberFormat((Location1.Speed * 60 * 60)/1000,1,1) & " Km/h"
'        gmap.MoveCamera(cp)
        DoEvents
        gpsfix = True
    End If
End Sub
 

warwound

Expert
Licensed User
Longtime User

Euxaes

Member
Licensed User
Longtime User
I'm using the LatLngBoundBuilder to zoom into an area bounded by all markers created. When I run the app, I encounter an initialize error during app start-up. This is how I coded the said feature:

B4X:
Sub Globals
    Dim markerBoundary As LatLngBoundsBuilder
    Dim markerBounds As LatLngBounds

B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Main")
    If FirstTime Then   
        markerBoundary.Initialize
    End If

I always call a sub called "SetMarkers" whenever placing a marker on the map as well as store the marker details on a map. I also have a "View All" button that when clicked will activate the following code:

B4X:
    markerBounds=markerBoundary.Build
gmapextras.AnimateToBounds(gmap,markerBounds,128)

Now my question is, where is the proper place in my code to place the Dimming of markerBoundary and markerBounds as well as the proper initialization of markerBoundary? I place the codes in that manner because I thought if I place the initialize code in SetMarkers, it will reset the variable set by the code below whenever SetMarkers is called.
B4X:
    markerBoundary.Include(carMark.Position)
.
 

warwound

Expert
Licensed User
Longtime User
@Euxaes

That's tricky to answer without see the entire code module.
Can you upload your project as a zip file and i'll have a look?

Martin.
 

Euxaes

Member
Licensed User
Longtime User
Here you go. When I run the app on actual deployment, the LatLngBounds Initialize error pops occasionally, please help me how to fix the said problem. Thank you.
 

Euxaes

Member
Licensed User
Longtime User
@warwound, have you seen the source I uploaded? I would like to know how it should be corrected. Thanks in advance for the guidance.
 

warwound

Expert
Licensed User
Longtime User
@warwound, have you seen the source I uploaded? I would like to know how it should be corrected. Thanks in advance for the guidance.

Hi, yes looking at it now.

I'd guess that the problem is that your LatLngBoundsBuilder is declared as a Global and not a Process Global.
It's dimmed each time the Activity is created but initialized only when FirstTime is True.
(When it's dimmed it's set to an uninitialized state).

Try moving:

B4X:
Dim markerBoundary As LatLngBoundsBuilder

From Sub Globals to Sub Process_Globals.

Martin.
 

Euxaes

Member
Licensed User
Longtime User
@warwound
Thank you very much for the response! I'll observe tomorrow whether the error would still occur but for sure I think it is already resolved :)
 
Top