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,693
  • MapsForgeTileProvider_v1.01.zip
    173.1 KB · Views: 2,567
  • GoogleMapsExtras_v2_0_library_files.zip
    82.5 KB · Views: 2,991
Last edited:

iCAB

Well-Known Member
Licensed User
Longtime User
Sorry I was't clear in my first post. Here are the declarations
B4X:
Sub Globals
    Dim MapFragment1 As MapFragment
    Dim GoogleMap1 As GoogleMap
    Dim GoogleMapsExtras1 As GoogleMapsExtras
    Dim MapPanel As Panel
End Sub
 

Nostrildumbass

Member
Licensed User
Longtime User
Try this as a quick test:

B4X:
Dim Marker1 As Marker = gmap.AddMarker(Lat, Lng, "Title")

I've been working on an app and have had my markers working very well for some time now. I used the above method using gmap.AddMarker (instead of yours where you are using GoogleMapsExtras1.AddMarker) to add markers to my map.

I only have 2 uses of "GoogleMapsExtras1," they are:

B4X:
Dim GoogleMapsExtras1 As GoogleMapsExtras
GoogleMapsExtras1.SetInfoWindowAdapter(gmap, InfoWindowAdapter1)

The second line is to have InfoWindows for my markers, so you wouldn't use that if you don't want it.
 

iCAB

Well-Known Member
Licensed User
Longtime User
Hi Stealth
Thanks for your reply. if you look closely at my first post, you can see that I commented out this code
B4X:
'      MyMarker = gmap.AddMarker(43.6953, -79.6152, "Hello!!!")
'      Dim cp As CameraPosition
'      cp.Initialize(36, 15, gmap.CameraPosition.Zoom)
'      gmap.AnimateCamera(cp)
'

Yes, you are absolutely right. This code works no problem, I was just trying to explore the feature of GoogleMapExtras and that's when I faced the issue.
 

ivan.tellez

Active Member
Licensed User
Longtime User
Hi martin,

Is there any changes on the ground overlay?


I try to use with a picture and coordinates on my own, but is not working right, the area is ok, but the image is not drawn complete.

So I downloaded your sample, but with the same results.


The image is not complete. Tested on a S4 with KitKat and other with Lollipop



EDIT: SOLVED

Well, the solution is to use a picture with power of two dimentions. (128, 256, 512, 1024...)
 

Attachments

  • test.png
    test.png
    65.9 KB · Views: 260
Last edited:

DarkAngel

Member
Licensed User
Longtime User
Hi, I've been using this library but to remove circles or markers I have to do "GoogleMap.Clear".
Is there a better way to remove just one Marker or one Circle?
I'm adding markers like this: "GoogleMapExtras.AddMarker(GoogleMap, MarkerOptions)"
I tried to use "GoogleMapExtras.AddMarker(GoogleMap, MarkerOptions).Remove" but doesn't work...the same for the circles.
Using my method causes some blinking to the markers on the map. And since I'm using user location real time positioning I have to refresh the map every second and I don't need to clear all the markers, only the user's marker.

Any one can help?

Thank's in advance.
 

warwound

Expert
Licensed User
Longtime User
Both Circle and Marker have a Remove method that removes the object from the map.
You need to keep a reference to the Circle or Marker when it is created and then use that reference when you later want to call the Remove method.

B4X:
MyMarker=GoogleMapExtras.AddMarker(GoogleMap, MarkerOptions)

' elsewhere in your code
MyMarker.Remove

If you don't keep a reference to the object when you create it you cannot later call it's Remove method.
 

DarkAngel

Member
Licensed User
Longtime User
Thanks a lot warwound, works like a charm.

Is it possible to add multiple markers, from a list, at once to the map?
I'm adding one by one.
Since clearing the marks all at once is possible adding would be great.

Thank you for the support.
 

Croïd

Active Member
Licensed User
Longtime User
GoogleMapsExtras updated to version 2.0

