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:

warwound

Expert
Licensed User
Longtime User
Take a look here: https://developers.google.com/maps/...ndroid.gms.maps.GoogleMap.CancelableCallback) for info on the callback:

An optional callback to be notified from the main thread when the animation stops. If the animation stops due to its natural completion, the callback will be notified with onFinish(). If the animation stops due to interruption by a later camera movement or a user gesture, onCancel() will be called. The callback should not attempt to move or animate the camera in its cancellation method.

Any user gesture will cause the animation to stop and the Finish event will not be raised.

If that's not the problem then maybe you are trying to re-use the CancelableCallback and that's not allowed?
Maybe you need to call the CancelableCallback Initialize method again after it has been used?

Whats the state of your windows computer?

Beyond repair - it needs a format and clean install.
I'm tempted to install Xubuntu and run Windows as a virtual machine but am not sure how well that will work.
(I wish i'd never bothered upgrading to Windows 8 :mad: ).

Martin.
 

rboeck

Well-Known Member
Licensed User
Longtime User
Hi Martin,

everything works; currently i fly from start to melbourne, then to google. Now i have to play with zoom, bearing and tilt to make a better fly feeling. I hope my donation is fair for your work... (rboeck@utanet.at)
I will make same further test and if i find something, i will contact you in the next two days.

Reinhard

P.S.: My windows 8 didnt find the way at my working machine, its only the third partition on my notebook; and very few times in use...
 

warwound

Expert
Licensed User
Longtime User
Great - it works!
And thanks for the donation - much appreciated.

Can you tell me if you had to call the CancelableCallback Initialize method (again) if you tried to use the CancelableCallback more than once?
Ie you fly to Melbourne so use the CancelableCallback and it's Finish event is raised, now you fly to Google and use the CancelableCallback again - did you call Initialize here again?

Is a Tag property useful in the CancelableCallback?
The Tag would be of type Object.
You'd be able to set the Tag value in Initialize and also access it as a read/write property.
When the CancelableCallback raises either of it's 2 events, the Tag value would be passed to the event Sub.

Does that sound useful - maybe an easy way to identify which animation has just caused the Cancel or Finish event to be raised?

Xubuntu 13.10 is now installing on my laptop, and i've revived an old media center on which i'll install Windows 7 and Basic4Android, i'll forget about Windows 8.
Basic4Android is the only application that i use that requires Windows, otherwise i'd not even bother having a Windows computer to hand.

Anyway - should be back up and coding B4A within a day :).

Martin.
 

rboeck

Well-Known Member
Licensed User
Longtime User
My first working example:

B4X:
Sub PlayRoute

Dim CancelableCallback1 As CancelableCallback
CancelableCallback1.Initialize("CancelableCallback1")

Dim LatLng1 As LatLng

Select Case St

Case 0
            LatLng1.Initialize(37.4,-122.1)
            GoogleMapsExtras1.MoveCamera(GoogleMap1, CameraUpdateFactory1.NewLatLng(LatLng1))
            CameraUpdate1=CameraUpdateFactory1.NewLatLngZoom(LatLng1, 4)

            GoogleMapsExtras1.AnimateCamera3(GoogleMap1, CameraUpdate1, 7000, CancelableCallback1)
Case 1
            LatLng1.Initialize(-33.88, 151.21)
            CameraUpdate1=CameraUpdateFactory1.NewLatLngZoom(LatLng1, 5)
            GoogleMapsExtras1.AnimateCamera3(GoogleMap1, CameraUpdate1, 7000, CancelableCallback1)
End Select
End Sub

Sub CancelableCallback1_Cancel
   Log("Cb_Cancel" & St)
End Sub

Sub CancelableCallback1_Finish
   Log("Finish")
   St=St+1
   PlayRoute
End Sub

I made one global var named st as int for controlling the steps. In Callback_Finish i count; the next idea is to transmit the data in a list or list of maps.
Maybe i use the sensors to change the direction at runtime - this would be the very first step to an flight simulator...
The tag property would replace my global variable st, which now informs, which step was made last; but if nothing else is to change, i would not change it for this one thing only.

Reinhard
 

warwound

Expert
Licensed User
Longtime User
GoogleMapsExtras updated to version 1.60

This update adds support for the various methods to animate a change in camera position.
For more information on what is available in the native android GoogleMaps library take a look here:
https://developers.google.com/maps/documentation/android/views.

And for more information about which new objects and methods have been added to GoogleMapsExtras take a look here:
http://www.b4x.com/android/forum/threads/googlemapsextras.26277/page-4#post-204919.

Some examples of the syntax required to use the new objects and methods can be found here:
http://www.b4x.com/android/forum/threads/googlemapsextras.26277/page-5#post-204957, though i'm too busy right now to put together a proper working example.

Version 1.60 of GoogleMapsExtras is attached to the first post in this thread.
As always - ensure you have the latest version of the Google Play Services to use the latest features in GoogleMapsExtras.

Martin.
 

M6SOFT

