[mapguide-users] Help

Lasly Genoese Puntodoc Srl lasly.genoese at puntodoc.net
Fri Jan 15 10:43:46 EST 2010


 
 
 
Hello, I am new to MapGuide. I've just started using open source MapGuide 2.1, but I did not even run the examples (C #) of the guide. possible?
I have too many problems (I do not work nothing) also asking for help.
For example map.open generates exception: Resource was not found
Then I used the map.create without exception (with map Sheboygan) and try to do the exercise to change the visibility of layers. The code goes, but video layers do not change.
Where can I find (or can you given me) a simple example ( or project  for Visual Studio 2008 c#) that works?

Thanks so much! (forgive my English!)
 
Le.

this is my code:
 
Page 1:
 
<%@ Page language="c#" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Collections.Specialized" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Globalization" %>
<%@ Import Namespace="OSGeo.MapGuide" %>
 
 
 
<%
        String sessionId = "";
        String webLayout = "Library%3a%2f%2fSamples%2fSheboygan%2fLayouts%2fSheboyganAsp.WebLayout";
    try
    {
        
        // Initialize a session and register a variable to hold the
        // session id, then initialize the Web Extensions, connect
        // to the site, and create a session.
 
        // Initialize Web Server Extensions.
        String realPath = Request.ServerVariables["APPL_PHYSICAL_PATH"];
        String configPath = realPath + "..\\webconfig.ini";
        MapGuideApi.MgInitializeWebTier(configPath);
 
        // Connect to the site.
        MgUserInformation userInfo = new MgUserInformation("Administrator", "admin");
        MgSite site = new MgSite();
        site.Open(userInfo);
 
            // Create a session
        sessionId = site.CreateSession();     
 
    }
    catch (Exception e)
    {
        Response.Write(e.Message);
    }
 
    Response.Redirect("InformationMap.aspx?SESSION=" + sessionId);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>HelloWorld</title>
</head>
 
<frameset rows="0,*" border="0" framespacing="0">
  <frame />
  <frame src="/mapguide/mapviewernet/ajaxviewer.aspx?SESSION=<%= sessionId %>&WEBLAYOUT=<%= webLayout %>" name="ViewerFrame" />
</frameset>
 
</html>  
 
 
Page 2:
<%@ Page Language="c#" %>
 
<%@ Import Namespace="OSGeo.MapGuide" %>
 
<%
    String MgSessionId = "";
   
    String webLayout = "Library%3a%2f%2fSamples%2fSheboygan%2fLayouts%2fSheboyganAsp.WebLayout";
    
    try
    {
 
     MgSessionId = Request.QueryString["SESSION"];  
 
       
 
        // Initialize Web Server Extensions.
        String realPath = Request.ServerVariables["APPL_PHYSICAL_PATH"];
        String configPath = realPath + "..\\webconfig.ini";
        MapGuideApi.MgInitializeWebTier(configPath);
 
        MgUserInformation userInfo = new MgUserInformation(MgSessionId);
 
 
        MgSiteConnection siteConnection = new MgSiteConnection();
 
        siteConnection.Open(userInfo);
 
        MgResourceService resourceService = siteConnection.CreateService(MgServiceType.ResourceService) as MgResourceService;
 
        MgResourceIdentifier mapDefid = new MgResourceIdentifier("Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition");
 
        MgMap map = new MgMap();
 
       
 
      map.Create(resourceService, mapDefid, "Sheboygan");
 
 
      // Exception!!! -.-'    
       // map.Open(resourceService, "Sheboygan");
       // map.Open("Sheboygan");
      //  map.Open(resourceService, mapDefid);
 
 
        MgEnvelope envelope = map.GetMapExtent();
 
 
        Double lowerX = envelope.GetLowerLeftCoordinate().GetX();
        Double lowerY = envelope.GetLowerLeftCoordinate().GetY();
 
        String mapname = map.GetName();
 
 
 
        MgLayerCollection layerCol = map.GetLayers();
        MgLayer layer = null;
 
        String layerName = "";
 
 
        for (int i = 0; i < layerCol.GetCount(); i++)
        {
            layer = (MgLayer)layerCol.GetItem(i);
            layerName = layer.GetName();
           
        }
 
 
        layer = (MgLayer)layerCol.GetItem("Districts");
 
    
 
        MgLayerGroup gruppo = layer.GetGroup();
 
 
        gruppo.SetLegendLabel("cambiata");
 
       // gruppo.SetDisplayInLegend(false);
 
 
        //if (layer.IsVisible())
       // {
            layer.SetVisible(false);
            
       // }
      //  else
      //  {
       //     layer.SetVisible(true);
    //    }
 
//try
        layer.ForceRefresh();
//try
 
        layer.NeedsRefresh();
    }
 
    catch (Exception e)
    {
        Response.Write(e.Message);
    }
    
    
 
        
%>
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>MapGuide Developer's Guide ASP.NET Samples</title>
</head>
 
<frameset rows="80,*" frameborder="no" framespacing="0">
      <frame id="titleFrame" frameborder="no" marginwidth="0" marginheight="0" scrolling="no" src="common/title.html">
      
<frame id="viewerFrame" frameborder="no" marginwidth="10" marginheight="10" scrolling="yes" src="../mapviewernet/ajaxviewer.aspx?SESSION=<%=MgSessionId%>&WEBLAYOUT=<%=webLayout%>">
 
</frame>
</frame>
 
</frameset>
<body>
 
<input type="button" value="Point" onclick="DigitizePoint();" />
</body>
</html>
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20100115/4f51b9d2/attachment.html


More information about the mapguide-users mailing list