This library update contains 2 new objects:
  • CustomLocationSource
    Events:
    • Activate (OnLocationChangedListener1 As OnLocationChangedListener)
    • Deactivate
.


Please Warwound, how is it possible to announce the deactivation with toast ?

This not work and suspendedcause.cause_service_disconnected, suspendedcause.cause_network_lost, too

B4X:
Sub CustomLocationSource1_Deactivate
    Log("CustomLocationSource1_Deactivate")
    '    stop listening for location updates
    FusedLocationProvider1.Disconnect
    ToastMessageShow("MyCustomLocationSource1 is disabled" , False)
End Sub
 

warwound

Expert
Licensed User
Longtime User
Thanks a lot warwound, works like a charm.

Is it possible to add multiple markers, from a list, at once to the map?
I'm adding one by one.
Since clearing the marks all at once is possible adding would be great.

Thank you for the support.

You already know about the GoogleMap Clear method - that is your only alternative.
Either remove map overlays individually or remove all types of overlays at once.
 

warwound

Expert
Licensed User
Longtime User
Please Warwound, how is it possible to announce the deactivation with toast ?

This not work and suspendedcause.cause_service_disconnected, suspendedcause.cause_network_lost, too

B4X:
Sub CustomLocationSource1_Deactivate
    Log("CustomLocationSource1_Deactivate")
    '    stop listening for location updates
    FusedLocationProvider1.Disconnect
    ToastMessageShow("MyCustomLocationSource1 is disabled" , False)
End Sub

Are you saying that your toast message does not display?
Instead the call to FusedLocationProvider causes a crash?

SetLocationSource (GoogleMap1 As GoogleMap, LocationSource1 As LocationSource)
Replaces the default location source of the MyLocation layer.
Pass Null to restore the default location source.


Try calling SetLocationSource(Null) before deactivating the CustomLocationSource.
 

Croïd

Active Member
Licensed User
Longtime User
No sorry, but I have a problem with declaration (..... As LocationSource)
 

Spectre

Active Member
Licensed User
Longtime User
Hi warwound and so long that you do not feel ... (OSMDroid4.1)

you can tell when I'm away from a track created with the Google API?

B4X:
Request="http://maps.googleapis.com/maps/api/directions/json?origin=" & STARTING_POINT_LAT &"," & STARTING_POINT_LON _
            & "&destination=" & END_POINT_LAT & "," & END_POINT_LON & "&sensor=false" _
                & "&mode=" & Value

I wanted to put on track a market but I would only do that if you are not too far from the track that I'm following.
 

warwound

Expert
Licensed User
Longtime User
Hi,

THanks for the tips warwaound,

Have another question, that was posted sometime ago but still have no solution:

Is it possible to have this effect on a marker? (Sliding effect)
Sliding a marker from a position to another.

An example can be seen here:
http://terikon.github.io/marker-animate-unobtrusive/demo/unobtrusive/markermove-sliding.html

No there's no way to animate a change in a marker's location.
The link you posted shows how it can be done with the javascript based Google Maps API - the javascript based Google Maps API is far more feature packed than the android Google Maps library.
 

warwound

Expert
Licensed User
Longtime User
Hi warwound and so long that you do not feel ... (OSMDroid4.1)

you can tell when I'm away from a track created with the Google API?

B4X:
Request="http://maps.googleapis.com/maps/api/directions/json?origin=" & STARTING_POINT_LAT &"," & STARTING_POINT_LON _
            & "&destination=" & END_POINT_LAT & "," & END_POINT_LON & "&sensor=false" _
                & "&mode=" & Value

I wanted to put on track a market but I would only do that if you are not too far from the track that I'm following.

Does this distance need to be 'road distance' or could it be 'as the crow flies' distance?
If 'as the crow flies' distance is acceptable then you could simply use the Location object's DistanceTo method to get the distance instead of performing a query to a web service.
You'd need to initialize a Location object for both start point and end point.
 
Top