1

I am developing an Android app using a Webmap with features created on ArcGIS Online. This webmap has a feature layer. I tried to load the basemap and then adding the feature layer, or tried to load the only webmap by its URL. In both ways, I can't display my map.

Can you help me to find what's the matter?

The Layout is:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#428"
    tools:context=".Pippo_NotLogged" >

    <TabHost
        android:id="@+id/tabHost"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >
            </TabWidget>

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >

                <LinearLayout
                    android:id="@+id/tab2"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical" >

                    <LinearLayout
                        android:id="@+id/mapLayout1"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_alignParentLeft="true"
                        android:layout_alignParentTop="true" >

                        <LinearLayout
                            android:id="@+id/buttonLayout"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentTop="true" >

                            <Button
                                android:id="@+id/centerButton"
                                style="?android:attr/buttonStyleSmall"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="CENTER"
                                android:textColor="#000000" />
                        </LinearLayout>

                        <com.esri.android.map.MapView
                            android:id="@+id/map"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:layout_alignParentLeft="true"
                            android:layout_alignParentTop="true">
                            <!-- mapoptions.MapType="Topo"  -->
                        </com.esri.android.map.MapView>
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentBottom="true"
                        android:layout_alignParentLeft="true"
                        android:layout_marginBottom="51dp"
                        android:layout_marginLeft="126dp"
                        android:orientation="vertical" >
                    </LinearLayout>

                    <ZoomControls
                        android:id="@+id/zoomControls1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentBottom="true"
                        android:layout_centerHorizontal="true" />
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/tab3"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="#158"
                    android:orientation="vertical" >

                    <LinearLayout
                        android:id="@+id/LayoutRow5"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="35dp"
                        android:orientation="horizontal" >

                        <TextView
                            android:id="@+id/bullet1"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="left"
                            android:text="Scarica il regolamento del parco!"
                            android:textColor="#00fb4c"
                            android:textSize="26dp"
                            android:typeface="serif" />
                    </LinearLayout>

                    <LinearLayout
                        android:id="@+id/LayoutRow6"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="20dp"
                        android:orientation="horizontal" >

                        <TextView
                            android:id="@+id/bullet2"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Informazioni turistiche"
                            android:textSize="26dp"
                            android:typeface="serif" />
                    </LinearLayout>

                    <LinearLayout
                        android:id="@+id/LayoutRow7"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="50dp"
                        android:orientation="horizontal" >

                        <TextView
                            android:id="@+id/bullet3"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Eventi della settimana"
                            android:textSize="26dp"
                            android:typeface="serif" />
                    </LinearLayout>

                    <LinearLayout
                        android:id="@+id/LayoutRow8"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="68dp"
                        android:layout_marginTop="20dp"
                        android:orientation="horizontal" >

                        <TextView
                            android:id="@+id/bullet4"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Avvisi ai naviganti"
                            android:textColor="#f60b00"
                            android:textSize="30dp"
                            android:typeface="serif" />
                    </LinearLayout>
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/tab1"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="#158"
                    android:orientation="vertical" >

                    <LinearLayout
                        android:id="@+id/LayoutRow1"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="35dp"
                        android:orientation="horizontal" >

                        <TextView
                            android:id="@+id/longTV"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Longitude : "
                            android:textColor="#f66"
                            android:textSize="30dp"
                            android:typeface="serif" />

                        <TextView
                            android:id="@+id/longTVvalue"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="999.99° E"
                            android:textSize="30dp" />
                    </LinearLayout>

                    <LinearLayout
                        android:id="@+id/LayoutRow2"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="20dp"
                        android:orientation="horizontal" >

                        <TextView
                            android:id="@+id/latTV"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Latitudine : "
                            android:textColor="#f66"
                            android:textSize="30dp"
                            android:typeface="serif" />

                        <TextView
                            android:id="@+id/latTVvalue"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="999.99 °N"
                            android:textSize="30dp" />
                    </LinearLayout>

                    <LinearLayout
                        android:id="@+id/LayoutRow3"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="50dp"
                        android:orientation="horizontal" >

                        <TextView
                            android:id="@+id/vesselTV"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Nome barca:"
                            android:textColor="#f66"
                            android:textSize="30dp"
                            android:typeface="serif" />

                        <TextView
                            android:id="@+id/vesselTVvalue"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="TEST BOAT"
                            android:textSize="30dp" />
                    </LinearLayout>

                    <LinearLayout
                        android:id="@+id/LayoutRow4"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="68dp"
                        android:layout_marginTop="20dp"
                        android:orientation="horizontal" >

                        <TextView
                            android:id="@+id/userTV"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Nome utente:"
                            android:textColor="#f66"
                            android:textSize="30dp"
                            android:typeface="serif" />

                        <TextView
                            android:id="@+id/userTVvalue"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="blue-thread"
                            android:textSize="30dp" />
                    </LinearLayout>
                </LinearLayout>
            </FrameLayout>
        </LinearLayout>
    </TabHost>

