I'm trying to add the my location button in my android application. This is the code I currently have:
`public class MapActivity extends FragmentActivity {
private GoogleMap googleMap;
int position;
String alllatitude,alllongitude,alldirname;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_activity);
Intent i=getIntent();
position=i.getIntExtra("POSITION", 0);
alllatitude=i.getStringExtra("LATITUDE");
alllongitude=i.getStringExtra("LONGITUDE");
alldirname=i.getStringExtra("DIRNAME");
LatLng TutorialsPoint = new LatLng(Double.parseDouble(alllatitude), Double.parseDouble(alllongitude));
try {
if (googleMap == null) {
googleMap = ((MapFragment) getFragmentManager()
.findFragmentById(R.id.map)).getMap();
}
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(TutorialsPoint, 15.0f));
googleMap.addMarker(new MarkerOptions().position(TutorialsPoint)
.title(alldirname));
} catch (Exception e) {
e.printStackTrace();
}
}
}`
Any help would be much appreciated.
0 comments:
Post a Comment