I am also able to get the data too. But to show them on an offline layer i would need the layer definition as string. What to do now?
I send request to my ArcGis Service using layer url + "?f=pjson". Get this json and save it to the file. And then using layer definition from this file.
{ "error": { "code": 499, "message": "Token Required", "details": [] } }
UserCredentials creds = new UserCredentials(); creds.setUserAccount("username", "password"); creds.setUserToken("token", "AkwekUYsasaYU"); ArcGISDynamicMapServiceLayer layer = new ArcGISDynamicMapServiceLayer( "http://servicesbeta.esri.com/ArcGIS/rest/services/SanJuan/TrailConditions/MapServer", null,creds);
Hello,Can you please tell me how did you manage to get the layer definition dynamically through code. I can see that in the "CreateJSONLocalMaps" project, the layer definition is hardcoded in the "strings.xml". I have nearly 90 layers for which i want to dynamically fetch the layer definition.
Hi all.I'll try to load feature layer offline. I used code such as in example Wind Turbines. I send query to layer, save json to file, get definition from server.But there are not features on map. Why is this happening?
Query query = new Query(); // set spatial reference SpatialReference sr = SpatialReference.create(102100); // set the geometry to the sketch polygon query.setGeometry(selection); // query features that are completely contained by selection query.setSpatialRelationship(SpatialRelationship.CONTAINS); // set query in/out spatial ref query.setInSpatialReference(sr); query.setOutSpatialReference(sr); // return all features query.setOutFields(new String[]{"*"}); // include geometry in result set query.setReturnGeometry(true); // run query on FeatureLayer off UI thread windTurbine.queryFeatures(query, new CallbackListener<FeatureSet>() {
// create feature set as json string String fsstring = FeatureSet.toJson(result); // create fully qualified path for json file path = createJsonFile(); // create a File from json fully qualified path File outfile = new File(path); // create output stream to write to json file outstream = new FileOutputStream(outfile); outstream.write(fsstring.getBytes()); // close output stream outstream.close();
public FeatureSet createWindTurbinesFeatureSet(String path) { FeatureSet fs = null; try { JsonFactory factory = new JsonFactory(); JsonParser parser = factory.createJsonParser(new FileInputStream(path)); parser.nextToken(); fs = FeatureSet.fromJson(parser); } catch (Exception e) { e.printStackTrace(); } return fs; }
// Create wind turbine featurelayer from json windTurbineFeatureSet = createWindTurbinesFeatureSet(jsonPath); windTurbineLayerDefinition = this.getResources().getString(R.string.config_windturbine_layer_definition); ArcGISFeatureLayer.Options layerOptions = new ArcGISFeatureLayer.Options(); layerOptions.mode = ArcGISFeatureLayer.MODE.SNAPSHOT; // create the offline feature layer windTurbinesFeatureLayer = new ArcGISFeatureLayer(windTurbineLayerDefinition, windTurbineFeatureSet, layerOptions);
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.