</RelativeLayout>

The onCreate method of the main activity is written in two different ways. 1st:

 @Override

  public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.tabs_layout2d);

    tabHost=(TabHost)findViewById(R.id.tabHost);
    tabHost.setup();
    TabSpec spec1=tabHost.newTabSpec("TAB 1");
    spec1.setContent(R.id.tab1);
    spec1.setIndicator("INFO IMBARCAZIONE");      
    TabSpec spec2=tabHost.newTabSpec("TAB 2");
    spec2.setIndicator("VEDI MAPPA");
    spec2.setContent(R.id.tab2);    
    TabSpec spec3=tabHost.newTabSpec("TAB 3");
    spec3.setContent(R.id.tab3);
    spec3.setIndicator("SITI");
    tabHost.addTab(spec1);
    tabHost.addTab(spec2);
    tabHost.addTab(spec3);
    centerButton = (Button) findViewById(R.id.centerButton);

    mercPoint = ToWebMercator(Posizione_dummy_lat, Posizione_dummy_long);

    // Set the Esri logo to be visible, and enable map to wrap around date line.
    mMapView = new MapView(
            this,
            "http://www.arcgis.com/home/item.html?id=81d2dcf906cf4df4889ec36c8dc0c1f9",
            "", "");    
    mMapView.inflate(getApplicationContext(), R.id.map, null);

    mMapView.setEsriLogoVisible(true);
    mMapView.enableWrapAround(true);
    mMapView.centerAt(mercPoint, true);

}

2nd:

 @Override

  public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.tabs_layout2d);

    tabHost=(TabHost)findViewById(R.id.tabHost);
    tabHost.setup();
    TabSpec spec1=tabHost.newTabSpec("TAB 1");
    spec1.setContent(R.id.tab1);
    spec1.setIndicator("INFO IMBARCAZIONE");      
    TabSpec spec2=tabHost.newTabSpec("TAB 2");
    spec2.setIndicator("VEDI MAPPA");
    spec2.setContent(R.id.tab2);    
    TabSpec spec3=tabHost.newTabSpec("TAB 3");
    spec3.setContent(R.id.tab3);
    spec3.setIndicator("SITI");
    tabHost.addTab(spec1);
    tabHost.addTab(spec2);
    tabHost.addTab(spec3);
    centerButton = (Button) findViewById(R.id.centerButton);

    mercPoint = ToWebMercator(Posizione_dummy_lat, Posizione_dummy_long);

    mMapView = (MapView) findViewById(R.id.map);
    mMapView.setMapOptions(new MapOptions(MapType.TOPO));
     ArcGISFeatureLayer webLayerParco = new ArcGISFeatureLayer("http://www.arcgis.com/home/item.html?id=2fd577ea8e534354a13afe236a4d0441", ArcGISFeatureLayer.MODE.ONDEMAND);
   mMapView.addLayer(webLayerParco);
    mMapView.setEsriLogoVisible(true);
    mMapView.enableWrapAround(true);
    mMapView.centerAt(mercPoint, true);

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.