Android Question Adding draggable Markers to a map

Discussion in 'Android Questions' started by Roger Daley, May 5, 2015.

  1. Roger Daley

    Roger Daley Well-Known Member Licensed User

    Hi All,

    I am trying to come to grips with Markers Etc. Currently I have a MapViewer stripped out of Klaus's GPSExample [I started with "GPSExample" then realized my final objective will have no need of GPS]
    I have come to the stage where I need to add two draggable makers to the map in ActivityCreate. They will always be present. They each have an individual icon to distinguish them.

    I have read and re-read everything I can find on the forum, Wiki, Warwounds DraggableMarker example etc. Lots of info and examples re: Webview, WebviewExtras, OSMDroid Etc. However I find that with each that I have walked in to the middle of a conversation and have missed the point.

    Can anyone provide the explanation for the "Totally Ignorant" as to how to add two markers [individual icons] to a map created in Webview.

    Thanks in advance
    Regards Roger
  2. eurojam

    eurojam Well-Known Member Licensed User

    DonManfred likes this.
  3. Roger Daley

    Roger Daley Well-Known Member Licensed User


    Thanks for the reply, unfortunately the two links above are among those I have been reading and not following.
    I will keep trying and hope that the brains cells finally cllick.

    Regards Roger
  4. Erel

    Erel Administrator Staff Member Licensed User

    Why aren't you using Google Maps SDK?
  5. Roger Daley

    Roger Daley Well-Known Member Licensed User


    Answer in two parts.

    1. Because Kauls didn't use it as the map viewer in his GPSExample which is where I started.
    2. Probably because I don't know what I am doing.

    Are you suggesting I should dump what I have and start afresh with Google Maps SDK? If so, can you please suggest a starting point.

    Regards Roger
  6. Erel

    Erel Administrator Staff Member Licensed User

    Roger Daley likes this.
  7. Roger Daley

    Roger Daley Well-Known Member Licensed User

    Thanks Erel,

    I've had a quick look and this should keep me occupied for some extended time, but a definite path to follow.
    Looking back I think I had been confused with different paths in the evolution of map viewing.

    Regards Roger
  8. eurojam

    eurojam Well-Known Member Licensed User

    Roger, here is a small example with a google map and one Marker which you can drag. Please follow the instructions how to setup the google Map lib (

    #Region  Project Attributes
    #ApplicationLabel: GoogleMapDemo
    #VersionCode: 1
    'SupportedOrientations possible values: unspecified, landscape or portrait.
        #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
    #End Region

    #Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
    #End Region

    #AdditionalRes: C:\Programme\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib\res,
    Sub Process_Globals
    Dim GoogleMapsExtras1 As GoogleMapsExtras
    End Sub

    Sub Globals
    Dim mFragment As MapFragment
    Dim gmap As GoogleMap

    Dim MapPanel As Panel
    Dim cp As CameraPosition

    'Dim GoogleMapsExtras1 As GoogleMapsExtras
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
    Activity.AddView(MapPanel, 00100%x100%y)
    If mFragment.IsGooglePlayServicesAvailable = False Then
    ToastMessageShow("Google Play services not available."True)
    "Map", MapPanel)
    End If
    End Sub
    Sub Map_Ready
    Log("map ready")
       gmap = mFragment.GetMap
    If gmap.IsInitialized = False Then
    ToastMessageShow("Error initializing map."True)
    Dim MarkerOptions1 As MarkerOptions

    Dim tmpMarker As Marker
            tmpMarker=GoogleMapsExtras1.AddMarker(gmap, MarkerOptions1)
    Dim markerDragListener As OnMarkerDragListener

    Dim cp As CameraPosition
    6418, gmap.CameraPosition.Zoom)
    End If
    End Sub
    Sub markerDragListener_Drag(Marker1 As Marker)
    End Sub

    Sub markerDragListener_DragEnd(Marker1 As Marker)

    End Sub

    Sub markerDragListener_DragStart(Marker1 As Marker)
    End Sub
    Hope this helps
    DonManfred and Roger Daley like this.
  9. Roger Daley

    Roger Daley Well-Known Member Licensed User


    Thanks again. This should be a great help to get started, this is much appreciated.

    Regards Roger
  10. klaus

    klaus Expert Licensed User

    Hi Roger,
    When I wrote the GPSExample I used a WebView because the GoogleMaps library didn't exist at that time.
    Roger Daley likes this.
  11. Roger Daley

    Roger Daley Well-Known Member Licensed User

    No worries Klaus,

    I've slowly caught on that the many things that I found on the forum were different stages of evolution.
    Going through your GPS example has been a great learning experience for me. Several things have been noted for use in the future.

    Thanks for your help.

    Regards Roger
  12. Roger Daley

    Roger Daley Well-Known Member Licensed User

    Hi All

    Back again. I've tried using the code kindly posted by Stefan [Post#8]

    Re-Installed SDK
    Installed Google Play Services
    Followed the "Google Maps Android v2 tutorial"
    Followed the "Google Play Services - Installation & Tips"
    Copied files to different locations
    Stumbled through the manifest editor
    Created API key

    Etc. [It takes a group like the Google Team of computer guru's to make something this convoluted]

    The result is, when I try to run the code [Release or Debug] I get "Google Play services not available". No clues as to why.
    Obviously I have missed something, done something wrong.
    I have uploaded the project zip in desparation, if someone can tell me where I have gone wrong I would be most grateful otherwise I will forget about Google Maps.

    Regards Roger

    Attached Files:

  13. Erel

    Erel Administrator Staff Member Licensed User

    That's correct. However once you try to implement in app purchases or push notifications in iOS then you see that it can be worse ;)

    Can you post the message from the logs?

    Are you testing it on a real device? It will not work on an emulator.
  14. eurojam

    eurojam Well-Known Member Licensed User

    Hi Roger,
    I have tried your project with my sign key / package name and it worked. I've changed the additional res to:
    'that was your Res
    '#AdditionalRes: C:\Program Files\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib\res
    'but it should be like this
    #AdditionalRes: C:\Programme Files\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib\res,
    then you have to do the following things:
    register your app with the sha1 key produced from your keyfile at:
    this should be a line like this(sha1;package name):
    finally run your app (debug mode or release mode) with your registered sign key

    Roger Daley likes this.
  15. Roger Daley

    Roger Daley Well-Known Member Licensed User


    Thanks for you help.
    Erel has hit part of the problem. I was using an emulator, when I use a real device the program loads but with a white screen, no map, nothing in the log.
    I think this has something to do with Google Maps API not being enabled in the developer console. I will research this tomorrow, it has been a long day and is time to move away from the keyboard.

    Thanks again
  16. Erel

    Erel Administrator Staff Member Licensed User

    eurojam likes this.
  17. Roger Daley

    Roger Daley Well-Known Member Licensed User

    Thanks Erel,

    This is much appreciated. The good news is that I managed to get the Demo working earlier today. That is after fixing a couple of my errors and being confused by Googles
    ambiguous reference to "enable the API" following "Create an API" when they meant "enable the Google Maps API".

    Now that I have a base on which to work I'll start to tinker with the demo code in between my domestic duties. :(
    Stand by for the next question, probably in a new thread.

    Regards Roger
    eurojam likes this.
  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