参考这个网站,我建立了MapActivity
如下:
public class MainActivity extends Activity {
private MapView mapView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mapView = (MapView) findViewById(R.id.map);
mapView.setComponents(new Components());
RasterDataSource datasource = new PackagedRasterDataSource(new EPSG3857(), 11, 12, "t{zoom}_{x}_{y}", getApplicationContext());
RasterLayer mapLayer = new RasterLayer(datasource, 16);
mapView.getLayers().setBaseLayer(mapLayer);
mapView.setFocusPoint(mapView.getLayers().getBaseLayer().getProjection().fromWgs84(47.0f, 9.0f));
//mapView.setZoom(15);
}
@Override
protected void onStart(){
super.onStart();
mapView.startMapping();
}
@Override
protected void onStop(){
mapView.stopMapping();
super.onStop();
}
}
我已将图块放入我的res/raw
文件夹中,但没有显示任何内容。有什么我想念的吗?根据教程,它必须显示一些东西。我还能提供什么来调试它?xml 是一个简单MapView
的 withwidth
和height
.