Android Question GoogleMaps - move the map not the marker ?

Discussion in 'Android Questions' started by achtrade, May 15, 2015.

  1. achtrade

    achtrade Active Member Licensed User

    How to leave a frozen marker right in the center of the map ? Just like the uber app, the user move the map but the marker stays in the middle of the map
     
    Last edited: Sep 9, 2015
  2. eurojam

    eurojam Well-Known Member Licensed User

    I think you can use the cameraChange Event and set the new position to the marker whenever the position will change and the marker will stay in the center:
    Code:
    Sub mFragment_CameraChange (Position As CameraPosition)
      
    'set the new position to your marker
    End Sub
    I haven't tried this, but that would be my first idea to do this....
    stefan
     
  3. warwound

    warwound Expert Licensed User

    I've seen this asked before on the forum and the simplest solution is to display your Marker's icon in an ImageView with the ImageView positioned over your MapView's center.

    You could instead have a Marker position at the MapView's center and whenever the MapView's position changes, reposition the Marker to the new MapView center.
    But you'll see the Marker move with the map and then reposition itself.

    With the ImageView solution you'll get exactly what you want.
     
    thedesolatesoul and eurojam like this.
  4. achtrade

    achtrade Active Member Licensed User

    How to get the lon & lat of the center of the MapView ?

    Thanks.

    ps: I just realized that now it's a native feature of GoogleMap, I hope one day we can have it in b4a
     
  5. eurojam

    eurojam Well-Known Member Licensed User

    I would say it is the cameraposition like in my previous post:
    Code:
    Sub mFragment_CameraChange (Position As CameraPosition)
      
    'set the new position to your marker
    End Sub
     
  6. warwound

    warwound Expert Licensed User

    You need to position the ImageView at the (x, y) center of the GoogleMap / MapFragment.
    Ie you need pixel values not latitude and longitude values.
     
    Matias Ferrer likes this.
  7. achtrade

    achtrade Active Member Licensed User

    My problem is not to put the imageview in the center, my problem is get the lat y lon of the imageview after the map is moved. See the pic.

    Also watch this video in 1:50, you can see the green pin stationary even tough the map is moving in the background, after that, the new location is found.
     

    Attached Files:

    Last edited: May 18, 2015
  8. warwound

    warwound Expert Licensed User

    @archtrade

    Have you tried the code in post #5 from @eurojam?
     
    ihabsharaf likes this.
Loading...
  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