0
public class MapActivity extends SherlockFragmentActivity{
// Google Map
private GoogleMap googleMap;
String longitude="0";
String latitude="0";
String title="";
@Override
protected void onCreate(Bundle savedInstanceState) {
try
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
try {
// Loading map
initilizeMap();
} catch (Exception e) {
e.printStackTrace();
}}
catch(Exception eos)
{
}
}
/**
* function to load map. If map is not created it will create it for you
* */
private void initilizeMap() {
try
{
if (googleMap == null) {
String longitude="27.175015";
String latitude="78.042155";
double savedLat = Double.parseDouble(longitude);
double savedLng =Double.parseDouble(latitude);
LatLng cameraLatLng = new LatLng(savedLat, savedLng);
googleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(
R.id.map)).getMap();
googleMap.addMarker(new MarkerOptions()
.position(new LatLng(Float.parseFloat(latitude), Float.parseFloat(longitude))).title("Marker")
.title("mazen"));
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(cameraLatLng, 17));
// check if map is created successfully or not
if (googleMap == null) {
}
}
}
catch(Exception e)
{
}
}
@Override
protected void onResume() {
super.onResume();
initilizeMap();
}
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
finish();
overridePendingTransition(R.anim.dux_sld_lft_in,
R.anim.dux_sld_lft_out);
return true;
}else {
return super.onOptionsItemSelected(item);
}
}
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
super.onBackPressed();
overridePendingTransition(R.anim.dux_sld_lft_in, R.anim.dux_sld_lft_out);
}
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
return true;
}
上午在這裏添加標記,但沒有標記說明爲什麼?我怎樣才能添加多個標記到多個地方?很可笑的錯誤......因爲我真的exacty的教程中,我讀.. 希望有人能養活我完成這項任務所需nessary幫助
圖標沒有什麼區別我t不起作用。 – user3278732 2014-10-18 22:09:03
顯示錯誤日誌。 – 2014-10-18 22:21:14
它適用於不同的地方,但不適用於印度。非常有趣 – user3278732 2014-10-18 22:21:34