/*
* Copyright 2010, 2011, 2012 mapsforge.org
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.applications.android.samples;
import java.io.File;
import org.mapsforge.android.maps.MapActivity;
import org.mapsforge.android.maps.MapView;
import org.mapsforge.map.reader.header.FileOpenResult;
import android.os.Bundle;
import android.os.Environment;
import android.widget.Toast;
/**
* A simple application which demonstrates how to use a MapView.
*/
public class BasicMapViewer extends MapActivity {
private static final File MAP_FILE = new File(Environment.getExternalStorageDirectory().getPath(), "berlin.map");
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MapView mapView = new MapView(this);
mapView.setClickable(true);
mapView.setBuiltInZoomControls(true);
FileOpenResult fileOpenResult = mapView.setMapFile(MAP_FILE);
if (!fileOpenResult.isSuccess()) {
Toast.makeText(this, fileOpenResult.getErrorMessage(), Toast.LENGTH_LONG).show();
finish();
}
setContentView(mapView);
}
}