2-symbol Rendering
The ry is the skeleton of the map, and the graph still needs to be mapped. The ry is another huge topic. We will not expand it here to introduce the symbols and rendering directly. A symbol is a space element. It defines the color, transparency, border size, and other information of points, lines, and surface elements. rendering is a layer and defines the symbol style of the entire layer, the elements apply symbols in batches according to the specified rules.
2.1 symbols
The form of agssymbol can be divided into single, text, and composite symbols.
2.1.1 point symbols
You can set the fill color, outer border, and size of a single agssimplemarkersymbol.
Figure 3-3-2-1 main attributes and methods of agssimplemarkersymbol
Agssimplemarkersymbolstyle: Circle, cross, diamond, square, and X are provided by default.
AGSSimpleMarkerSymbol* myMarkerSymbol = [AGSSimpleMarkerSymbol simpleMarkerSymbol]; myMarkerSymbol.color = [UIColor blueColor]; myMarkerSymbol.style = AGSSimpleMarkerSymbolStyleDiamond; myMarkerSymbol.outline.color = [UIColor whiteColor]; myMarkerSymbol.outline.width = 3;
The agspicturemarkersymbol is filled with a given image. You can set its size, rotation angle, and offset.
Figure 3-3-2-2 main attributes and methods of agspicturemarkersymbol
By default, "the image is pressed on the point", that is, the coordinate corresponds to the pixel center of the image symbol. If you use a pointing icon (such as a dingtalk or bubble ), you need to set an appropriate pixel offset (xoffset/yoffset ).
Agssimplepicturesymbol * mypicturesymbol = [agssimplepicturesymbol values: @”mypic.png "]; // offset five pixels to the upper right: mypicturesymbol. xoffset = 5; mypicturesymbol. xoffset = 5;
2.1.2 linear symbolsA single line symbol (agssimplelinesymbol) is used to modify the color, width, and style. The default style includes: Dash, dot, and dashdot) and solid.
Figure 3-3-2-3 main attributes and methods of agssimplelinesymbol
Agssimplefillsymbol * myfillsymbol = [agssimplefillsymbol simplefillsymbol]; myfillsymbol. color = [uicolor colorwithred: 0.7 Green: 0.1 Blue: 0.1 ALPHA: 0.5]; // The Line border or "line" agssimplelinesymbol * myoutlinesymbol = [Symbol simplelinesymbol]; myoutlinesymbol. color = [uicolor redcolor]; myoutlinesymbol. width = 2; // set the outline property to myoutlinesymbol myfillsymbol. outline = myoutlinesymbol;
2.1.3 area symbolThe area symbols include the single fill symbol (agssimplefillsymbol) and the image fill symbol (agspicturefillsymbol). The attributes are similar to the point symbol, and the image fill symbol can set the display ratio: XScale \ yscale.
Agssimplefillsymbol * myfillsymbol = [agssimplefillsymbol simplefillsymbol]; myfillsymbol. color = [uicolorcolorwithred: 0.7 Green: 0.1 Blue: 0.1 ALPHA: 0.5]; // the outer contour agssimplelinesymbol * myoutlinesymbol = [inclusimplelinesymbol]; myoutlinesymbol. color = [uicolorredcolor]; myoutlinesymbol. width = 2; myfillsymbol. outline = myoutlinesymbol;
2.1.4 text symbolsAgstextsymbol can be used in any geometric shape. It is generally used as a label. The default font is the system font. You can set the font color, size, and width. To display the value of an attribute field, use texttemplate directly, for example, $ {country_name}, where country_name is the attribute field name.
Figure 3-3-2-4 main attributes and methods of agstextsymbol
Agstextsymbol * txtsymbol = [agstextsymboltextsymbolwithtexttemplate: @ "text" color: [uicolor greencolor];
txtSymbol.xoffset = -30.; txtSymbol.yoffset = 30.; txtSymbol.backgroundColor = [UIColor whiteColor]; txtSymbol.fontSize = 20.;
2.1.5 compound symbolsCompositesymbol is a symbolic component of the geometric shape to meet special requirements. It has two types: agscompositesymbol and agscompositelinesymbol ).
You can add a node symbol to the surface composite symbol to highlight the nodes.
A series of line symbols are added to the line composite symbol to show the effect of the gradient line.
In fact, a composite symbol is used when the sketch layer (agssketchlayer) shows each node (endpoint and edge midpoint) of the selected element.
2.2 RenderingRendering (renderers) is a symbolic style of a layer, which is batch signed according to the attribute values of elements in the layer. It is worth noting that the symbolic and geometric shapes in the rendering style correspond to the point rendering point data, linear rendering line data, and surface symbol corresponding area data.
Figure 3-3-2-5 inheritance relationship of agsrenderer
2.2.1 single RenderingA single rendering (agssimplerenderer) is to render all elements with a symbol, which can be any of the following: point, line, surface, text or compound.
The symbolic attributes are read-only. If you change the attributes, You need to recreate a single rendering style.
// Construct the composite symbol agscompositesymbol * Composite = [agscompositesymbol compositesymbol]; agssimplemarkersymbol * markersymbol = [[[agssimplemarkersymbol alloc] init] autorelease. style = agssimplemarkersymbolstylesquare; markersymbol. color = [uicolor greencolor]; [composite. symbolsaddobject: markersymbol]; agssimplelinesymbol * linesymbol = [[[agssimplelinesymbol alloc] init] autorelease]; linesymbol. color = [uicolor graycolor]; linesymbol. width = 4; [composite. symbolsaddobject: linesymbol]; agssimplefillsymbol * fillsymbol = [[[agssimplefillsymbol alloc] init] autorelease]; fillsymbol. color = [uicolor colorwithred: 1.0 Green: 1.0 Blue: 0 ALPHA: 0.5]; [composite. symbolsaddobject: fillsymbol]; // directly render agssimplerenderer * Renderer = [agssimplerenderer ready: Composite]; agsgraphiclayer * graphicslayer = [agsgraphiclayer graphiclayer]; graphicslayer. renderer = Renderer;
2.2.2 hierarchical RenderingHierarchical rendering (agsclassbreaksrenderer) classifies all elements according to numerical attributes, and each level of elements uses the same symbol. Each level of Numerical range and symbol is a segmentation (agsclassbreak). The elements falling within the value range are rendered according to the corresponding symbol. For example, a batch of hourly average rainfall sample data is displayed with three symbols, namely light rain, moderate rain, and heavy rain, based on the demarcation between 5mm and 30mm. This is a typical hierarchical rendering style.
Agsclassbreaksrenderer * rainrenderer = [[agsclassbreaksrenderer alloc] init] autorelender]; rainrenderer. field = @ "day"; // Classification Section agsclassbreak * lowclassbreak = [agsclassbreakclassbreakinfowithlabel: @ "low" Description: @ "" maxvalue: 5 Symbol: lowmarkersymbol]; agsclassbreak * mediumclassbreak = [Signature: @ "medium" Description: @ "" maxvalue: 30 Symbol: mediummarkersymbol]; agsclassbreak * highclassbreak = [Signature: @ "high" Description: @ "" minvalue: 30 Symbol: highmarkersymbol]; // Add it to the classification Array Using * classbreaks = [hierarchical array]; [classbreaks addobject: lowclassbreak]; [classbreaks addobject: mediumclassbreak [classbreaks addobject: highclassbreak]; rainrenderer. classbreaks = classbreaks; // hierarchical rendering agsgraphiclayer * graphicslayer = [agsgraphiclayer graphiclayer]; graphicslayer. renderer = rainrenderer;
2.2.3 unique value RenderingAgsuniquevaluerenderer (agsuniqueverenderer) is suitable for symbolic by non-numeric attributes. Each group of unique values (agsuniquevalue) includes values, tags, symbols, and so on. For example, a typical poi point of interest is symbolic Based on catering, hotel, and entertainment, which is a typical unique value rendering.
Agsuniquevaluerenderer * poirenderer = [[agsuniquevaluerenderer alloc] init] autorelender]; // default symbol and comparison field poirenderer. defaultsymbol = defamamakersymbol; poirenderer. field1 = @ "type"; // set the unique value agsuniquevalue * Food = [[agsuniquevalue alloc] initwithvalue: @ "food" label: @ "food" Description: Nil symbol: foodsymbol]; agsuniquevalue * Hotel = [[agsuniquevalloc] initwithvalue: @ "hotel" label: @ "hotel" Description: Nil Symbol: Symbol symbol]; agsuniquevalue * entertainment = [[agsuniquevalue alloc] initwithvalue: @ "Entertainment" label: @ "Entertainment" Description: Nil Symbol: entertainmentsymbol]; [poirenderer. uniquevalues addobject: Food]; [poirenderer. uniquevalues addobject: Hotel]; [poirenderer. uniquevalues addobject: Entertainment]; // unique value rendering agsgraphiclayer * graphicslayer = [agsgraphiclayer graphiclayer]; graphicslayer. renderer = poirenderer;
2.2.4 temporal RenderingAgstemporalrenderer is used to represent element layers with temporal information, including the default rendering style (observation Renderer) and interpolator ). The rendering style is a common single, hierarchical, and unique value rendering. It is related to the time, and determines the symbol size and color of a certain time point or time period, there are two kinds of interpolation devices: ramp interpolator and timeclassbreaksager ).
The gradient interval interpolation device defines the color start/end value and size start/end value of a symbol to display continuous time features.
Figure 3-3-2-6 use the ramp interpolator rendering Element
AGSFeatureLayer* featLayer = ...; //ObservationrendererAGSSimpleMarkerSymbol* pointSymbol = [[[AGSSimpleMarkerSymbol alloc] init] autorelease]; pointSymbol.style = AGSSimpleMarkerSymbolStyleSquare; pointSymbol.size = 6; pointSymbol.color = [UIColor blackColor]; AGSSimpleRenderer* obsRenderer = [AGSSimpleRenderer simpleRendererWithSymbol:pointSymbol]; //Color range UIColor*startCol = [UIColor redColor]; UIColor* endCol= [UIColor yellowColor]; //Size rangeint startSize = 20;int endSize = 2; //A rampinterpolator using the color and size rangeAGSRampInterpolator* ramp = [[AGSRampInterpolatoralloc] initWithStartColor:startCol endColor:endCol startSize:startSizeendSize:endSize]; //A temporalrendererAGSTemporalRenderer* temporalRenderer =[[AGSTemporalRenderer alloc] initWithObservationRenderer:obsRendererobservationAger:ramp featureLayer:featLayer];featLayer.renderer = temporalRenderer;
The time grading includes a group of time grading segments agstimeclassbreak, each of which defines the symbol size, color, and length (maxrelativeage ).
Figure 3-3-2-7 use time-based hierarchical Rendering
//A time-awarefeature layerAGSFeatureLayer* featLayer = ...; //An array tohold the class breaksNSMutableArray* classBreaks = [[[NSMutableArray alloc] init] autorelease]; //Class breakfor features upto 2 days oldAGSTimeClassBreak* tcb = [[[AGSTimeClassBreak alloc] init] autorelease]; tcb.maxRelativeAge = 2; tcb.size = 8; tcb.color = [UIColor whiteColor]; [classBreaks addObject:tcb]; //Class breakfor features upto 5 days oldtcb = [[[AGSTimeClassBreak alloc] init] autorelease]; tcb.maxRelativeAge = 5; tcb.size = 5; tcb.color = [UIColor blueColor]; [classBreaks addObject:tcb]; //Class breakfor features upto 12 days oldtcb = [[[AGSTimeClassBreak alloc] init] autorelease]; tcb.maxRelativeAge = 12; tcb.size = 3; tcb.color = [UIColor redColor]; [classBreaks addObject:tcb]; //A classbreaks ager based on the class breaks defined aboveAGSTimeClassBreaksAger *classbreaksAger = [[AGSTimeClassBreaksAger alloc] initWithTimeClassBreaks:classBreaks units:AGSTimeIntervalUnitsDays]; //ObservationrendererAGSSimpleMarkerSymbol* pointSymbol = [[[AGSSimpleMarkerSymbol alloc] init] autorelease]; pointSymbol.style = AGSSimpleMarkerSymbolStyleCircle; pointSymbol.size = 2; pointSymbol.color = [UIColor blackColor]; AGSSimpleRenderer* obsRenderer = [AGSSimpleRenderer simpleRendererWithSymbol:pointSymbol]; //Temporal renderer AGSTemporalRenderer* temporalRenderer = [[AGSTemporalRenderer alloc] initWithObservationRenderer:obsRenderer observationAger:classbreaksAger featureLayer:featLayer]; featLayer.renderer = temporalRenderer;
3. Property InformationAttribute information of a spatial element is loaded in a key-Value Pair (field name and content), which is usually obtained directly from an existing element or a new nsdictionary is constructed by yourself.
// Obtain the existing element attribute agsgraphic * mygraphic = [agsgraphic graphicwithgeometry: mymarkerpoint Symbol: mymarkersymbol attributes: feature. attributes: Nil]; // construct attributes nsmutabledictionary * attributes = [nsmutabledictionary dictionary]; [attributes setobject: Region forkey: @ "region"]; [attributes setobject: magnworkflow forkey: @ "Magn"]; [attributes setobject: Depth forkey: @ "depth"]; agsgraphic * mygraphic = [agsgraphic graphicwithgeometry: mymarkerpoint Symbol: mymarkersymbol attributes: feature. attributesinfotemplatedelegate: Self];
The infotemplatedelegate in the Code declares the display content of the attribute information in the pop-up box, which will be detailed in the "Information Window" section.