kostas
kostas

Reputation: 53

how to change my first view of the map activity

i have a map activity in my app.when the user first starts the map activity,the map presents an overview of the europe.i woulk like,when the user fistly starts the map activity to point to greece for example and not the hole europe..is that possible..?thanks

Upvotes: 1

Views: 215

Answers (1)

TofferJ
TofferJ

Reputation: 4784

You can use the MapController to do that:

MapView map = (MapView) findViewById(R.id.mapview);

GeoPoint center = new GeoPoint(myLatitude, myLongitude);

MapController controller = map.getController();
controller.setCenter(center);
controller.setZoom(ZOOM_LEVEL_DEFAULT);

or if you want to calculate a zoom that fits some longitude/latitude span:

int latitudeSpan = latitude1 - latitude2;
int longitudeSpan = longitude1 - longitude2;
controller.zoomToSpan(latitudeSpan, longitudeSpan);

Upvotes: 3

Related Questions