Android Question Change googlemap camera position

devmobile

Active Member
Licensed User
Hey,
Suppose that googlemap camera position is 39.938048, 32.860946
and I add marker on refer location
Now i need to change camera position to below marker
How is it possible?
 

devmobile

Active Member
Licensed User
Start with reading the documentation
"AnimateCamera" and "MoveCamera"
No No my means is another
I need to change camera position according to marker position
Example when i add marker on map,auto change camera position to below marker
I increase latlng and change camera to new latlng but it is not correct
 
Upvote 0

Ohanian

Active Member
Licensed User
Longtime User
Hi,

I'm not sure what you're asking for but it seems you need something like this :

B4X:
Dim Projection As Projection
Dim Point1 As Point
Dim LatLng1 As LatLng
       
LatLng1.Initialize(GoogleMap1.CameraPosition.Target.Latitude, GoogleMap1.CameraPosition.Target.Longitude)
       
Projection = GoogleMapsExtras1.GetProjection(GoogleMap1)
Point1 = Projection.ToScreenLocation(LatLng1)
Point1.Set(Point1.X, Point1.Y + 35dip)

LatLng1 = Projection.FromScreenLocation(Point1)
   
Dim CameraPosition1 As CameraPosition
CameraPosition1.Initialize(LatLng1.Latitude, LatLng1.Longitude, GoogleMap1.CameraPosition.Zoom)
       
GoogleMap1.MoveCamera(CameraPosition1)
 
Upvote 0

devmobile

Active Member
Licensed User
Yes your sample code is correct
In below line you change camera position with add 35dip
I will try it thanks
B4X:
Projection = GoogleMapsExtras1.GetProjection(GoogleMap1)
Point1 = Projection.ToScreenLocation(LatLng1)
Point1.Set(Point1.X, Point1.Y + 35dip)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…