AnsweredAssumed Answered

ArcGIS MapView BackgroundGrid behavior in Java and .NET

Question asked by fuzail8 on Oct 15, 2019
Latest reply on Oct 16, 2019 by fuzail8

I am working on a desktop application and moving from ASP.NET WPF to JavaFX. The application uses ArcGIS SDK to display a MapView which contains a map object in which i add a FeatureLayer which is a shape file (having countries) saved on my system to use offline. Hence i want this application to function properly without internet connectivity. Due to this, i want to customize the MapView and apply colors to it.

In .NET, i simply set MapView.BackgroundGrid to remove grid lines from the MapView and then set it's color to blue to indicate the seas. Then i use the shape FeatureLayer and apply Renderer to it which adds light brown color to the layer's country shapes to indicate lands on the map. The code in .NET goes like this:

        mapView.BackgroundGrid = new BackgroundGrid(Color.LightBlue, Color.White, 0, 1.1f);        string shapeFilePath = "path-to-shape-file";        ShapefileFeatureTable myShapefile = await ShapefileFeatureTable.OpenAsync(shapeFilePath);        FeatureLayer newFeatureLayer = new FeatureLayer(myShapefile)        {            Renderer = new SimpleRenderer()                    { Symbol = new SimpleFillSymbol() { Color = Color.SandyBrown } }        };        mapView.Map = new Map(new Basemap(newFeatureLayer));

This results as:

Now when i follow the same procedure in java, with this code:

        mapView = new MapView();        map = new ArcGISMap();        mapView.setMap(map);         mapView.setBackgroundGrid(new BackgroundGrid(hexLightBlue, hexWhite, 1, 1.1f));         String shapeFilePath = "path-to-shape-file"                ShapefileFeatureTable myShapeFile = new ShapefileFeatureTable(shapeFilePath);        newFeatureLayer = new FeatureLayer(myShapeFile);         mapView.getMap().getOperationalLayers().add(newFeatureLayer);

It results in:

Both implementations are similar. Setting color on BackgroundGrid seems to have a different effect in .NET and Java. It seems fine in .NET but in Java the lands are colored blue instead of the background which doesn't look normal. What am i doing wrong here? How do i get the same results in Java?

Outcomes