<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
The viewer always creates the runtime map, which explains two things:<br>
1. You get the exception because the viewer has not created it yet<br>
2. The mark disapears because the viewer overwrites your runtime map.<br>
<br>
AFAIK there is no easy way to prevent the viewer from creating the
runtime map,<br>
so the "hidden frame" approach is your best choice.<br>
<pre class="moz-signature" cols="72">Regards, Kenneth Skovhede, GEOGRAF A/S
</pre>
<br>
<br>
Ran Mahiru skrev:
<blockquote cite="mid:924678.93624.qm@web35405.mail.mud.yahoo.com"
 type="cite">
  <pre wrap="">Thank's Kenneth, I think the error I keep getting is that the runtime map does not exist yet?

Code fragments:
===============

The viewer is activated at the bottom of the code by the following:

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" <a class="moz-txt-link-rfc2396E" href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"</a>&gt;
&lt;html xmlns=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/1999/xhtml">"http://www.w3.org/1999/xhtml"</a> &gt;
&lt;head&gt;
    &lt;title&gt;TEST&lt;/title&gt;
    
&lt;/head&gt;


&lt;frameset &gt;

        &lt;frame id="viewerFrame" frameborder="no" marginwidth="0" marginheight="0" scrolling="no" src="<a class="moz-txt-link-freetext" href="http://localhost/mapguide/mapviewernet/ajaxviewer.aspx?SESSION=">http://localhost/mapguide/mapviewernet/ajaxviewer.aspx?SESSION=</a>&lt;%=sessionId%&gt;&amp;WEBLAYOUT=&lt;%=sesslayout%&gt;"&gt;
&lt;/frameset&gt;


I created the map via:

        Dim map As MgMap = New MgMap
        map.Create(resourceSrvc, mapid, "DemoMap") ' mapid is the resource identifier for the map definition 
        Dim layers = map.GetLayers()

Because I kept getting an error when I tried to open the map...

Further down (after setting up the layer definition) I add it to the map:


        'Create the layer definition
        layerDefContent = BuildLayerDefinitionContent(mrkrDataS, featureName, "")
        Dim rnull As MgByteReader
        
        resourceSrvc.SetResource(mrkrLD_ID, layerDefContent, rnull)
        
        Dim mylegendName = MgLocalizer.GetString("MARKERLAYER", locale)
        Dim layer = New MgLayer(mrkrLD_ID, resourceSrvc)
        layer.SetDisplayInLegend(True)
        layer.SetLegendLabel(mylegendName)
        layers.Insert(0, layer)
        
        'create a feature representing this segment and insert it into the data source
            
        Dim mrkrProps = New MgPropertyCollection
        
        Dim TipProp = New MgStringProperty("TXTDISP", "")
        mrkrProps.Add(TipProp)

        Dim URLProp = New MgStringProperty("URLLINK", "")
        mrkrProps.Add(URLProp)

        Dim agf = New MgAgfReaderWriter()
        Dim geomReader = agf.Write(geom)
        Dim ngeomProp = New MgGeometryProperty("GEOM", geomReader)
        mrkrProps.Add(ngeomProp)

        Dim cmd As MgInsertFeatures = New MgInsertFeatures("Marker", CType(mrkrProps, MgPropertyCollection))
        Dim commands = New MgFeatureCommandCollection()
        commands.Add(cmd)
        featureSrvc.UpdateFeatures(mrkrDS_ID, commands, False)

The feature insertion works since I extracted the session SDF to check. After that the code simply extracts the weblayout, changes the starting center x, y and sets a session weblayout.

One way I managed to get this work is have the add marker code be run in a hidden frame AFTER the map has been loaded in the main frame. But is there a better way?

Thanks again.

  </pre>
  <blockquote type="cite">
    <pre wrap="">If you have the FeatureSource and the LayerDefinition ready,
you have to insert the layer into the runtime map, and call Refresh() on 
the client.

You may also need to insert the temporary feature into the FeatureSource.

Does this help you, or do you need further instructions?
If so, try posting a code fragment that explains what you have,
and where you get stuck.

(And yes, it is indeed possible).

Regards, Kenneth Skovhede, GEOGRAF A/S



Ran Mahiru skrev:
    </pre>
    <blockquote type="cite">
      <pre wrap="">Hi all, new to Mapguide Enterprise and a former Mapgudie 6.5 user...

I've managed to get the ajaxviewer to load a map at a preset center and zoom by changing the user session's weblayout before display but now I'm trying to add a feature source from a template and add a feature before display as well (to create a temporary marker). Is this even possible?

I've managed to succesfully create a marker feature source and layer definition for the session, I think but am at a loss as to how to proceed.

Help? ^^;;
      </pre>
    </blockquote>
  </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>
</body>
</html>