Member
Licensed User
Longtime User
I'm thinking about connecting WMS to google maps. First idea is to use URLTileProvider but WMS address look like:
B4X:
... WMSServer?VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&LAYERS=Raster&SRS=EPSG:4326&BBOX=18.840965697,50.431481569,18.843600627,50.432944172&WIDTH=256&HEIGHT=256
BBOX is the tile bounds. I can calculate it from tile x,y,z but how to pass link?
Is it possible expose getTileUrl to B4A?
Maybe better way is GroundOverlay? What You think?
 

warwound

Expert
Licensed User
Longtime User
Can you test the attached update?
I have created a new object CustomUrlTileProvider:

CustomUrlTileProvider
Events:

  • GetTileUrl (TileX As Int, TileY As Int, Zoom As Int) As String
Methods:
  • Initialize (EventName As String, Width As Int, Height As Int)
    Initialize the CustomUrlTileProvider.
    Width - width of the images used for tiles.
    Height - height of the images used for tiles.
    The CustomUrlTileProvider raises the event:
    GetTileUrl(TileX As Int, TileY As Int, Zoom As Int) As String
  • IsInitialized As Boolean

So you handle the event: GetTileUrl(TileX As Int, TileY As Int, Zoom As Int) As String returning a valid URL to a tile.

The only possible problem could that be that:

Calls to methods in this interface might be made from multiple threads so implementations of this interface must be threadsafe.
https://developers.google.com/maps/...om/google/android/gms/maps/model/TileProvider

We had this problem before with the CustomTileProvider and the solution was to use Reflection to call a b4a sub and get a value instead of raising an event.
If you can give this update a thorough test and report any problems, i can rewrite it to use Reflection if there are threading problems.
Also note that because of the possible calls from non UI threads you should not update your app's UI from within the GetTileUrl event handling sub.

Martin.
 

M6SOFT

Member
Licensed User
Longtime User
Thank You a lot. You are great person in this B4A family. After first tests it seems that all work as expected. I will still test and inform in this thread
 

rboeck

Well-Known Member
Licensed User
Longtime User
Hi Martin,

i saw an older note about SetPadding and tried to use it for the first time. I wanted to reduze the full screen map to an active part of 85%x of the map.

In the logs you find the following:
B4X:
GoogleMapsExtras1.SetPadding(GoogleMap1,1,1,1,25)
java.lang.NoSuchMethodError: com.google.android.gms.maps.GoogleMap.setPadding

If write the code, i get all the information about SetPadding - the information about thie method is here. I tried it with ver 1.60 and the pre version from last saturday.

Thanks
Reinhard
 

warwound

Expert
Licensed User
Longtime User
I'd guess that your version of the Google Play Services library is not up to date.

Run your Android SDK Manager and ensure you have the latest version - and also be sure that once the latest version has been downloaded to the Android SDK folder that you copy the latest version to your b4a additional libraries folder.

Martin.
 

rboeck

Well-Known Member
Licensed User
Longtime User
Hi martin,

there were 4 updates possible; till now i had no problem with the play services, i never changed the manifest in that way you descripted, because everything worked without it.
Till today, where i wanted to try out the setpadding feature.

As i looked at my code i found following in Activity_Create:

B4X:
' Padding removal of the jog_tab_bar drawable
  Dim R As Reflector
  R.Target = PanelWithSidebar.Sidebar
  R.RunMethod4("setPadding", Array As Object(0, 0, 0, 0), Array As String("java.lang.int", "java.lang.int", "java.lang.int", "java.lang.int"))

I can imagine, that the use of the method has same side effect.
But i dont really need the setpadding method now; now i will try your new work for B4J..

Thanks
Reinhard
 

BvdB

Member
Licensed User
Longtime User
Hi Greg.

I was reading through some docs about SpatiaLite and found that it actually contains a version of the proj4 library.
You should find it very useful!

I'll start a private conversation with you - i'd rather not post links to either SpatiaLite or mapsforge libraries on the forum.

Martin.

Hi Martin and Marco (M&M for short ;) )
I am very interested in the work that you are busy with especially Spatialite library. I have not read further down the thread, so the answers may appear in a later post, if that be the case, then just reply in short.

Martin, where/how can I get access to the B4A Spatialite library that you mentioned? This will make my life much easier with a project that I currently developing.

Kind regards
Ben
 

warwound

Expert
Licensed User
Longtime User
GoogleMapsExtras updated to version 1.70

This update makes GoogleMapsExtras compatible with the new #AdditionalRes project attribute introduced in version 3.20 of Basic4Android.
  • If you are using a version of Basic4Android older than version 3.20 then you will not be able to use the #AdditionalRes project attribute.
    You will not be able to compile a project that correctly contains all of the required android resources that the GoogleMaps and GoogleMapsExtras libraries require and you will not be able to use version 1.70 and subsequent versions of GoogleMapsExtras.
    Version 1.61 of GoogleMapsExtras will be the last version that you are able to use.
  • If you are using version 3.20+ of Basic4Android then:
    • You should compile your project using the updated instructions in the GoogleMaps tutorial thread.
      Be sure to use the new #AdditionalRes project attribute.
    • You can now use or continue to use GoogleMapsExtras version 1.70+.

