<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
The code you sent in this thread does not have a variable named
repositoryName.<br>
<br>
I think you are mixing some terms.<br>
<br>
A typical application is made up of:<br>
One or more FeatureSource's (data connections, raw geometry, no colors
etc).<br>
One or more LayerDefinition's that each connect to a single
featuresource (sets up colors, etc).<br>
One MapDefinition which is basically a collection of layers.<br>
One WebLayout or Fusion Application that includes the map and some
buttons.<br>
<br>
All of these elements are actually Xml documents, and all are stored in
a repository.<br>
There are two types of repositories, a Library repo, which is
permanent, and a Session repo, which is created and deleted for each
user automatically.<br>
The Library repo adresses all features by a "Library://" prefix, the
Session repo adresses all features by a "Session:&lt;sessionid&gt;//"
prefix.<br>
<br>
Since Xml is verbose text data, it is highly inefficient to read, store
and parse such documents all the time.<br>
To remedy this, MapGuide relies on a Runtime Map, which is a binary
representation of a MapDefinition and some data from its
LayerDefinitions.<br>
What makes it tricky to understand, is that this distinction is not
really clear in the Developer Guide (my own opinion).<br>
<br>
When you start the MapGuide viewer, it creates a session (and thus a
Session repo), then converts the MapDefinition to a Runtime Map, and <br>
saves it in the Session repo. The runtime map is then manipulated by
the viewer, to turn layers on/off etc.<br>
<br>
You can get the Runtime Map, by using the MgMap.Open(...). To get the
Runtime map name, you must read the WebLayout (or Fusion Application), <br>
then extract the resource Id for the MapDefinition. Since the
MapDefinition is Xml, and the Runtime Map is binary, they can't share
the same resource Id.<br>
<br>
The viewer takes the MapDefinition resourceId and converts it into a
shorter string, eg:<br>
Library://Folder/mymap.MapDefinition<br>
becomes<br>
Folder/mymap<br>
<br>
Everytime you do something where a "mapname" is expected, you must use
the short form. Internally this is then expanded to:<br>
Session:&lt;sessionid&gt;//Folder/mymap.Map<br>
<br>
So the runtime map is strictly in the session repository.<br>
When you want something done, you must consider if it should be done
before the runtime map is created, or after. If you choose before, you
must battle with the xml, if you choose after, you must use the MgMap
object. When you manipulate either the MgMap or the Xml, nothing
happens before you call MgMap.Save(...) or
MgResourceService.SetResource().<br>
<br>
If you are manipulating the Runtime Map, you perform an action on the
server. The client is an AJAX viewer and runs on the client machine. To
inform the client that something has happened, you must call
"GetMapFrame().Refresh()" on the client. If this call fails, you can
usually see the effects of the change when you pan or zoom, as that
triggers the Refresh as well.<br>
<br>
I think there are some problems with the Legend, specifically that
legend labels are stripped from the Runtime Map, if the "show in
legend" is not checked in the MapDefinition. I also seem to remember
that modifing the label does not work correctly either.<br>
<br>
To make things even more confusing, the Runtime Map references the
LayerDefinition, and only copies a few attributes from the layer, but
still needs the LayerDefinition for style information.<br>
<br>
I hope that clears out some of the confusion for you.<br>
<br>
So, as you might be able to see now, if you want to change the style of
a feature, you must make a copy of the LayerDefinition (xml) save it in
the Session repo, and then update the Runtime map to use the new
Session repo based LayerDefinition, otherwise all users will get their
layers updated. The same goes for the FeatureSource.<br>
<br>
What can confuse more, is that IF you want a layer visible BEFORE the
runtime map is generated, you must save a copy of the MapDefinition,
and WebLayout in the Session repo, and then start the viewer with that,
and it will create the Runtime map as usual, but now based on a
modified MapDefinition.<br>
<br>
<pre class="moz-signature" cols="72">Regards, Kenneth Skovhede, GEOGRAF A/S
</pre>
<br>
Galois skrev:
<blockquote cite="mid:20088499.post@talk.nabble.com" type="cite">
  <pre wrap="">When I say empty I mean that when I am in debug mode, I see that
repositoryName = ""

I have read MapGuide Developers Guide, but I cannot say that everything is
clear to me.
For example, I don't know if I have to use featureSource in order to change
something in the runTimeMap.

