This project has moved and is read-only. For the latest updates, please go here.


Feb 16, 2015 at 2:47 PM

First of all, I really like your library, saves me a lot of time!

There is only one thing I don't get to work: StyleMaps

I need to create this code:
        <StyleMap id="msn_placemark_circle">
I try to achieve this in C#, but I can't get that result. Here's what I have:
        public static StyleSelector Generate_M_ylw_pushpin3()
            var stylemap = new StyleMapCollection();
            stylemap.Id = "s_ylw-pushpin3";
            var normalPair = new Pair();
            normalPair.Id = "normal";
            normalPair.Selector = StyleGenerator.Generate_s_ylw_pushpin_hl3();
            //normalPair.StyleUrl = new Uri(styleUrl_s_ylw_pushpin3);

            var highlightPair = new Pair();
            highlightPair.Id = "highlight";
            highlightPair.Selector = StyleGenerator.Generate_s_ylw_pushpin_hl3();
            //highlightPair.StyleUrl = new Uri(styleUrl_s_ylw_pushpin_hl3);


            return stylemap;
As you can see I am struggling on how to get things right. The things I'd like to know is:

1) How to generate the 'Key' node, with a value of 'normal' or 'highlight'
2) How to put '#some_url' into the 'styleUrl' tag. When I use 'new Uri("#some_url")' I get an C# exception...

I really hope you can help me further, this is the last thing I need to fix :)


Feb 16, 2015 at 5:31 PM
Finally, I've got everything to work. To answer my own questions...

1) To generate the 'Key' node, use styleMap.State. State is an enum of type 'StyleState' with two values 'Normal' and 'Highlight';
2) This came down to some C# I didn't know. Use 'new Uri("#some_id", UriKind.Relative)' to use a hash value.

Marked as answer by samcragg on 2/17/2015 at 11:46 PM
Feb 18, 2015 at 7:46 AM
Sorry about the late reply but looks like you've solved it on your own :)

First of all thanks for using the library and posting the anwser for others to benefit from.

Just little explanation of why you need a uri for the StyleUrl is because I believe it could refere to an external style (e.g. hosted on a website); by using the # syntax it referes to a style declared in the same document, however, the Uri constructor needs a little help determining the type of URI you've given it, hence the need to call the overloaded constructor taking the UriKind.Relative in it.

I know they're not the easiest things to discover but I think there is an example of creating the URI in the CreateIconStyle example.

Thanks again,