Select to view content in your preferred language

Hosted line feature layer not rendered on map

1263
9
09-14-2023 12:11 AM
MaheshP
Emerging Contributor

I am not able to render a line feature layer even though the feature layer is loaded successfully. If I query the features, it will render but still it blinks and goes away when I pan/zoom the map. Let me know if I am missing any thing. Here I am attaching the code

 

Layer currentBaseLayer = new WmtsLayer(<locally hosted url>);
map.getOperationalLayers().add(currentBaseLayer);

serviceGeodatabase = new ServiceGeodatabase(GEOLOGY_FEATURE_SERVICE);
serviceGeodatabase.addDoneLoadingListener(() -> {

serviceFeatureTable = serviceGeodatabase.getTable(0);

featureLayer = new FeatureLayer(serviceFeatureTable);

SimpleLineSymbol bikeTrailSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.DASH, 0xffff0000, 2.0f);


featureLayer.setRenderer(bikeTrailRenderer);


map.getOperationalLayers().add(featureLayer);
featureLayer.addDoneLoadingListener(() -> {
System.out.println(featureLayer.getLoadStatus());
});

});
serviceGeodatabase.loadAsync();

0 Kudos
9 Replies
MarkBaird
Esri Regular Contributor

@MaheshP 

I've taken a quick look at your code, but it isn't complete.  The code which initialises the bikeTrailRenderer is missing.  I've assumed you are using a SimpleRenderer here and managed to get the service working using the following code:

 

private static final String GEOLOGY_FEATURE_SERVICE =
      "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Energy/Geology/FeatureServer/9";

  @Override
  public void start(Stage stage) {

    try {
      // create stack pane and application scene
      StackPane stackPane = new StackPane();
      Scene scene = new Scene(stackPane);

      // size the stage, add a title, and set scene to stage
      stage.setTitle("Feature Layer Feature Service Sample");
      stage.setHeight(700);
      stage.setWidth(800);
      stage.setScene(scene);
      stage.show();

      // authentication with an API key or named user is required to access basemaps and other location services
      String yourAPIKey = System.getProperty("apiKey");
      ArcGISRuntimeEnvironment.setApiKey(yourAPIKey);

      // create a map with the terrain basemap style
      ArcGISMap map = new ArcGISMap(BasemapStyle.ARCGIS_TERRAIN);

      // create a map view and set the map to it
      mapView = new MapView();
      mapView.setMap(map);

      // set a viewpoint on the map view
      mapView.setViewpoint(new Viewpoint(new Point(-13176752, 4090404, SpatialReferences.getWebMercator()), 500000));

      // create feature layer with its service feature table
      // create the service feature table
      ServiceFeatureTable serviceFeatureTable = new ServiceFeatureTable(GEOLOGY_FEATURE_SERVICE);

      // create the feature layer using the service feature table
      FeatureLayer featureLayer = new FeatureLayer(serviceFeatureTable);

      SimpleLineSymbol bikeTrailSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.DASH, 0xffff0000, 2.0f);

      SimpleRenderer bikeTrailRenderer = new SimpleRenderer(bikeTrailSymbol);


      featureLayer.setRenderer(bikeTrailRenderer);

      // add the feature layer to the map's operational layers
      map.getOperationalLayers().add(featureLayer);

      // add the map view to stack pane
      stackPane.getChildren().add(mapView);

    } catch (Exception e) {
      // on any error, display stack trace
      e.printStackTrace();
    }
  }

 

If this works fine, then I'd start looking at your WMTS layer to see if that is causing the issue.  There is a WMTS sample here which you can look at.

0 Kudos
MaheshP
Emerging Contributor

@MarkBaird Thanks for your response.

I removed WMTS layer. The above snippet seems to be working. But, my hosted LINE feature layer is not visible yet, even though it is loaded.  I could not figure out what could have gone wrong with feature layer. Is there anything I need to check?

The layer json looks like this:

Display Field: trackid

Type: Feature Layer

Geometry Type: esriGeometryPolyline

Description:

Definition Expression: N/A

Copyright Text:

Default Visibility: true

MaxRecordCount: 4000

Supported Query Formats: JSON, AMF, geoJSON

Min Scale: 0

Max Scale: 0

Supports Advanced Queries: true

Supports Statistics: true

Use Standardized Queries: true

Supports ValidateSQL: true

Supports Calculate: true

Extent:

XMin: NaN
YMin: NaN
XMax: NaN
YMax: NaN
Spatial Reference: 4326 (4326)


Drawing Info:

Renderer:
Simple Renderer:
Symbol:
Style: esriSLSSolid
Color: [135, 70, 31, 255]
Width: 1 Label: N/A
Description: N/A Transparency: 0
Labeling Info:

Advanced Query Capabilities:

Supports Statistics: true
Supports OrderBy: true
Supports Distinct: true
Supports Pagination: true
Supports TrueCurve: true
Supports Returning Query Extent: true
Supports Query With Distance: true
Supports Sql Expression: true
Supports Query With ResultType: true
Supports Returning Geometry Centroid: false


HasZ: true

HasM: false

Time Info:

Start Time Field: currenttime
End Time Field: null
Track ID Field: null
Time Extent: N/A
Time Reference:
Time Zone: India Standard Time
Respects Daylight Saving: false
Time Interval: 10
Time Interval Units: esriTimeUnitsUnknown
Has Live Data: true
Export Options:
Use Time: true
Time Data Cumulative: false
Time Offset: null (null)


Has Attachments: false

HTML Popup Type: esriServerHTMLPopupTypeAsHTMLText

Type ID Field:

0 Kudos
MaheshP
Emerging Contributor

map.PNG

0 Kudos
MarkBaird
Esri Regular Contributor

I can't see a basemap being displayed in your application above.  Are you using a basemap or are you just displaying the feature service on its own?

Would you be able to share your feature service?

0 Kudos
MaheshP
Emerging Contributor

As the feature service is locally hosted, I can not share the service. The code showing the basemap. 

map = new ArcGISMap();

// create a map view and set the map to it
mapView = new MapView();
mapView.setMap(map);

 The same code works for another line feature layer.map_2.PNG

0 Kudos
MarkBaird
Esri Regular Contributor

It's hard for me to diagnose without accessing the service.  For the service which does work, is the spatial reference different to the one which does work?

Not having a basemap I suspect is the cause of the issue.

Looking at the service definition of the service you are having trouble with I can see it is in wgs84 (Spatial Reference: 4326 (4326)). 

I wonder if you initialise the map to the spatial reference which matches the service it might make it work.

ArcGISMap map = new ArcGISMap(SpatialReferences.getWgs84());

 

0 Kudos
MaheshP
Emerging Contributor

Initializing the map with spatial reference did not work. I tried initiliazing the ArcMap with PortalItem. The service which is working and the service which is not, both have the same spatial reference; (4326). Interesting thing is; It used to work initially when I published the service. Is there anything I need to check?

Thanks for your time

0 Kudos
MaheshP
Emerging Contributor

When I query the feature layer, it is showing but goes away when I pan the map

0 Kudos
MarkBaird
Esri Regular Contributor

Without accessing the data its not easy for me to diagnose why this is happening.

If you can't make the service available to me, then its is worth contacting your local distributor (Esri India?), or our tech support to get a reproducer complete with the data.

0 Kudos