Marchinin added the answer to his question, which was surprising and helped me get to my decision. Just for the alternative, which, in my opinion, is a little more general, I decided that I would leave my decision, which I received thanks to Martigine's answer.Note: my solution generates them to create a string object, however this can be easily used for other styles.
. , ,
( , ..) , . :
kmlDom.Style normalStyle = createPlacemarkLineStyle(thisPlacemark, false);
kmlDom.Style highlightStyle = createPlacemarkLineStyle(thisPlacemark, true);
:
public kmlDom.Style createPlacemarkLineStyle ( kmlDom.Placemark placemark , bool highlight )
{
kmlDom.Style styleNode = new kmlDom.Style( );
kmlDom.LineStyle lineStyle = new kmlDom.LineStyle( );
if( !highlight )
{
styleNode.Id = String.Format( "{0}-normal", placemark.placemarkName );
lineStyle.Color = hexToColor("ff0000ff");
lineStyle.Width = 2;
}
else
{
styleNode.Id = String.Format( "{0}-highlight", placemark.placemarkName );
lineStyle.Color = hexToColor( "ff0000ff" );
lineStyle.Width = 2;
}
styleNode.Line = lineStyle;
return styleNode;
}
,
, . , :
thisPlacemark.StyleSelector = createPlacemarkLineStyleMap(placemark, normalStyle, highlightStyle);
:
public kmlDom.StyleSelector createPlacemarkLineStyleMap ( kmlDom.Placemark placemark , kmlDom.Style normalStyle , kmlDom.Style highlightStyle )
{
kmlDom.StyleMapCollection styleMapCollection = new kmlDom.StyleMapCollection( );
styleMapCollection.Id = String.Format( "{0}-stylemap" , placemark.placemarkName );
kmlDom.Pair normalPair = new kmlDom.Pair();
normalPair.StyleUrl = new Uri(String.Format("#{0}", normalStyle.Id), UriKind.Relative);
normalPair.State = kmlDom.StyleState.Normal;
kmlDom.Pair highlightPair = new kmlDom.Pair( );
highlightPair.StyleUrl = new Uri( String.Format( "#{0}" , highlightStyle.Id ) , UriKind.Relative );
highlightPair.State = kmlDom.StyleState.Highlight;
styleMapCollection.Add( normalPair);
styleMapCollection.Add( highlightPair );
return styleMapCollection;
}
kmlDom, kmlBase kmlEngine
** , sharpkml .
using kmlBase = SharpKml.Base;
using kmlDom = SharpKml.Dom;
using kmlEngine = SharpKml.Engine;