<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>Selection problem after modify runtime map with MaestroAPI</TITLE>
</HEAD>
<BODY>
<P ALIGN=LEFT><FONT SIZE=2 FACE="Arial">Hello,</FONT></P>
<P ALIGN=LEFT><FONT SIZE=2 FACE="Arial">the following code is used to add a layer from an template map to the runtime map</FONT><FONT SIZE=2 FACE="Arial">, where the required layergroup already exists</FONT><FONT SIZE=2 FACE="Arial">:</FONT></P>
<P ALIGN=LEFT><FONT COLOR="#2B91AF" SIZE=2 FACE="Courier New">MapGuideApi</FONT><FONT SIZE=2 FACE="Courier New">.MgInitializeWebTier(</FONT><FONT COLOR="#A31515" SIZE=2 FACE="Courier New">@"D:\Programme\Autodesk\MapGuideEnterprise2011\WebServerExtensions\www\webconfig.ini"</FONT><FONT SIZE=2 FACE="Courier New">);</FONT></P>
<P ALIGN=LEFT><FONT COLOR="#2B91AF" SIZE=2 FACE="Courier New">LocalNativeConnection</FONT><FONT SIZE=2 FACE="Courier New"> connection =</FONT> <FONT COLOR="#0000FF" SIZE=2 FACE="Courier New">new</FONT><FONT SIZE=2 FACE="Courier New"></FONT> <FONT COLOR="#2B91AF" SIZE=2 FACE="Courier New">LocalNativeConnection</FONT><FONT SIZE=2 FACE="Courier New">(sessionId);</FONT></P>
<P ALIGN=LEFT><FONT COLOR="#2B91AF" SIZE=2 FACE="Courier New">MapDefinition</FONT><FONT SIZE=2 FACE="Courier New"> templateMap = connection.GetMapDefinition(</FONT><FONT COLOR="#A31515" SIZE=2 FACE="Courier New">"Library://TestProject/Maps/Project.MapDefinition"</FONT><FONT SIZE=2 FACE="Courier New">);</FONT></P>
<P ALIGN=LEFT><FONT COLOR="#2B91AF" SIZE=2 FACE="Courier New">ResourceIdentifier</FONT><FONT SIZE=2 FACE="Courier New"> resIdRuntimeMap =</FONT> <FONT COLOR="#0000FF" SIZE=2 FACE="Courier New">new</FONT><FONT SIZE=2 FACE="Courier New"></FONT> <FONT COLOR="#2B91AF" SIZE=2 FACE="Courier New">ResourceIdentifier</FONT><FONT SIZE=2 FACE="Courier New">(</FONT><FONT COLOR="#A31515" SIZE=2 FACE="Courier New">"Map"</FONT><FONT SIZE=2 FACE="Courier New">,</FONT> <FONT COLOR="#2B91AF" SIZE=2 FACE="Courier New">ResourceTypes</FONT><FONT SIZE=2 FACE="Courier New">.RuntimeMap, sessionId);</FONT></P>
<P ALIGN=LEFT><FONT COLOR="#2B91AF" SIZE=2 FACE="Courier New">RuntimeMap</FONT><FONT SIZE=2 FACE="Courier New"> runtimeMap = connection.GetRuntimeMap(resIdRuntimeMap.ResourceId);</FONT></P>
<P ALIGN=LEFT><FONT COLOR="#2B91AF" SIZE=2 FACE="Courier New">MapLayerType</FONT><FONT SIZE=2 FACE="Courier New"> layer = templateMap.Layers[templateMap.Layers.IndexOf(</FONT><FONT COLOR="#A31515" SIZE=2 FACE="Courier New">"testLayer"</FONT><FONT SIZE=2 FACE="Courier New">)];</FONT></P>
<P ALIGN=LEFT><FONT SIZE=2 FACE="Courier New">runtimeMap.Layers.Insert(runtimeMap.Layers.Count,</FONT> <FONT COLOR="#0000FF" SIZE=2 FACE="Courier New">new</FONT><FONT SIZE=2 FACE="Courier New"></FONT> <FONT COLOR="#2B91AF" SIZE=2 FACE="Courier New">RuntimeMapLayer</FONT><FONT SIZE=2 FACE="Courier New">(layer));</FONT></P>
<P ALIGN=LEFT><FONT SIZE=2 FACE="Courier New">connection.SaveRuntimeMap(resIdRuntimeMap.ResourceId, runtimeMap);</FONT></P>
<P ALIGN=LEFT><FONT SIZE=2 FACE="Arial">In normal conditions the obove code runs successfully</FONT><FONT SIZE=2 FACE="Arial">,</FONT> <FONT SIZE=2 FACE="Arial">getting a d</FONT><FONT SIZE=2 FACE="Arial">e</FONT><FONT SIZE=2 FACE="Arial">fined layer from TemplateMap(</FONT><FONT SIZE=2 FACE="Arial">"</FONT><FONT COLOR="#A31515" SIZE=2 FACE="Courier New">Project</FONT><FONT COLOR="#A31515" SIZE=2 FACE="Courier New">"</FONT><FONT SIZE=2 FACE="Arial">)</FONT><FONT SIZE=2 FACE="Arial"> and i</FONT><FONT SIZE=2 FACE="Arial">n</FONT><FONT SIZE=2 FACE="Arial">serting</FONT> <FONT SIZE=2 FACE="Arial">it</FONT><FONT SIZE=2 FACE="Arial"> to the runtime map.</FONT></P>
<P ALIGN=LEFT><FONT SIZE=2 FACE="Arial">However if the layer to be added is set as invisible</FONT><FONT SIZE=2 FACE="Arial"></FONT> <FONT SIZE=2 FACE="Arial">at startup</FONT><FONT SIZE=2 FACE="Arial"></FONT> <FONT SIZE=2 FACE="Arial">in the template</FONT><FONT SIZE=2 FACE="Arial">, elements from these layer become</FONT> <FONT SIZE=2 FACE="Arial">not highlighted after being selected</FONT><FONT SIZE=2 FACE="Arial"> in the target runtime map.</FONT></P>
<P ALIGN=LEFT><FONT SIZE=2 FACE="Arial">When</FONT> <FONT SIZE=2 FACE="Arial">select</FONT><FONT SIZE=2 FACE="Arial">ing</FONT><FONT SIZE=2 FACE="Arial"> an element</FONT><FONT SIZE=2 FACE="Arial"> from such a layer, the selection highlighting fails to show</FONT><FONT SIZE=2 FACE="Arial"> the</FONT><FONT SIZE=2 FACE="Arial"> selected element</FONT><FONT SIZE=2 FACE="Arial">, although</FONT> <FONT SIZE=2 FACE="Arial">the toolbar</FONT> <FONT SIZE=2 FACE="Arial">confirms one element selected.</FONT><FONT SIZE=2 FACE="Arial"></FONT> <FONT SIZE=2 FACE="Arial">Also</FONT> <FONT SIZE=2 FACE="Arial">getting the id of the element works.</FONT> </P>
<P ALIGN=LEFT><FONT SIZE=2 FACE="Arial">In such condition, the</FONT> <FONT SIZE=2 FACE="Arial">Mapviewernet tr</FONT><FONT SIZE=2 FACE="Arial">i</FONT><FONT SIZE=2 FACE="Arial">es to get the selection image</FONT><FONT SIZE=2 FACE="Arial">:</FONT></P>
<UL>
<P ALIGN=LEFT><FONT SIZE=2 FACE="Arial">/mapguide2011/mapagent/mapagent.fcgi?OPERATION=GETDYNAMICMAPOVERLAYIMAGE&FORMAT=PNG&VERSION=2.1.0&SESSION=f66f5f60-bcb9-11df-8000-005056c00008_de_7F0000010AFC0AFB0AFA&MAPNAME=Map&SEQ=0.4188060987466432&CLIENTAGENT=Ajax%20Viewer&BEHAVIOR=5&SELECTIONCOLOR=0x0000FFFF</FONT></P>
</UL>
<P ALIGN=LEFT><FONT SIZE=2 FACE="Arial">But t</FONT><FONT SIZE=2 FACE="Arial">he result is an em</FONT><FONT SIZE=2 FACE="Arial">p</FONT><FONT SIZE=2 FACE="Arial">ty png.</FONT></P>
<P ALIGN=LEFT><FONT SIZE=2 FACE="Arial">If the layer is added</FONT><FONT SIZE=2 FACE="Arial"> interactively</FONT><FONT SIZE=2 FACE="Arial"> to the map</FONT><FONT SIZE=2 FACE="Arial"></FONT> <FONT SIZE=2 FACE="Arial">with Maestor/MapGuide Studio</FONT><FONT SIZE=2 FACE="Arial">, all is working fine.</FONT></P>
<P ALIGN=LEFT><FONT SIZE=2 FACE="Arial">So it seems this problem occurs</FONT><FONT SIZE=2 FACE="Arial"> only</FONT><FONT SIZE=2 FACE="Arial"> when</FONT> <FONT SIZE=2 FACE="Arial">transfering</FONT><FONT SIZE=2 FACE="Arial"> a layer</FONT> <FONT SIZE=2 FACE="Arial">from template to runtime</FONT> <FONT SIZE=2 FACE="Arial">pro</FONT><FONT SIZE=2 FACE="Arial">g</FONT><FONT SIZE=2 FACE="Arial">ram</FONT><FONT SIZE=2 FACE="Arial">m</FONT><FONT SIZE=2 FACE="Arial">atic</FONT><FONT SIZE=2 FACE="Arial">al</FONT><FONT SIZE=2 FACE="Arial">ly</FONT><FONT SIZE=2 FACE="Arial">.</FONT></P>
<P ALIGN=LEFT><FONT SIZE=2 FACE="Arial">I use MapGuide Enterprise 2011 with Maestro</FONT><FONT SIZE=2 FACE="Arial"> 2.1.0.</FONT></P>
<BR>
<P ALIGN=LEFT><FONT SIZE=2 FACE="Arial">Any help would be appreciated</FONT><FONT SIZE=2>.</FONT></P>
<P ALIGN=LEFT><FONT SIZE=2 FACE="Arial">Regards,</FONT></P>
<P ALIGN=LEFT><FONT SIZE=2 FACE="Arial">Thomas</FONT></P>
</BODY>
</HTML>