first map not drawing

808
4
Jump to solution
10-28-2012 08:01 PM
forestknutsen1
MVP Regular Contributor
I have created simple service on my server and I'm trying to display it on a android device. However when I run the code all I get is a gray screen.

The java code:

import android.app.Activity; import android.os.Bundle;   import com.esri.android.map.MapView; import com.esri.android.map.ags.ArcGISDynamicMapServiceLayer;    public class MyPath_v02Activity extends Activity {    MapView mMapView = null;  private ArcGISDynamicMapServiceLayer dynamicLayer;      /** Called when the activity is first created. */     @Override     public void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.main);    mMapView = (MapView)findViewById(R.id.map);   dynamicLayer = new ArcGISDynamicMapServiceLayer("http://anc-arcsrv-01.ua.ad.alaska.edu/arcgis/services/myPath_v8/MapServer/MobileServer");   mMapView.addLayer(dynamicLayer);        }   @Override   protected void onDestroy() {    super.onDestroy();  }  @Override  protected void onPause() {   super.onPause();   mMapView.pause();  }  @Override  protected void onResume() {   super.onResume();    mMapView.unpause();  }  }


and the xml code in "main":

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:orientation="vertical"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     tools:context=".MyPath_v02Activity"     > <com.esri.android.map.MapView     android:id="@+id/map"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     initExtent = " -16713385.63038, 8560546.73163, -16546828.73922, 8746032.94837">    </com.esri.android.map.MapView> </LinearLayout>


I made the assumption that the args for initExtent are x min, y min, x max, and y max and I got the values from REST services dir.

I there some thing simple that I'm doing wrong. Thnaks for any help.
0 Kudos
1 Solution

Accepted Solutions
DanO_Neill
Occasional Contributor III

I can add the service for the MapServer to ArcGIS Desktop and to ArcGIS Online with the URL "http://anc-arcsrv-01.ua.ad.alaska.edu/arcgis/services/myPath_v8/MapServer" and every thing works fine. However I'm uncertain how to test the URL for MobileServer service at "http://anc-arcsrv-01.ua.ad.alaska.edu/arcgis/services/myPath_v8/MapServer/MobileServer"


Why are you appending /MobileServer to the end of the URL?  You should use the URL that is working wtih ArcGIS Desktop and ArcGIS Online as the ArcGISDynamicMapServerLayer constructor takes a URL to a valid Map Service Layer. 

BTW:  The URL returns a runtime error for me as well.

View solution in original post

0 Kudos
4 Replies
AndyGup
Esri Regular Contributor
Does the rest endpoint work? I tried to load it in a browser and it failed.

Also check DDMS for any possible errors when the app loads.

-Andy
0 Kudos
forestknutsen1
MVP Regular Contributor
1) I neglected to post the errors from logcat last night with the code. Sorry.

10-29 16:53:11.772: E/ArcGIS(16652): url =http://anc-arcsrv-01.ua.ad.alaska.edu/arcgis/services/myPath_v8/MapServer/MobileServer
10-29 16:53:11.772: E/ArcGIS(16652): org.codehaus.jackson.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
10-29 16:53:11.772: E/ArcGIS(16652):  at [Source: java.io.StringReader@40560848; line: 1, column: 2]
10-29 16:53:11.772: E/ArcGIS(16652):  at org.codehaus.jackson.JsonParser._constructError(JsonParser.java:1432)
10-29 16:53:11.772: E/ArcGIS(16652):  at org.codehaus.jackson.impl.JsonParserMinimalBase._reportError(JsonParserMinimalBase.java:521)
10-29 16:53:11.772: E/ArcGIS(16652):  at org.codehaus.jackson.impl.JsonParserMinimalBase._reportUnexpectedChar(JsonParserMinimalBase.java:442)
10-29 16:53:11.772: E/ArcGIS(16652):  at org.codehaus.jackson.impl.ReaderBasedParser._handleUnexpectedValue(ReaderBasedParser.java:1198)
10-29 16:53:11.772: E/ArcGIS(16652):  at org.codehaus.jackson.impl.ReaderBasedParser.nextToken(ReaderBasedParser.java:485)
10-29 16:53:11.772: E/ArcGIS(16652):  at com.esri.core.internal.b.a.g.a(Unknown Source)
10-29 16:53:11.772: E/ArcGIS(16652):  at com.esri.core.internal.b.a.g.a(Unknown Source)
10-29 16:53:11.772: E/ArcGIS(16652):  at com.esri.core.internal.a.a.n.b(Unknown Source)
10-29 16:53:11.772: E/ArcGIS(16652):  at com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.initLayer(Unknown Source)
10-29 16:53:11.772: E/ArcGIS(16652):  at com.esri.android.map.ags.ArcGISDynamicMapServiceLayer$1.run(Unknown Source)
10-29 16:53:11.772: E/ArcGIS(16652):  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:444)
10-29 16:53:11.772: E/ArcGIS(16652):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
10-29 16:53:11.772: E/ArcGIS(16652):  at java.util.concurrent.FutureTask.run(FutureTask.java:138)
10-29 16:53:11.772: E/ArcGIS(16652):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
10-29 16:53:11.772: E/ArcGIS(16652):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
10-29 16:53:11.772: E/ArcGIS(16652):  at java.lang.Thread.run(Thread.java:1027)


It does look like the first error is at the URL of the service.

2) I can add the service for the MapServer to ArcGIS Desktop and to ArcGIS Online with the URL "http://anc-arcsrv-01.ua.ad.alaska.edu/arcgis/services/myPath_v8/MapServer" and every thing works fine. However I'm uncertain how to test the URL for MobileServer service at "http://anc-arcsrv-01.ua.ad.alaska.edu/arcgis/services/myPath_v8/MapServer/MobileServer"

3) I can see no errors in DDMS as it loads. According to the android console the app installs and starts normally.
[2012-10-29 16:52:59 - MyPath_v02] ------------------------------
[2012-10-29 16:52:59 - MyPath_v02] Android Launch!
[2012-10-29 16:52:59 - MyPath_v02] adb is running normally.
[2012-10-29 16:52:59 - MyPath_v02] Performing forest.knutsen.ccel.uaa.geomatics.MyPath_v02Activity activity launch
[2012-10-29 16:52:59 - MyPath_v02] Automatic Target Mode: using device 'HT1AXT203453'
[2012-10-29 16:52:59 - MyPath_v02] Uploading MyPath_v02.apk onto device 'HT1AXT203453'
[2012-10-29 16:53:04 - MyPath_v02] Installing MyPath_v02.apk...
[2012-10-29 16:53:11 - MyPath_v02] Success!
[2012-10-29 16:53:11 - MyPath_v02] Starting activity forest.knutsen.ccel.uaa.geomatics.MyPath_v02Activity on device HT1AXT203453
[2012-10-29 16:53:12 - MyPath_v02] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=forest.knutsen.ccel.uaa.geomatics/.MyPath_v02Activity }
0 Kudos
DanO_Neill
Occasional Contributor III

I can add the service for the MapServer to ArcGIS Desktop and to ArcGIS Online with the URL "http://anc-arcsrv-01.ua.ad.alaska.edu/arcgis/services/myPath_v8/MapServer" and every thing works fine. However I'm uncertain how to test the URL for MobileServer service at "http://anc-arcsrv-01.ua.ad.alaska.edu/arcgis/services/myPath_v8/MapServer/MobileServer"


Why are you appending /MobileServer to the end of the URL?  You should use the URL that is working wtih ArcGIS Desktop and ArcGIS Online as the ArcGISDynamicMapServerLayer constructor takes a URL to a valid Map Service Layer. 

BTW:  The URL returns a runtime error for me as well.
0 Kudos
forestknutsen1
MVP Regular Contributor
Thank you Andy and Dan for the the help. It is now working fine with an updated (and correct) url.
0 Kudos