我想以编程方式实例化 MapView。我正在使用 Osmdroid。我写了这个,但地图没有显示(有或没有设置参数)!怎么了?
LinearLayout contentLayout = (LinearLayout) findViewById(R.id.contentLayout);
m_mapView = new MapView(this, 10);
org.osmdroid.views.MapView.LayoutParams mapParams = new org.osmdroid.views.MapView.LayoutParams(
org.osmdroid.views.MapView.LayoutParams.MATCH_PARENT,
org.osmdroid.views.MapView.LayoutParams.MATCH_PARENT,
null, 0, 0, 0);
m_mapView.setBuiltInZoomControls(true);
m_mapView.setMultiTouchControls(false);
mapController = this.m_mapView.getController();
mapController.setZoom(MAP_DEFAULT_ZOOM);
m_mapView.getController().setCenter( new GeoPoint(MAP_DEFAULT_LATITUDE, MAP_DEFAULT_LONGITUDE));
m_mapView.invalidate();
contentLayout.addView(m_mapView,mapParams);