AnsweredAssumed Answered

Android APP to view offline .shp files

Question asked by iMoVe on Dec 17, 2014
Latest reply on Jan 7, 2015 by iMoVe

Hello, my name is Motiejus and Im a GIS specialist who is trying to flip over to the dark side (become a developer). Im just starting so it is very difficult and I could use some help to get on my feet.

 

Im trying to write an app that displays offline shapefiles on android device.

Found a sample how to do it here: Shapefile feature layer | ArcGIS for Developers

If I just paste the code in my Eclipes, I get a bunch of errors. Maybe I dont know how to use samples?

 

Anyways I reduced the code and Im stuck at several errors here:

 

        // create a renderer

        UniqueValueRenderer uvRenderer = new UniqueValueRenderer(

                new SimpleFillSymbol(new Color(0, 0, 0, 255), null), "CONTINENT");

 

Error:

Multiple markers at this line

    - The constructor SimpleFillSymbol(Color, null) is undefined

    - The constructor Color(int, int, int, int) is undefined

    - The constructor UniqueValueRenderer(SimpleFillSymbol, String) is

     undefined

 

 

 

 

 

 

 

 

My full code can be found here

package offline.map;

 

import java.io.FileNotFoundException;

 

import android.app.Activity;

import android.graphics.Color;

import android.os.Bundle;

 

 

import com.esri.android.map.FeatureLayer;

import com.esri.android.map.MapView;

import com.esri.core.geodatabase.ShapefileFeatureTable;

import com.esri.core.renderer.UniqueValueRenderer;

import com.esri.core.symbol.SimpleFillSymbol;

 

 

public class OfflineMapActivity extends Activity {

   

    MapView mMapView;

    ShapefileFeatureTable shapefileTable;

    /** Called when the activity is first created. */

    @Override

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);

 

 

     // Create shapefile feature table from path to .shp file

 

         try {

            shapefileTable = new ShapefileFeatureTable("storage/emulated/0/Documents/sav.shp");

        } catch (FileNotFoundException e) {

            // TODO Auto-generated catch block

            e.printStackTrace();

        }

 

        FeatureLayer featureLayer = new FeatureLayer(shapefileTable);

       

        // create a renderer

        UniqueValueRenderer uvRenderer = new UniqueValueRenderer(new SimpleFillSymbol(new Color(0, 0, 0, 255), null), "CONTINENT");

        // set renderer

 

        featureLayer.setRenderer(uvRenderer);

        mMapView.addLayer(featureLayer);

 

    }

 

    @Override

    protected void onDestroy() {

        super.onDestroy();

}

    @Override

    protected void onPause() {

        super.onPause();

        mMapView.pause();

}

    @Override

    protected void onResume() {

        super.onResume();

        mMapView.unpause();

    }

 

}

Outcomes