private Point GetRectangleCenter(Map map, MapDecorationAnchor anchor)
        {
            var coords = GetRectanglePoints(map, anchor);

            return(new Point((coords[0].X + coords[1].X) / 2.0,
                             (coords[0].Y + coords[2].Y) / 2.0));
        }
        private static Coordinate[] GetRectanglePoints(Map map, MapDecorationAnchor anchor)
        {
            var env = map.Envelope;

            env.ExpandBy(-env.Width * 0.05);

            var coords = new Coordinate[5];

            Coordinate tl = null;

            switch (anchor)
            {
            case MapDecorationAnchor.LeftTop:
                tl = env.TopLeft();
                break;

            case MapDecorationAnchor.LeftCenter:
                tl = new Coordinate(env.MinX, env.MaxY - env.Height * 0.375);
                break;

            case MapDecorationAnchor.LeftBottom:
                tl = new Coordinate(env.MinX, env.MinY + env.Height * 0.25);
                break;

            case MapDecorationAnchor.CenterTop:
                tl = new Coordinate(env.Centre.X - env.Width * 0.125, env.MaxY);
                break;

            case MapDecorationAnchor.CenterBottom:
                tl = new Coordinate(env.Centre.X - env.Width * 0.125, env.MinY + env.Height * 0.25);
                break;

            case MapDecorationAnchor.RightTop:
                tl = new Coordinate(env.MaxX - env.Width * 0.25, env.MaxY);
                break;

            case MapDecorationAnchor.RightCenter:
                tl = new Coordinate(env.MaxX - env.Width * 0.25, env.MaxY - env.Height * 0.375);
                break;

            case MapDecorationAnchor.RightBottom:
                tl = new Coordinate(env.MaxX - env.Width * 0.25, env.MinY + env.Height * 0.25);
                break;

            default:
                tl = new Coordinate(env.Centre.X - env.Width * 0.125, env.Centre.Y + env.Height * 0.125);
                break;
            }

            coords[0] = tl;
            coords[1] = new Coordinate(tl.X + env.Width * 0.25, coords[0].Y);
            coords[2] = new Coordinate(coords[1].X, tl.Y - env.Height * 0.25);
            coords[3] = new Coordinate(coords[0].X, coords[2].Y);
            coords[4] = tl;

            return(coords);
        }