Android Question Google Maps Zoomimg

brodmuehler

Member
Licensed User
Longtime User
Hi

I would appreciate some help with google maps zooming. I attached a little graphic that should show what I am wanting to do.

I have a track on a google map. Now I want to zoom into the map, so that I only see the track with a bit of margin around the box that includes the track. I know all the Lat/Lon combination from the track.

My question is now which function can I use to zoom into the googlemap so that the map is magnified and I only see the part of the map where the track is.

Any help is highly appreciated.
Thanks a lot in advance.
Kind regards
René
 

Attachments

  • gmapZoom.png
    gmapZoom.png
    8.8 KB · Views: 270

rboeck

Well-Known Member
Licensed User
Longtime User
Look for GoogleMapsExtras and the method AnimateToBounds - its exactly what you need: you look for the outer bounds and animatetoBounds make the rest.
 
Upvote 0

brodmuehler

Member
Licensed User
Longtime User
Great. Thanks a lot. I will have a look.
Hi.

Found the library and and added it. So far so good. By any chance, do you have some sample code for me so that I can see how the syntax works. I am not that experienced that it is fully intuitive.

Thanks again
Rene
 
Upvote 0

rboeck

Well-Known Member
Licensed User
Longtime User
B4X:
Dim LatLngBoundsBuilder1 As LatLngBoundsBuilder
    LatLngBoundsBuilder1.Initialize

'here you include all your postition information to this object:

'here a loop for all of your points
dim Dim Point As LatLng
Point.Initialize(37.772323, -122.214897)

LatLngBoundsBuilder1.Include(Point)
'end loop

Dim llBounds As LatLngBounds
llBounds = LatLngBoundsBuilder1.Build

GoogleMapsExtras1.AnimateToBounds2(GoogleMap1,llBounds,1920,1000,190)
 
Upvote 0

brodmuehler

Member
Licensed User
Longtime User
B4X:
Dim LatLngBoundsBuilder1 As LatLngBoundsBuilder
    LatLngBoundsBuilder1.Initialize

'here you include all your postition information to this object:

'here a loop for all of your points
dim Dim Point As LatLng
Point.Initialize(37.772323, -122.214897)

LatLngBoundsBuilder1.Include(Point)
'end loop

Dim llBounds As LatLngBounds
llBounds = LatLngBoundsBuilder1.Build

GoogleMapsExtras1.AnimateToBounds2(GoogleMap1,llBounds,1920,1000,190)
Hi
Great. Thanks a lot.

How many points does the function need to work properly. Do you think 4 points are enough in order to describe the corners of the rectangle with the track inside.

What means the 1920,1000,190 in the AnimateToBounds2 function?

Thanks
Rene
 
Upvote 0

brodmuehler

Member
Licensed User
Longtime User
Did you have a look in the GoogleMapsExtras documentation (Tooltip)?
Hi
Not sure what you mean. I searched for it yesterday but didn't find any good examples. And sometimes I really struggle to understand the examples or language used for explanation. As I mentioned before. I am not an expert. Just someone who likes creating little tools mainly for myself. The stuff here is great and the work behind all of this is absolutely unbelievable. We done to all of you. It allows even people like me to come up with nice apps.

I will have another look for the documentation. Best wishes Rene
 
Upvote 0

rboeck

Well-Known Member
Licensed User
Longtime User
Just type: GoogleMapsExtras1.AnimateToBounds2( and you should get:

Animate.png


Here you see all parameters.
I have also learned everthing by myself, my studied job is farmer. But i work with computers since 1982....
 
Upvote 0
Top