Ejemplo n.º 1
0
        /// <summary>
        /// Exports a map with a given MapAlias, width, and height into a stream and returns it.
        /// </summary>
        /// <remarks>The stream containing the map is written to the response and streamed back to the client.</remarks>
        /// <param name="mapAlias">MapAlias of the requested map.</param>
        /// <param name="mapWidth">Width of the map.</param>
        /// <param name="mapHeight">Height of the map.</param>
        /// <param name="exportFormat">Export format to be used to export the map.</param>
        /// <returns>Returns the stream containing the map.</returns>
        public virtual MemoryStream GetMap(string mapAlias, int mapWidth, int mapHeight, string exportFormat)
        {
            Map map = GetMapObj(mapAlias);

            map.Size = new Size(mapWidth, mapHeight);
            ExportFormat ef = (ExportFormat)ExportFormat.Parse(typeof(ExportFormat), exportFormat);

            MemoryStream memStream = null;

            if (map != null)
            {
                MapExport mapExport = new MapExport(map);
                mapExport.ExportSize = new ExportSize(mapWidth, mapHeight);
                memStream            = new MemoryStream();
                mapExport.Format     = ef;
                mapExport.Export(memStream);
                memStream.Position = 0;
                mapExport.Dispose();
            }
            return(memStream);
        }