This work is borrowed and modified from Edwin van Rijkom. The modifications include the generation of
Geometrysubclasses based on the Flex API for ArcGIS Server.
So, to get started, I created a
ShpLayerclass that is a subclass of
GraphicsLayer. I initialized this layer's
symbolproperty with an instance of
ShpSymbolwhich is my own custom symbol (more on this later). This way, I do not have to assign a symbol to each added
Graphicinstance. Internally, when a graphic is rendered, and that graphic has a null symbol property, it inherits its parent's symbol property value. This is an easy way to globally change the symbology of a graphic layer, without having to explicitly iterate through all its children :-)
The fact that I've created my own custom symbol is yet another demonstration of the extensibility of the API to render a
Graphicin any which way I seem fit. This was easily done by overriding the
In this example, I'm filling and outlining a polygon. In addition, I'm annotating the polygon with its label property and locating that annotation at its label X/Y property values.
The embedding of the shapefile (shp and dbf) in the application is accomplished by the following statement (Note the mimeType):
private var m_shpClass : Class;
private var m_dbfClass : Class;
I've overridden the
createChildrenprotected function to load into a byte array the shp and dbf content from which I created a
DbfHeader. I then iterated over each feature to create a
Graphicinstance which I pushed onto an array. At the end of the iteration, the array was converted to an
ArrayCollectionthat became the layer's graphic provider. Here is the application in action, and like usual you can download the source from here.
One more gem. Note how I created my own subclass of
Map, where I've overridden the
updateDisplayListprotected function to create a nice gradient filled background.