+ Reply to Thread
Results 1 to 2 of 2

Thread: Feature Layer. Disappearing points.

  1. #1
    Inessa Shammas
    Join Date
    Apr 2012
    Posts
    4
    Points
    0
    Answers Provided
    0


    0

    Default Feature Layer. Disappearing points.

    If “Apply Edits” method used on second Feature Layer, then after pausing and resuming the application, features load, but don’t appear.

    Code:
    public class BlablaESRIActivity extends Activity {
    	
    	public MapView mapView;
    
    	BingMapsLayer tLayer = null;
    	ArcGISFeatureLayer fLayer = null;
    	ArcGISFeatureLayer logTable = null;
    	
    	Graphic currentGraphic = null;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            requestWindowFeature(Window.FEATURE_NO_TITLE);
            setContentView(R.layout.main);
    		
            mapView = (MapView)findViewById(R.id.mapview); 
            
            mapView.setOnStatusChangedListener(mapOnStatusChangedListener);
    
            tLayer = new BingMapsLayer("vjhadbfabsdffv...", MapStyle.Road);  
    	mapView.addLayer(tLayer);
    		
    	mapView.setOnSingleTapListener(mapOnSingleTapListener);	
        }
         
    	@Override 
    	protected void onDestroy() { 
    		super.onDestroy();
    		mapView.recycle();	
    	}
    	
    	@Override
    	protected void onPause() {
    		super.onPause();
    		mapView.pause();
    	}
    	
    	@Override 	
    	protected void onResume() {
    		super.onResume(); 
    		mapView.unpause();		
    	}
    	
    	private OnStatusChangedListener mapOnStatusChangedListener = new OnStatusChangedListener() {
    
    		private static final long serialVersionUID = 1L;
    
    		public void onStatusChanged(Object source, STATUS status) {
    			if (source == mapView && status == STATUS.INITIALIZED) {
    			     fLayer = new ArcGISFeatureLayer("http://.../ArcGIS/rest/services/POIs/FeatureServer/0",MODE.ONDEMAND);	
    		             mapView.addLayer(fLayer);
    		
    		            logTable = new ArcGISFeatureLayer("http://.../ArcGIS/rest/services/POIs/FeatureServer/1", new Options(),c);	
    			}
    		}
    	};
    
    	private OnSingleTapListener mapOnSingleTapListener = new OnSingleTapListener() {
    
    		private static final long serialVersionUID = 1L;
    
    		public void onSingleTap(float x, float y) {
    			
    			if (currentGraphic == null) {
    	        	int[] graphicIDs = fLayer.getGraphicIDs(x, y, 20);
    	        	if (graphicIDs == null) return;
    	        	if (graphicIDs.length == 0) return;
    	        	currentGraphic = fLayer.getGraphic(graphicIDs[0]);
    			} else {
            		Point p = (Point) currentGraphic.getGeometry();
            		p.setXY(mapView.toMapPoint(x, y).getX(), mapView.toMapPoint(x, y).getY());	
    				saveCurrentPOI();
    			}
    		}
    	};	
    	
    	public void saveCurrentPOI() {
    		
    		if (currentGraphic == null) return;
    
    		fLayer.applyEdits(null, null, new Graphic[] { currentGraphic }, null);
    		    	
    		Map<String, Object> attributes = new HashMap<String, Object>();
    		attributes.put("LANDMARK_NAME", "name");	
    		attributes.put("LANDMARK_X", ((Point) currentGraphic.getGeometry()).getX());
    		attributes.put("LANDMARK_Y", ((Point) currentGraphic.getGeometry()).getY());
        
        	Graphic newLogRecord = new Graphic(null, null, attributes, null); 
    
        	//If “Apply Edits” method used on this Feature Layer, then after pausing and resuming the application, fLayer points load, but don’t appear.
        	logTable.applyEdits(new Graphic[] { newLogRecord }, null, null, null);	
        	currentGraphic = null;
    	}	
    }

  2. #2
    Iain Campion
    Join Date
    Mar 2010
    Posts
    26
    Points
    2
    Answers Provided
    0


    0

    Default Re: Feature Layer. Disappearing points.

    Hi,

    I had a similar issue with flex ....

    when the edits where applied, the graphics disappeared ..

    and had to create a new instance off the graphic that wasnt connected to the graphic layer and it kept the graphics on the screen in this function below ...... (instead of using the graphic input from the function)

    hope this helps ..

    Code:
    private function FeatureOperation(graphic:Graphic, shapetype:String, operation:String):void
    			{
    				
    				if(operation == "add")
    				{
    					
    				
    				///test applying edits
    				const attr:Object = {};
    				
    				var date:Date = new Date();
    				
    				//set attributes
    				attr["BlastID"] = blastID.text;
    				attr["DateCreated"] = date.time;     //1227663551096;
    				attr["StartDate"] =  null;   ///1227663551096;
    				attr["StartTime"] =  null;   ///1227663551096;
    				attr["FinishDate"] = null;
    				attr["FinishTime"] = null;
    				attr["CreatedBy"] = null;
    				attr["InnerBuffer"] = innerBuffer.text;
    				attr["OuterBuffer"] = outerBuffer.text;
    				attr["ShapeType"] = shapetype; 
    				attr["Status"] = 1 ; ///Domain: Coded Values: [1: Active], [2: Inactive], [3: Planned], ...1 more...)
    				
    				var g:Graphic = new Graphic(graphic.geometry,null,attr);
    							
    				///graphic.attributes = attr;
    				
    				
    				FeatureLayer(editfs).applyEdits( [ g ], null, null , true, new AsyncResponder(featureLayer_editsCompleteHandler, featureLayer_faultHandler));
    				
    				};

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts