Hi, how are you?
I have one pointcollection with 1742863 points, when add it to GraphicsOverlay:
graphicsOverlay.getGraphics().addAll(pointcollection);
The MapView (with resolution 2614x1469) reflect the drawing, but almost seconds later several points (I ignore amount) are removed and not showing.
This has to do with performance and equipment ? I have one equipment with 16gb ram and intel processor i5-7400.
Solved! Go to Solution.
There are 2 rendering modes for graphics overlays. The default is "Dynamic" which gives you a nice user experience when zooming in and out where the symbol size is animated as you change scale. This is however expensive on GPU resources so if you've got almost 2 million graphics you will run out of resources. The other mode is "Static" which I recommend if you have very large numbers of graphics. It doesn't look as nice when you zoom in or out, but it makes better use of our hardware resources.
I've tried this out in a little app I've written just now. In dynamic mode it failed to render all points correctly, but switching to static makes it draw correctly.
private void addLotsOfGraphics() {
// static rendering is best for very large number of graphics
graphicsOverlay = new GraphicsOverlay(GraphicsOverlay.RenderingMode.STATIC);
mapView.getGraphicsOverlays().add(graphicsOverlay);
Collection pointsList = new ArrayList<>();
Random random = new Random();
// using a simple marker symbol and applying this to a renderer for graphics overlay
SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, 0xFF00FF00, 10);
SimpleRenderer simpleRenderer = new SimpleRenderer(simpleMarkerSymbol);
graphicsOverlay.setRenderer(simpleRenderer);
// add lots of graphics in random places
for (int i=1; i<2000000; i++) {
// random point
Point point = new Point(random.nextDouble() * 10000000, random.nextDouble() * 10000000);
Graphic graphic = new Graphic(point);
pointsList.add(graphic);
}
// add the graphics to the graphics overlay
graphicsOverlay.getGraphics().addAll(pointsList);
}
Does this help?
There are 2 rendering modes for graphics overlays. The default is "Dynamic" which gives you a nice user experience when zooming in and out where the symbol size is animated as you change scale. This is however expensive on GPU resources so if you've got almost 2 million graphics you will run out of resources. The other mode is "Static" which I recommend if you have very large numbers of graphics. It doesn't look as nice when you zoom in or out, but it makes better use of our hardware resources.
I've tried this out in a little app I've written just now. In dynamic mode it failed to render all points correctly, but switching to static makes it draw correctly.
private void addLotsOfGraphics() {
// static rendering is best for very large number of graphics
graphicsOverlay = new GraphicsOverlay(GraphicsOverlay.RenderingMode.STATIC);
mapView.getGraphicsOverlays().add(graphicsOverlay);
Collection pointsList = new ArrayList<>();
Random random = new Random();
// using a simple marker symbol and applying this to a renderer for graphics overlay
SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, 0xFF00FF00, 10);
SimpleRenderer simpleRenderer = new SimpleRenderer(simpleMarkerSymbol);
graphicsOverlay.setRenderer(simpleRenderer);
// add lots of graphics in random places
for (int i=1; i<2000000; i++) {
// random point
Point point = new Point(random.nextDouble() * 10000000, random.nextDouble() * 10000000);
Graphic graphic = new Graphic(point);
pointsList.add(graphic);
}
// add the graphics to the graphics overlay
graphicsOverlay.getGraphics().addAll(pointsList);
}
Does this help?
Thanks, works perfectilly. Did not know the rendering modes.