Android Tutorial (old) Google Maps Android v2 tutorial

Discussion in 'Tutorials & Examples' started by Erel, Dec 18, 2012.

Thread Status:
Not open for further replies.
  1. imbault

    imbault Well-Known Member Licensed User

    after download your library, and trying your sample, I got :

    Compiling generated Java code. Error
    B4A line: 30
    javac 1.7.0_09
    src\b4a\example\ error: package does not exist
  2. Erel

    Erel Administrator Staff Member Licensed User

    Are you sure that you copied the native library to the libraries folder?
  3. imbault

    imbault Well-Known Member Licensed User

    sure, google-play-services.jar is here
  4. Erel

    Erel Administrator Staff Member Licensed User

    Make sure that you reference android.jar from platform level 14 or above (Tools - Configure paths).

    If it still doesn't compile then delete google-play-services.jar and see whether you get a different error message.
  5. JTmartins

    JTmartins Active Member Licensed User

    Find the key signature

    Hi guys,

    How can I find the key signature ?

    As step "3. Find the key signature", does not work here as it is described in first post.

    Created the signature. have the key file created.

    Go again to Tools -> Private sign key

    but nothing is displayed..fields come up as

    Name : unknown
    Organization Unknown
    country : Unknown
    password : (yes, here I can see the one I've used)

    I browse for the key file..but nothing else is displayed.

    V 2.02 here

  6. Erel

    Erel Administrator Staff Member Licensed User

    The signature info feature was added in v2.50. You can use Java KeyTool to extract the same information. However this library depends on v2.50. It will not work properly with previous versions.
  7. icefairy333

    icefairy333 Active Member Licensed User

    I had encounter this too
  8. RichardHirst

    RichardHirst Member Licensed User


    Hi Erel.

    Would it be possible to add TileOverlay to this libraary at some stage. Need to add a fire line scan image at a Lat/Lon.

    Thanks and great work

  9. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this request in the Wishlist forum.
  10. msawada

    msawada Member Licensed User

    White screen problem with tutorial example

    Great addition to B4A, I've been wanting it for a long time. I've tried a few times and can only achieve a white screen. I've generated private keys (tried two different) from Google API with the SHA1 private sign key from B4a and the ";" which is my package name from Tools->Package Name in B4a. I've added these to the manifest editor using the code from Erel's tutorial. I've put the google jar and play jar files into the library folder and see the googlemaps library and it is loaded for the tutorial code. I have google maps on my devices. When I install and run the tutorial code I only get the zoom buttons and a white screen. Erel mentions that the white screen problem may be due to issue with some in-congruence of the package name SHA1 key or google key. However, I think mine are consistent unless I have the package name wrong and I am supposed to use a package name other than the one from tools->Package name. Any thoughts?
  11. Erel

    Erel Administrator Staff Member Licensed User

    Try the attached APK. Does it work on your device?

    Attached Files:

  12. msawada

    msawada Member Licensed User

    Yes it works great Erel. Any idea what I am doing wrong? It must be an issue with my package name. Am I using the correct package name when I request my API key? I named my package using Tools->Package name in the menu and then used that name in the API Gmap 2.0 request.
  13. Erel

    Erel Administrator Staff Member Licensed User

    If it works then your program should also (eventually) work :)

    Yes. Project - Package name is the correct place.

    Make sure that you checked the correct service in Google API Console.
  14. msawada

    msawada Member Licensed User

    Thanks Erel and sorry. I have it working! It was my fault. I had chosen to active the Google Maps API v2 key rather than what you specifically said which is Google Maps Android API v2 - which makes complete sense. Again, thanks and my apologies.
  15. wes58

    wes58 Active Member Licensed User

    Hi Erel,
    I have been playing with the new map object and have a few questions:
    - How can the zoom level be changed (after initial initialization)?
    - How can the boundaries be set?
    In the google documentation (HTTP:// there are methods CameraUpdateFactory that allow to change this and other map parameters. But how can we do it in B4A?
  16. Erel

    Erel Administrator Staff Member Licensed User

    Dim cp As CameraPosition
    Dim LL As LatLng = map.CameraPosition.Target
    cp.Initialize(LL.Latitude, LL.Longitude, NewZoom)
    2. You can use Reflection to set the zoom and position based on the boundaries:
    Sub Map_Ready
    Log("map ready")
        gmap = mFragment.GetMap
    If gmap.IsInitialized = False Then
    ToastMessageShow("Error initializing map."True)
    Dim cp As CameraPosition
    3615, gmap.CameraPosition.Zoom)
    End If
    End Sub

    Sub SetZoom
    Dim sw, ne As LatLng
       ZoomToBoundaries(gmap, sw, ne, 
    End Sub

    'SouthWest -> NorthEast - the visible box
    'Padding - Padding from the map edges
    Sub ZoomToBoundaries (gm As GoogleMap, SouthWest As LatLng, NorthEast As LatLng, Padding As Int)
    Dim r As Reflector
       r.Target = r.CreateObject2(
    ""Array As Object(SouthWest, NorthEast), _
    Array As String(""""))
    Dim cameraUpdate As Object = r.RunStaticMethod("""newLatLngBounds", _
    Array As Object(r.Target, Padding), Array As String(""""))
       r.Target = gm
    "moveCamera"Array As Object(cameraUpdate), Array As String(""))
    End Sub
    Note that I use CallSubDelayed as the map size is still 0 in the Ready event and this causes the zoom method to fail (see this link for more information:, int))

    3. Most or all of the factory features are already available with CameraPosition.
  17. wes58

    wes58 Active Member Licensed User

  18. RichardHirst

    RichardHirst Member Licensed User



    Would you have a quick example to add a Polyline to the Map. Can not make it visible..?


  19. Erel

    Erel Administrator Staff Member Licensed User

    Dim pl As Polyline = gmap.AddPolyline
    Dim l1, l2 As LatLng
    Dim points As List
          pl.points = points
    Mashiane likes this.
  20. wes58

    wes58 Active Member Licensed User

    In my application I want to show the map when the user presses the button. When the map is not needed the user presses the button again and the map should be removed. The only way I can remove (or really only hide) the map is to make the panel the map is on not visible. But this way the map is still active and is using GPS and data.

    Is there any way to remove (destroy) the map object when not needed?
Thread Status:
Not open for further replies.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice