I'm trying to display a map which I created and uploaded on ArcGIS online as a map package:
map = new JMap();
Portal portal = new Portal("http://www.arcgis.com", null);
PortalItem item = null;
item = PortalItem.fetchItem(portal, "9464b884blahblahblah");
WebMap wm = WebMap.newInstance(item);
map.loadWebMap(wm);
I tried the code with a map ID from the samples provided in the docs and it works fine.
With the ID of the map I uploaded, however, I get this error:
Java version : 1.8.0_20 (Oracle Corporation) amd64
Rendering engine : DirectX
Unable to construct spatial reference from GCS_WGS_1984
org.codehaus.jackson.JsonParseException: Unexpected character ('z' (code 122)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
at [Source: org.apache.http.conn.EofSensorInputStream@48718cc6; line: 1, column: 3]
at org.codehaus.jackson.JsonParser._constructError(JsonParser.java:1432)
at org.codehaus.jackson.impl.JsonParserMinimalBase._reportError(JsonParserMinimalBase.java:521)
at org.codehaus.jackson.impl.JsonParserMinimalBase._reportUnexpectedChar(JsonParserMinimalBase.java:442)
at org.codehaus.jackson.impl.Utf8StreamParser._handleUnexpectedValue(Utf8StreamParser.java:2090)
at org.codehaus.jackson.impl.Utf8StreamParser._nextTokenNotInObject(Utf8StreamParser.java:606)
at org.codehaus.jackson.impl.Utf8StreamParser.nextToken(Utf8StreamParser.java:492)
at com.esri.core.portal.WebMap.a(Unknown Source)
at com.esri.core.portal.WebMap.<init>(Unknown Source)
at com.esri.core.portal.WebMap.<init>(Unknown Source)
at com.esri.core.portal.WebMap.newInstance(Unknown Source)
at Tsunami.<init>(Tsunami.java:80)
at Tsunami$2.run(Tsunami.java:105)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:744)
at java.awt.EventQueue.access$400(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:697)
at java.awt.EventQueue$3.run(EventQueue.java:691)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:714)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
The "Unable to construct spatial reference ..." error message pops up after 1-2 seconds after starting the program, where as the JsonParseException takes about 10 seconds to appear and is triggered by the following line:
WebMap wm = WebMap.newInstance(item);
I checked the layers I created (in properties, in the coordinate system tab) they do reside under a "GCS_WGS_1984" coordinate system.
Is the JsonParseException somehow linked to the Unable to construct... error message?
Can anybody tell me what am I doing wrong?
Thank you for the support in advance!
Solved! Go to Solution.
Turns out I wasn't exporting with support for ArcGIS Runtime.
I first had to enable this feature: Customize > Sharing > Under the Packaging fieldset > Check "Enable ArcGIS Runtime Tools".
Then I was able to File > Share As > Map Package and check "Support ArcGIS Runtime" and then it worked fine after sharing.
Turns out I wasn't exporting with support for ArcGIS Runtime.
I first had to enable this feature: Customize > Sharing > Under the Packaging fieldset > Check "Enable ArcGIS Runtime Tools".
Then I was able to File > Share As > Map Package and check "Support ArcGIS Runtime" and then it worked fine after sharing.