How to enlarge and add a marker to the android map

I show the map in my Android application (google maps api v2). I want to manipulate the map to show a specific location, scale and marker.

can anyone give an example of mapfragment manipulation

+5
source share
1 answer

To get an instance of the card in code, do the following:

map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();

or

map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

depending on whether you use SupportMapFragmentor MapFragmentin your xml file.

Then add a marker to it:

Marker newmarker = map.addMarker(new MarkerOptions().position(latlng).title("marker title").icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_for_map_purpul)));

To enlarge the map:

CameraPosition cameraPosition = new CameraPosition.Builder().target(latlng).zoom(14.0f).build();
CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition);
map.moveCamera(cameraUpdate);   
+21
source

All Articles