Skip to main content

Simple Map activity

There is only map and switch for opengl rendering

public class SimpleMapActivity extends AppCompatActivity {

private OsmandApplication app;
private OsmandMapTileView mapTileView;

private MapViewWithLayers mapViewWithLayers;
private AppInitializeListener initListener;

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.simple_map_activity);
mapViewWithLayers = findViewById(R.id.map_view_with_layers);

app = (OsmandApplication) getApplication();

mapTileView = app.getOsmandMap().getMapView();
mapTileView.setupOpenGLView();

ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setTitle("Simple map");
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}

CompoundButton openglSwitch = findViewById(R.id.opengl_switch);
openglSwitch.setChecked(app.getSettings().USE_OPENGL_RENDER.get());
openglSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
app.getSettings().USE_OPENGL_RENDER.set(isChecked);
RestartActivity.doRestart(this);
});

//set start location and zoom for map
mapTileView.setIntZoom(14);
mapTileView.setLatLon(52.3704312, 4.8904288);
}

@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (item.getItemId() == android.R.id.home) {
finish();
}
return super.onOptionsItemSelected(item);
}

@Override
protected void onResume() {
super.onResume();
mapViewWithLayers.onResume();
}

@Override
protected void onPause() {
super.onPause();
mapViewWithLayers.onPause();
}

@Override
protected void onDestroy() {
super.onDestroy();
mapViewWithLayers.onDestroy();
}
}