Select to view content in your preferred language

Trouble loading a second layer in map

2596
1
02-04-2013 05:47 AM
BrianMulcahy
Occasional Contributor
Well it is basically just the nearby application but when I try to load my own layer it states unknown source and never loads the layer. I tried it both as dynamic and tiled(does have a server cache) but can't seem to get it to load. This isn't just my own layer either when I try to load any second layer other than the one in the nearby app it won't load. Layer displays fine in other non android application. Any ideas?

Error I receive
02-04 09:40:45.547: E/ArcGIS(4407): ImageCallback.onError
02-04 09:40:45.547: E/ArcGIS(4407): com.esri.core.io.EsriServiceException: Image width is not in range. Valid range is from 1 to 2048.
02-04 09:40:45.547: E/ArcGIS(4407):  at com.esri.core.internal.io.handler.c.a(Unknown Source)
02-04 09:40:45.547: E/ArcGIS(4407):  at com.esri.core.internal.io.handler.a.a(Unknown Source)
02-04 09:40:45.547: E/ArcGIS(4407):  at com.esri.core.internal.tasks.a.g.a(Unknown Source)
02-04 09:40:45.547: E/ArcGIS(4407):  at com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.a(Unknown Source)
02-04 09:40:45.547: E/ArcGIS(4407):  at com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.getImage(Unknown Source)
02-04 09:40:45.547: E/ArcGIS(4407):  at com.esri.android.map.DynamicLayer$1.run(Unknown Source)
02-04 09:40:45.547: E/ArcGIS(4407):  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
02-04 09:40:45.547: E/ArcGIS(4407):  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
02-04 09:40:45.547: E/ArcGIS(4407):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
02-04 09:40:45.547: E/ArcGIS(4407):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
02-04 09:40:45.547: E/ArcGIS(4407):  at java.lang.Thread.run(Thread.java:856)


From this code

package com.gissal.map;



import android.app.Activity;
import android.app.ProgressDialog;
import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;

import com.esri.android.map.Callout;
import com.esri.android.map.GraphicsLayer;
import com.esri.android.map.LocationService;
import com.esri.android.map.MapView;
import com.esri.android.map.ags.ArcGISDynamicMapServiceLayer;
import com.esri.android.map.ags.ArcGISTiledMapServiceLayer;
import com.esri.android.map.event.OnStatusChangedListener;
import com.esri.core.geometry.Envelope;
import com.esri.core.geometry.GeometryEngine;
import com.esri.core.geometry.LinearUnit;
import com.esri.core.geometry.Point;
import com.esri.core.geometry.SpatialReference;
import com.esri.core.geometry.Unit;
import com.esri.core.symbol.PictureMarkerSymbol;



public class MappingActivity extends Activity {
 final static int TITLE_ID = 1;
 final static int REVIEW_ID = 2;
 // The circle area specified by search_radius and input lat/lon serves
 // searching purpose. It is also used to construct the extent which
 // map zooms to after the first GPS fix is retrieved.
 final static double SEARCH_RADIUS = 5;

 MapView map = null;
 GraphicsLayer graphicsLayer = null;
 
 ProgressDialog progress;
 PictureMarkerSymbol hazardIcon;
 ImageButton hazard;
 View content;
 Callout callout;

 
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  
  
     hazardIcon = new PictureMarkerSymbol(this.getResources().getDrawable(
    R.drawable.add_hazard));
     // Retrieves ImageButton declared in main.xml
     hazard = (ImageButton) findViewById(R.id.hazard);
        
  map = (MapView) findViewById(R.id.map);
  
  map.addLayer(new ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"));
  map.addLayer(new ArcGISDynamicMapServiceLayer("http://services.geog.ksu.edu/ArcGIS/rest/services/RTLA/FRK_RTLA_Base/MapServer"));

  graphicsLayer = new GraphicsLayer();
  map.addLayer(graphicsLayer);

  
  map.setOnStatusChangedListener(new OnStatusChangedListener() {

   private static final long serialVersionUID = 1L;

   public void onStatusChanged(Object source, STATUS status) {
    if (source == map && status == STATUS.INITIALIZED) {
     LocationService ls = map.getLocationService();
     ls.setAutoPan(false);
     ls.setLocationListener(new LocationListener() {

      boolean locationChanged = false;

      // Zooms to the current location when first GPS fix
      // arrives.
      public void onLocationChanged(Location loc) {
       if (!locationChanged) {
        locationChanged = true;
        double locy = loc.getLatitude();
        double locx = loc.getLongitude();
        Point wgspoint = new Point(locx, locy);
        Point mapPoint = (Point) GeometryEngine
          .project(wgspoint,
            SpatialReference.create(4326),
            map.getSpatialReference());

        Unit mapUnit = map.getSpatialReference()
          .getUnit();
        double zoomWidth = Unit.convertUnits(
          SEARCH_RADIUS,
          Unit.create(LinearUnit.Code.MILE_US),
          mapUnit);
        Envelope zoomExtent = new Envelope(mapPoint,
          zoomWidth, zoomWidth);
        map.setExtent(zoomExtent);

       }

      }

      public void onProviderDisabled(String arg0) {

      }

      public void onProviderEnabled(String arg0) {
      }

      public void onStatusChanged(String arg0, int arg1,
        Bundle arg2) {

      }
     });
     ls.start();

    }

   }
  });

  
 
 }
 
 
      

    

 @Override 
 protected void onDestroy() { 
  super.onDestroy();
 }
 @Override
 protected void onPause() {
  super.onPause();
   map.pause();
 }
 @Override  protected void onResume() {
  super.onResume(); 
   map.unpause();
 }

}
0 Kudos
1 Reply
BrianMulcahy
Occasional Contributor
This should be easy. I was thinking it was maybe the spatial reference but if it is a dynamic layer it shouldn't matter should it?
0 Kudos