Ok, if I don't have to "touch" the mapDefinition, then I'll have to store
everything in a session repository. Is that wright?

Do I have to make anything with the webLayout?

Do you see any mistake in my code?




Kenneth Skovhede, GEOGRAF A/S wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">You are correct about the new MgMap(...) call. My mistake.
So it becomes:
MgMap map = new MgMap(siteConnection);
map.Open(mapname);
map.GetLayers().GetItem(0).SetLegend("Changed");
map.Save(resourceSrvc, mapname);

Yes, I meant the Refresh() call.

If nothing happens, either you are not calling the correct frame, or the 
map has not been saved.
Try to use FireFox and the FireBug plugin to see where the calls go.

Regard, Kenneth Skovhede, GEOGRAF A/S



Antonis Mihalas skrev:
    </pre>
    <blockquote type="cite">
      <pre wrap="">As far as I know, this is not possible, because
MgMap map = new MgMap(resourceSrvc); it takes as argument a
siteConnection...


When you say refresh the client you mean just to write one line *.js?
without importing anything?

I'm asking, cause parent.parent.Refresh();
              or
parent.mapFrame.Refresh();

doesn't do anything...
        

--- Στις *Δευτ., 20/10/08, ο/η Kenneth Skovhede, GEOGRAF A/S 
/<a class="moz-txt-link-rfc2396E" href="mailto:ks@geograf.dk">&lt;ks@geograf.dk&gt;</a>/* έγραψε:

    Από: Kenneth Skovhede, GEOGRAF A/S <a class="moz-txt-link-rfc2396E" href="mailto:ks@geograf.dk">&lt;ks@geograf.dk&gt;</a>
    Θέμα: Re: [mapguide-users] Nothing is working or what I'm doing
wrong?
    Προς: "MapGuide Users Mail List" <a class="moz-txt-link-rfc2396E" href="mailto:mapguide-users@lists.osgeo.org">&lt;mapguide-users@lists.osgeo.org&gt;</a>
    Ημερομηνία: Δευτέρα, 20 Οκτώβριος 2008, 16:53

    The viewer overwrites the runtime map on startup, so if you run this 
    before starting the viewer, your changes will be lost.
    You should not create a new runtime map, but open the one the viewer 
    creates for you, modify it, save it, and refresh the client.
    I belive the correct sequence would be:
    MgMap map = new MgMap(resourceSrvc);
    map.Open(mapName):

    The viewer takes a string like:
    "Library://Folder/MapName.MapDefinition"
    and uses the map name:
    "Folder/MapName"

    You must use the same name in your code, or you won't get to the
runtime 
    map.

    If you want the layer to show when the map loads, have a look at
this:
   
<a class="moz-txt-link-freetext" href="http://trac.osgeo.org/mapguide/wiki/maestro/MaestroAPI/samples/AddInitialLayer">http://trac.osgeo.org/mapguide/wiki/maestro/MaestroAPI/samples/AddInitialLayer</a>

    You can perform the same actions without the MaestroAPI if you like,
but 
    you have to deal with the xml in raw form.

    Regards, Kenneth Skovhede, GEOGRAF
     A/S



    Galois skrev:
    &gt; Whatever I try to do it's just not working.
    &gt;
    &gt; Add a new layer?
    &gt; The layer is added but never shown
    &gt;
    &gt; Add a point? Nothing
    &gt;
    &gt; Add a new group?
    &gt; The Group is added but never shown
    &gt;
    &gt; So, I simple tried to change the LegendLabel of an existing layer.
    &gt; Nothing happened again...
    &gt;
    &gt; If anyone can tell me what I am doing wrong I would appreciate it.
    &gt;
    &gt; Code follows:
    &gt;
    &gt;
    &gt; using System;
    &gt; using System.Data;
    &gt; using System.Configuration;
    &gt; using System.Web;
    &gt; using System.Web.Security;
    &gt; using System.Web.UI;
    &gt; using System.Web.UI.WebControls;
    &gt; using System.Web.UI.WebControls.WebParts;
    &gt; using System.Web.UI.HtmlControls;
    &gt; using OSGeo.MapGuide;
    &gt; using System.Xml;
    &gt; using System.IO;
    &gt; using System.Text;
    &gt;
    &gt; public partial
     class _Default : System.Web.UI.Page
    &gt; {
    &gt;     public string sessionId;
    &gt;     public string webLayout;
    &gt;     public MgLayer tmpLayer;
    &gt;     protected System.Web.UI.HtmlControls.HtmlGenericControl Frame1;
    &gt;
    &gt;     protected void Page_Load(object sender, EventArgs e)
    &gt;     {
    &gt;         string physicalPath = @"C:\Program
    &gt;
    Files\MapGuideOpenSource\WebServerExtensions\www\webconfig.ini";
    &gt;
    &gt;         try
    &gt;         {
    &gt;             MapGuideApi.MgInitializeWebTier(physicalPath);
    &gt;
    &gt;
    &gt;             passAndSession();
    &gt;
    &gt;
    &gt;             //Associate a session ID with the MgSiteConnection
Object
    &gt;             MgUserInformation userInfo_new = new
    &gt; MgUserInformation(sessionId);
    &gt;
    &gt;             MgSiteConnection siteConnection = new
MgSiteConnection();
    &gt;
    &gt;            
     siteConnection.Open(userInfo_new);
    &gt;
    &gt;
    &gt;
    &gt;             // Get an instance of the required service(s)
    &gt;             MgResourceService resourceSrvc =
    &gt;
   
(MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
    &gt;             MgFeatureService featureSrvc =
    &gt;
   
(MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);
    &gt;
    &gt;
    &gt;
    &gt;             MgMap map = new MgMap(siteConnection);
    &gt;
    &gt;
    &gt;             webLayout =
    &gt;
   
"Library://GoSpatial/Web+Layouts/Autostrada+Brescia+Padova+Map.WebLayout";
    &gt;
    &gt;             MgResourceIdentifier resId = new
    &gt; MgResourceIdentifier("Library://GoSpatial/Maps/Italy
    Map.MapDefinition");
    &gt;
    &gt;             String mapName = resId.GetName();
    &gt;
    &gt;             MgResourceIdentifier mapStateId = new
    &gt; MgResourceIdentifier("Session:" + sessionId + "//"
     +
    mapName + "." +
    &gt; MgResourceType.Map);
    &gt;
    &gt;
    &gt;
    &gt;             createSaveOpen(map, resourceSrvc, resId, mapName,
mapStateId);
    &gt;
    &gt;
    &gt;             MgLayerBase firstLayer = map.GetLayers().GetItem(0);
    &gt;             firstLayer.SetLegendLabel("CHANGE");
    &gt;             
    &gt;
    &gt;             map.Save(resourceSrvc, mapStateId);
    &gt;         }
    &gt;         catch (Exception ex)
    &gt;         {
    &gt;             throw (ex);
    &gt;         }
    &gt;     }
    &gt;
    &gt;
    &gt; Thx in advanced!
    &gt;
    &gt; PS I have never but never in my life try to do something and in 2
weeks
    not
    &gt; shown even a small improvement...
    &gt;   
    _______________________________________________
    mapguide-users mailing
     list
    <a class="moz-txt-link-abbreviated" href="mailto:mapguide-users@lists.osgeo.org">mapguide-users@lists.osgeo.org</a>
    <a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/mapguide-users">http://lists.osgeo.org/mailman/listinfo/mapguide-users</a>
              


__________________________________________________
Χρησιμοποιείτε Yahoo!;
Βαρεθήκατε τα ενοχλητικά μηνύματα (spam); Το Yahoo! Mail διαθέτει την 
καλύτερη δυνατή προστασία κατά των ενοχλητικών μηνυμάτων
<a class="moz-txt-link-freetext" href="http://mail.yahoo.gr">http://mail.yahoo.gr</a>
------------------------------------------------------------------------

_______________________________________________
mapguide-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:mapguide-users@lists.osgeo.org">mapguide-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/mapguide-users">http://lists.osgeo.org/mailman/listinfo/mapguide-users</a>
  
      </pre>
    </blockquote>
    <pre wrap="">_______________________________________________
mapguide-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:mapguide-users@lists.osgeo.org">mapguide-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/mapguide-users">http://lists.osgeo.org/mailman/listinfo/mapguide-users</a>


    </pre>
  </blockquote>
  <pre wrap=""><!---->
  </pre>
</blockquote>
</body>
</html>