Android Question GoogleMaps - move the map not the marker ?

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:

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:
B4X:
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
 

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.
 

achtrade

Active Member
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.
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
 

eurojam

Well-Known Member
Licensed User
I would say it is the cameraposition like in my previous post:
B4X:
Sub mFragment_CameraChange (Position As CameraPosition)
  'set the new position to your marker
End Sub
 

warwound

Expert
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
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.
 

achtrade

Active Member
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.
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.
 

Attachments

Last edited:
Top