[mapguide-users] MaestroAPI 4 and MGOS 2.2 - empty/blank/transparent map

Hans Milling hm at geograf.dk
Fri Dec 2 07:59:34 EST 2011


Hi, I am trying one of the samples from the MapGuide API 4.0 website.

Using MGOS 2.2 I have set up a simple map with a sigel layer based on a
MapInfo tab/ind/map/dat files.

Using MapGuide Maestro 3.5 (And 4.0 RC1) I can see the layer and map, no
problems and no validation errors.

But when I run the following sample code that just saves the map as a PNG
image, the image is just a transparent blank image but with the correct
with/height. Does anyone have any clue what I am missing?



			        Uri host = new
Uri("http://msvm/mapguide/mapagent/mapagent.fcgi");

			        IServerConnection conn =
ConnectionProviderRegistry.CreateConnection("Maestro.Http",
"Url", host.ToString(), "Username",
"Administrator", "Password", "admin");

			        IMappingService mapSvc =
(IMappingService)conn.GetService((int)ServiceType.Mapping);

			        ResourceIdentifier resId = new
ResourceIdentifier("Library://Test/MyMap.MapDefinition");

			        IMapDefinition mdf =
(IMapDefinition)conn.ResourceService.GetResource(resId);

			        double metersPerUnit = 1.0;

			/*      if (!string.IsNullOrEmpty(mdf.CoordinateSystem))

			        {

			          MgCoordinateSystemFactory factory =
new MgCoordinateSystemFactory(); // <-- This Throws a target of an
invocation exception, but never mind

			          MgCoordinateSystem cs =
factory.Create(mdf.CoordinateSystem);

			          metersPerUnit =
cs.ConvertCoordinateSystemUnitsToMeters(1.0);

			        }*/

			        ResourceIdentifier rtMapId = new
ResourceIdentifier(resId.Name, ResourceTypes.RuntimeMap,
conn.SessionID); 

			        RuntimeMap map = mapSvc.CreateMap(rtMapId,
mdf, metersPerUnit); 

			        map.DisplayWidth = 640;

			        map.DisplayHeight = 480;

			        map.DisplayDpi = 96;

			        map.BackgroundColor = Color.White;

			        map.DataExtent =
ObjectFactory.CreateEnvelope(505468, 6276258, 539925, 6320454);

			        map.Save();

			        

			        byte[] buf = new byte[1024];

			        using (Stream stream =
mapSvc.RenderDynamicOverlay(map, null, "PNG"))

			        {

			          using (var fs = new
FileStream("RenderMap.png", FileMode.OpenOrCreate))

			          {

			            int read = 0;

			            do

			            {

			              read = stream.Read(buf,
0, buf.Length);

			              fs.Write(buf, 0, read);

			            } while (read > 0);

			          }

			        }


Regards Hans Milling...

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/MaestroAPI-4-and-MGOS-2-2-empty-blank-transparent-map-tp7054607p7054607.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20111202/e2de5b71/attachment.html


More information about the mapguide-users mailing list