Solved! Go to Solution.
The wrinkle here is that I am receiving the data from an external source as it is read from various sensors. It is not coming from ArcGIS Server or from any mapping service. It sounds as though I need a custom subclass of AGSDynamicLayer that renders the density representation one way or another. Is that reasonable?
... Does the layer ask its renderer for a visual representation of each AGSGraphic? Does the visual representation of a graphic always end up being a swatch/image?
If I understand your desired workflow correctly, you want to switch from discrete graphics to a density representation at a certain scale.
You should be able to accomplish this by having two services; one feature service that returns the discrete graphics and one dynamic or tiled service that returns the density map. You can switch between displaying one or the other once you cross your scale threshold.
You might also explore clustering algorithms. I've poked around with writing a k-means clustering kit for the ArcGIS Runtime SDK. This clustering library also has a good example of a more basic algorithm that could be ported over fairly easily.
The wrinkle here is that I am receiving the data from an external source as it is read from various sensors. It is not coming from ArcGIS Server or from any mapping service. It sounds as though I need a custom subclass of AGSDynamicLayer that renders the density representation one way or another. Is that reasonable?
My two cents is that the subclass you are thinking of will have to work against some of the basic conventions/architectural choices of the SDK and that you want to either:
- Figure out a clustering algorithm that will allow you to represent graphics in aggregate at larger scales. This does not get you a true density map but will allow the user to view clusters of graphics at larger scales.
- Figure out a way to feed your external map service into an ESRI service. Assuming, of course, that you have the license to set up and use such a service.
What I have tried thus far does seem to be going against the grain. My proof of concept uses an instance of CALayer that I create and add as a sub-layer of the CAEAGLLayer used by AGSMapView. The behavior is quite poor due to the high latency on state change notifications from the AGSMapView object. My custom layer always lags way behind during panning and zooming. My real goal is to use an OpenGL texture to provide the visualization, but that would still have the same zooming and panning problems that I have with my trivial CALayer usage. I get the feeling that some sort of low level drawing hook into the CAEAGLLayer of the map view is what I would need to get the best results, but I do not see a way to make that happen.