google maps - how to zoom and add marker to android mapfragment -
i displaying map @ android application (google maps api v2). want manipulate map in order show specific location, zoom , marker.
can give example of manipulation mapfragment
to map instance in code this:
map = ((supportmapfragment) getsupportfragmentmanager().findfragmentbyid(r.id.map)).getmap();
or:
map = ((mapfragment) getfragmentmanager().findfragmentbyid(r.id.map)).getmap();
depending on whether used supportmapfragment
or mapfragment
in xml file.
then add marker it:
marker newmarker = map.addmarker(new markeroptions().position(latlng).title("marker title").icon(bitmapdescriptorfactory.fromresource(r.drawable.marker_for_map_purpul)));
to zoom map:
cameraposition cameraposition = new cameraposition.builder().target(latlng).zoom(14.0f).build(); cameraupdate cameraupdate = cameraupdatefactory.newcameraposition(cameraposition); map.movecamera(cameraupdate);
Comments
Post a Comment