Select to view content in your preferred language

mapView is blank when added to a layout

3298
1
03-12-2013 06:46 AM
SethSeligman
New Contributor
When I have a mapView that is already defined in a layout and set the view with the following code, everything works fine:

map = (MITMapView)findViewById(getMapViewID());

However, if I tried to add a mapView dynamically to a linear layout using the addView method, the mapView appears blank (black or grey). If there any way to dynamically add mapviews to a layout?
0 Kudos
1 Reply
SriramV
Emerging Contributor
Hi,
Iam able to add the MapView dynamically. Here's the code snippet:

Java Code:
  map = new MapView(this);
 
  ((LinearLayout)findViewById(R.id.contentLayout)).addView(map, 0,new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,  LayoutParams.FILL_PARENT));

  map.setExtent(new Envelope(-19332033.11, -3516.27, -1720941.80, 11737211.28));

XML:
    <LinearLayout
        android:id="@+id/contentLayout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" />


Do let me know if you meant something else.

Thanks,
V. Sriram
0 Kudos