I hope that makes sense?

Version 1.70 of GoogleMapsExtras is attached to the first post in this thread.

Martin.
 

marcick

Well-Known Member
Licensed User
Longtime User
Hi Martin, something is not working correctly to me:
I have a project done with the previous version of b4a that use googlemapextras library.
I have now updated to b4a 3.2, updated the googlemapextras library 1.7, done the modification described in the GoogleMap tutorial and added the #AdditionalRes attribute to main activity.
Compiling, I get the error below.
What's wrong ?

p.s. if I start a blank project and try the sample in GoogleMap tutorial it compiles ok.

Marco


B4X:
Parsing code.                          0.10
Compiling code.                        0.20
   
ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code.                0.02
Generating R file.                      Error
res\values\ahqa_styles.xml:3: error: Resource does not already exist in overlay at 'Animations'; use <add-resource> to add.
res\values\ahqa_styles.xml:6: error: Resource does not already exist in overlay at 'Animations.PopDownMenu'; use <add-resource> to add.
res\values\ahqa_styles.xml:8: error: Resource does not already exist in overlay at 'Animations.PopDownMenu.Left'; use <add-resource> to add.
res\values\ahqa_styles.xml:9: error: Resource at Animations.PopDownMenu.Left appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahqa_styles.xml:10: error: Resource at Animations.PopDownMenu.Left appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahqa_styles.xml:13: error: Resource does not already exist in overlay at 'Animations.PopDownMenu.Right'; use <add-resource> to add.
res\values\ahqa_styles.xml:14: error: Resource at Animations.PopDownMenu.Right appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahqa_styles.xml:15: error: Resource at Animations.PopDownMenu.Right appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahqa_styles.xml:18: error: Resource does not already exist in overlay at 'Animations.PopDownMenu.Center'; use <add-resource> to add.
res\values\ahqa_styles.xml:19: error: Resource at Animations.PopDownMenu.Center appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahqa_styles.xml:20: error: Resource at Animations.PopDownMenu.Center appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahqa_styles.xml:23: error: Resource does not already exist in overlay at 'Animations.PopDownMenu.Reflect'; use <add-resource> to add.
res\values\ahqa_styles.xml:24: error: Resource at Animations.PopDownMenu.Reflect appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahqa_styles.xml:25: error: Resource at Animations.PopDownMenu.Reflect appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahqa_styles.xml:29: error: Resource does not already exist in overlay at 'Animations.PopUpMenu'; use <add-resource> to add.
res\values\ahqa_styles.xml:31: error: Resource does not already exist in overlay at 'Animations.PopUpMenu.Left'; use <add-resource> to add.
res\values\ahqa_styles.xml:32: error: Resource at Animations.PopUpMenu.Left appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahqa_styles.xml:33: error: Resource at Animations.PopUpMenu.Left appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahqa_styles.xml:36: error: Resource does not already exist in overlay at 'Animations.PopUpMenu.Right'; use <add-resource> to add.
res\values\ahqa_styles.xml:37: error: Resource at Animations.PopUpMenu.Right appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahqa_styles.xml:38: error: Resource at Animations.PopUpMenu.Right appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahqa_styles.xml:41: error: Resource does not already exist in overlay at 'Animations.PopUpMenu.Center'; use <add-resource> to add.
res\values\ahqa_styles.xml:42: error: Resource at Animations.PopUpMenu.Center appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahqa_styles.xml:43: error: Resource at Animations.PopUpMenu.Center appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahqa_styles.xml:46: error: Resource does not already exist in overlay at 'Animations.PopUpMenu.Reflect'; use <add-resource> to add.
res\values\ahqa_styles.xml:47: error: Resource at Animations.PopUpMenu.Reflect appears in overlay but not in the base package; use <add-resource> to add.
res\values\ahqa_styles.xml:48: error: Resource at Animations.PopUpMenu.Reflect appears in overlay but not in the base package; use <add-resource> to add.
 

warwound

Expert
Licensed User
Longtime User
Hi Marco.

Those errors look like they are related to the AHQuickAction library not GoogleMaps or GoogleMapsExtras.
Did you remove the GoogleMaps resources from this project and at the same time also remove the AHQuickAction resources referenced by those errors?

Martin.
 

marcick

Well-Known Member
Licensed User
Longtime User
Uhm, I don't understand what to do.
I didn't do any change to the project, just updated to b4a 3.2 and GoogleMapsExtras 1.7.
I have installed now the 1.02 update of AHQUickAction lib but the result is the same
Marco
 

warwound

Expert
Licensed User
Longtime User
Did the 1.02 update of AHQuickAction require any changes to be made to the project's resources if you were already using a previous version of AHQuickAction?
If you revert to the previous version of AHQuickAction does the project now compile?

Martin.
 

marcick

Well-Known Member
Licensed User
Longtime User
It seems not. I just tried the 1.02 update (and copied again the required res folder, checking the read-only property) to see if it was the problem, but I had the compilation error also with 1.01.
Marco
 
Top