This idea came up when I had to create a viewer containing a map, and also a (pie) chart based on data from a polygon layer. (Charts are built using a 3rd party library, Highcharts)
One requirement was that the pie sections of the chart had the same fill symbols as the layer. This is easy to do when the symbology is a solid symbol, I can parse the renderer definition and retrieve the correct colors. However, if the symbology is more advanced, e.g. a hatch symbol, or even an image, things get complicated.
I then thought of making a request to https://example.com/arcgis/rest/services/MyService/MapServer/legend?f=json get the images from the response, and use those as a tiled background for the pie sections. This kind of works, but there are two drawbacks:
- The resulting images have a 1 pixel border that I need to get rid off when the image repeats
- The size of the images needs to match the repeating interval of the used symbol. For instance, if the symbol is a simple dot, that repeats every 10 pixels, the image size needs to be a multiple of 10.
My idea is therefore:
- Add an option to the /legend REST endpoint that removes the border of the image
- Add an option to calculate the size of the image based on the pattern repeat interval (where horizontal en vertical interval can differ)