@Override public boolean onCreateOptionsMenu(Menu menu) { // Instantiate preference manager prefs = PreferenceManager.getDefaultSharedPreferences(this); // Instantiate Application class and call the setLanguage method BusPlus bp = (BusPlus) getApplicationContext(); bp.setLanguage(prefs.getString("language", "sr")); new MenuInflater(this).inflate(R.menu.option_map, menu); return (super.onCreateOptionsMenu(menu)); }
/** Center map on current coordinates * */ public void centerLocation(boolean showDialog) { // Show a dialog if there is no provider if (noProvider & showDialog) { showMsgDialog(getString(R.string.no_provider), getString(R.string.turn_on_location)); } else { if (mLatitude != 0 && mLongitude != 0) { // Center on current coordinates GeoPoint centerGeoPoint = new GeoPoint((int) (mLatitude * 1E6), (int) (mLongitude * 1E6)); mapView.getController().setCenter(centerGeoPoint); // Draw all markers again if they were visible if (all) drawViewMarkers(); } else { BusPlus bp = (BusPlus) getApplicationContext(); bp.showToastMessage(getString(R.string.location_waiting)); } } }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Instantiate preference manager prefs = PreferenceManager.getDefaultSharedPreferences(this); // Instantiate Application class and call the setLanguage method BusPlus bp = (BusPlus) getApplicationContext(); bp.setLanguage(prefs.getString("language", "sr")); // Sets the view for this activity setContentView(R.layout.map); // Instantiate helper object for work on database helper = new DataBaseHelper(this); // Set up some map view parameters mapView = (MyMapView) findViewById(R.id.mapview); mapView.setBuiltInZoomControls(true); mapView.getController().setZoom(17); mapView.setOnZoomListener( new MyMapView.OnZoomListener() { @Override public void onZoom() { if (all) drawViewMarkers(); } }); centerMap(44.818061, 20.456524); // Set Satellite view on our map, if the preference has been set mapView.setSatellite(prefs.getBoolean("map_satellite", false)); // Get the best location provider and start location thread initializeLocationAndStartGpsThread(); }