Changes between Version 2 and Version 3 of maestro/MaestroAPI/samples/CustomizedZoomWithWebLayout


Ignore:
Timestamp:
Mar 12, 2009, 5:20:40 AM (15 years ago)
Author:
ksgeograf
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • maestro/MaestroAPI/samples/CustomizedZoomWithWebLayout

    v2 v3  
    4545Response.Redirect("/mapguide/ajaxviewer/?LAYOUT=" & Server.UrlEncode(tempWebLayout) & "&SESSION=" &  Server.UrlEncode(con.SessionID), true)
    4646}}}
     47
     48(C#)
     49{{{
     50import OSGeo.MapGuide.MaestroAPI;
     51...
     52
     53//Read the setup, either from QueryString, Form, Cookies or hardcoded values
     54string username As = Request.Params("USERNAME") == null ? "Anonymous" : Request.Params("USERNAME");
     55string password = Request.Params("PASSWORD") == null ? "" : Request.Params("PASSWORD");
     56string layout = Request.Params("LAYOUT") == null ? "Library://MyLayout.WebLayout" : Request.Params("LAYOUT");
     57string locale = Request.Params("LOCALE") == null ? "en" : Request.Params("LOCALE");
     58
     59
     60//Setup connection
     61Uri host = new Uri("http://localhost/mapguide/mapagent/mapagent.fcgi");
     62ServerConnectionI conn = new HttpServerConnection(host, username , password, locale, True);
     63
     64'Obtain the weblayout and map
     65WebLayout weblayout = con.GetWebLayout(layout);
     66MapDefinition mapdefinition = con.GetMapDefinition(weblayout.Map.ResourceId);
     67
     68//Modify the initial view of the weblayout
     69weblayout.Map.InitialView = new MapViewType();
     70weblayout.Map.InitialView.Scale = 2000 //Zoom to 1:2000
     71weblayout.Map.InitialView.CenterX = (mapdefinition.Extents.MaxX - mapdefinition.Extents.MinX) + mapdefinition.Extents.MinX;
     72weblayout.Map.InitialView.CenterY = (mapdefinition.Extents.MaxY - mapdefinition.Extents.MinX) + mapdefinition.Extents.MinY;
     73
     74//Obtain a unique session based id for the temporary weblayout (which is a copy of an existing WebLayout)
     75ResourceIdentifier tempid = new ResourceIdentifier(Guid.NewGuid(), OSGeo.MapGuide.MaestroAPI.ResourceTypes.WebLayout, con.SessionID);
     76
     77//Save the layout, otherwise you can't reference it
     78con.SaveResourceAs(weblayout, tempid);
     79
     80//Open the viewer, and use the temporary layout, since the map only exists in the
     81//current session, we must use that session, and NOT supply username/password
     82Response.Redirect("/mapguide/ajaxviewer/?LAYOUT=" + Server.UrlEncode(tempWebLayout) + "&SESSION=" +  Server.UrlEncode(con.SessionID), true);
     83}}}