Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google maps api v2 zooming near the marker

Tags:

I am using Google maps api v2 in android. I have placed a marker by using latitude and longitude . The marker is shown at correct place , but i want the the map should show area around the marker only .i.e i want to zoom to markers position when the map is shown so it shows nearby region of the marker only..any help would be great.

like image 617
Ravi Avatar asked May 09 '13 09:05

Ravi


People also ask

How do I fix zoom on Google Maps?

To fix Google maps zooming problems, for Google maps default zoom you want to know how to change the zoom level on Google Maps. You can change the zoom level by going to the Edit map page and then selecting 'default zoom level' in the map information section and then clicking save map.

Why does Google Maps keep zooming in?

The app does this because you're not in navigation mode, you're browsing the route. It zooms out to fit the entire route on your screen when you reorient the device. If you don't want it to zoom, press the navigation button in the lower right corner and optionally switch off voice navigation.

Can you use Google Maps and zoom at the same time?

Google Maps - cannot zoom and move at the same time with animateCamera, but can with moveCamera. Bookmark this question. Show activity on this post. I am using Google Maps for Android.


2 Answers

pass your current location in this function where you have placed your marker.

private void moveToCurrentLocation(LatLng currentLocation) {        googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLocation,15));     // Zoom in, animating the camera.     googleMap.animateCamera(CameraUpdateFactory.zoomIn());     // Zoom out to zoom level 10, animating with a duration of 2 seconds.     googleMap.animateCamera(CameraUpdateFactory.zoomTo(15), 2000, null);   } 
like image 83
TheFlash Avatar answered Sep 21 '22 11:09

TheFlash


Provide marker position.

private void pointToPosition(LatLng position) {     //Build camera position     CameraPosition cameraPosition = new CameraPosition.Builder()             .target(position)             .zoom(17).build();     //Zoom in and animate the camera.     mGoogleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); } 
like image 31
Pasan Randula Eramusugoda Avatar answered Sep 20 '22 11:09

Pasan Randula Eramusugoda