static MapLayer()
        {
            layerParsers = new Dictionary <string, LayerParser>();

            // register layer types
            ValueMapLayer16.Register();
            ColorMapLayer.Register();
        }
        protected static MapLayer ParseLayer(WorldMap map, XmlReader r)
        {
            string layerName = null;
            int metersPerTile = 0;
            int metersPerSample = 0;
            float red = 0;
            float green = 0;
            float blue = 0;
            float alpha = 0;

            // parse attributes
            for (int i = 0; i < r.AttributeCount; i++)
            {
                r.MoveToAttribute(i);

                // set the field in this object based on the element we just read
                switch (r.Name)
                {
                    case "Type":
                        break;
                    case "Name":
                        layerName = r.Value;
                        break;
                    case "MetersPerTile":
                        metersPerTile = int.Parse(r.Value);
                        break;
                    case "MetersPerSample":
                        metersPerSample = int.Parse(r.Value);
                        break;
                    case "DefaultColorR":
                        red = float.Parse(r.Value);
                        break;
                    case "DefaultColorG":
                        green = float.Parse(r.Value);
                        break;
                    case "DefaultColorB":
                        blue = float.Parse(r.Value);
                        break;
                    case "DefaultColorA":
                        alpha = float.Parse(r.Value);
                        break;

                }
            }

            r.MoveToElement(); //Moves the reader back to the element node.

            MapLayer layer = new ColorMapLayer(map, layerName, metersPerTile, metersPerSample, new ColorEx(alpha, red, green, blue));

            if (!r.IsEmptyElement)
            {
                // now parse the sub-elements
                while (r.Read())
                {
                    // look for the start of an element
                    if (r.NodeType == XmlNodeType.Element)
                    {
                        // parse that element
                        // save the name of the element
                        string elementName = r.Name;
                        switch (elementName)
                        {
                            case "Property":
                                layer.Properties.ParseProperty(r);
                                break;
                        }
                    }
                    else if (r.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }
                }
            }

            return layer;
        }
        protected static MapLayer ParseLayer(WorldMap map, XmlReader r)
        {
            string layerName       = null;
            int    metersPerTile   = 0;
            int    metersPerSample = 0;
            float  red             = 0;
            float  green           = 0;
            float  blue            = 0;
            float  alpha           = 0;

            // parse attributes
            for (int i = 0; i < r.AttributeCount; i++)
            {
                r.MoveToAttribute(i);

                // set the field in this object based on the element we just read
                switch (r.Name)
                {
                case "Type":
                    break;

                case "Name":
                    layerName = r.Value;
                    break;

                case "MetersPerTile":
                    metersPerTile = int.Parse(r.Value);
                    break;

                case "MetersPerSample":
                    metersPerSample = int.Parse(r.Value);
                    break;

                case "DefaultColorR":
                    red = float.Parse(r.Value);
                    break;

                case "DefaultColorG":
                    green = float.Parse(r.Value);
                    break;

                case "DefaultColorB":
                    blue = float.Parse(r.Value);
                    break;

                case "DefaultColorA":
                    alpha = float.Parse(r.Value);
                    break;
                }
            }

            r.MoveToElement(); //Moves the reader back to the element node.

            MapLayer layer = new ColorMapLayer(map, layerName, metersPerTile, metersPerSample, new ColorEx(alpha, red, green, blue));

            if (!r.IsEmptyElement)
            {
                // now parse the sub-elements
                while (r.Read())
                {
                    // look for the start of an element
                    if (r.NodeType == XmlNodeType.Element)
                    {
                        // parse that element
                        // save the name of the element
                        string elementName = r.Name;
                        switch (elementName)
                        {
                        case "Property":
                            layer.Properties.ParseProperty(r);
                            break;
                        }
                    }
                    else if (r.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }
                }
            }

            return(layer);
        }