<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"><meta name="Generator" content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
span.EmailStyle18
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style></head><body lang="EN-US" link="#0563C1" vlink="#954F72"><div class="WordSection1"><p class="MsoNormal"><span style="color:#1f497d">I found my problem.  It was here:</span></p><p class="MsoNormal"><span style="color:#1f497d"> </span></p><p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas">map.Save(resService); should be map.Save();</span></p><p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas"> </span></p><p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas">Updating the OpenLayers mapguide layer accomplished like this:</span></p><p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas"> </span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">var</span><span style="font-size:9.5pt;font-family:Consolas"> params = mgLayer.getSource().getParams();</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">params.t = <span style="color:blue">new</span> Date().getMilliseconds();</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">mgLayer.getSource().updateParams(params);</span></p><p class="MsoNormal"><span style="color:#1f497d"> </span></p><p class="MsoNormal"><span style="color:#1f497d">Thanks,</span></p><p class="MsoNormal"><span style="color:#1f497d"> </span></p><div><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#0000a0">Gregory B. Neff</span><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#1f497d"></span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:navy">District Engineer</span><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1f497d"></span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:navy">Cottonwood Improvement District</span><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1f497d"></span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:navy">8620 Highland Drive</span><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1f497d"></span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:navy">Sandy, Utah 84093</span><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1f497d"></span></p></div><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:navy">(801) 943-7671</span><span style="color:#1f497d"></span></p><div><div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0in 0in 0in"><p class="MsoNormal"><b>From:</b> Greg Neff [mailto:<a href="mailto:gbneff@cid.utah.gov">gbneff@cid.utah.gov</a>] <br><b>Sent:</b> Friday, February 10, 2017 11:34 AM<br><b>To:</b> '<a href="mailto:mapguide-users@lists.osgeo.org">mapguide-users@lists.osgeo.org</a>' <<a href="mailto:mapguide-users@lists.osgeo.org">mapguide-users@lists.osgeo.org</a>><br><b>Subject:</b> Change Layer Visibility - Mapguide With Openlayers3</p></div></div><p class="MsoNormal"> </p><p class="MsoNormal">OpenLayers v3.18</p><p class="MsoNormal">Mapguide 3.1 64 bit</p><p class="MsoNormal">IIs – Windows 10</p><p class="MsoNormal"> </p><p class="MsoNormal">Is it possible to change the visibility of a Mapguide  map layer using the Mapguide api and then have the change reflected in the openlayers viewer where the Mapguide map is a layer?</p><p class="MsoNormal"> </p><p class="MsoNormal">I have tried the following code below and seem to be able to get the layer visibility and set the visibility, but I don’t think the changes are being saved to the “runtime” or session map. (btw: When I couldn’t make it work with OpenLayers, I tried it in the AJAX viewer with an invoke url running in the task pane and that is the code shown.)</p><p class="MsoNormal"> </p><p class="MsoNormal">Thanks,</p><p class="MsoNormal"> </p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#0000a0">Gregory B. Neff</span><span style="font-size:12.0pt;font-family:"Arial",sans-serif"></span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:navy">District Engineer</span><span style="font-size:10.0pt;font-family:"Arial",sans-serif"></span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:navy">Cottonwood Improvement District</span><span style="font-size:10.0pt;font-family:"Arial",sans-serif"></span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:navy">8620 Highland Drive</span><span style="font-size:10.0pt;font-family:"Arial",sans-serif"></span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:navy">Sandy, Utah 84093</span><span style="font-size:10.0pt;font-family:"Arial",sans-serif"></span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:navy">(801) 943-7671</span></p><p class="MsoNormal"> </p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;background:yellow"><%</span><span style="font-size:9.5pt;font-family:Consolas;color:blue">@</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:maroon">Import</span> <span style="color:red">Namespace</span><span style="color:blue">="OSGeo.MapGuide"</span> <span style="background:yellow">%></span></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> </span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue"><!</span><span style="font-size:9.5pt;font-family:Consolas;color:maroon">DOCTYPE</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:red">html</span> <span style="color:red">PUBLIC</span> <span style="color:blue">"-//W3C//DTD XHTML 1.0 Transitional//EN"</span> <span style="color:blue">"<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>"></span></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> </span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue"><</span><span style="font-size:9.5pt;font-family:Consolas;color:maroon">html</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:red">xmlns</span><span style="color:blue">="<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>"></span></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue"><</span><span style="font-size:9.5pt;font-family:Consolas;color:maroon">head</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:red">runat</span><span style="color:blue">="server"></span></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">    <span style="color:blue"><</span><span style="color:maroon">title</span><span style="color:blue">></span> Changing Layer Visibility<span style="color:blue"></</span><span style="color:maroon">title</span><span style="color:blue">></span>   </span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">    <span style="color:blue"><</span><span style="color:maroon">script</span> <span style="color:red">type</span><span style="color:blue">="text/javascript"></span></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        <span style="color:blue">function</span> RefreshMap() {</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">            parent.parent.Refresh();</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        }</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">    <span style="color:blue"></</span><span style="color:maroon">script</span><span style="color:blue">></span></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> </span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue"></</span><span style="font-size:9.5pt;font-family:Consolas;color:maroon">head</span><span style="font-size:9.5pt;font-family:Consolas;color:blue">></span><span style="font-size:9.5pt;font-family:Consolas"></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue"><</span><span style="font-size:9.5pt;font-family:Consolas;color:maroon">body</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:red">onload</span><span style="color:blue">="javascript:RefreshMap()"></span></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">    <span style="background:yellow"><%</span></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        <span style="color:#2b91af">String</span> sessionId = Request.Form.Get(<span style="color:#a31515">"SESSION"</span>);</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        <span style="color:green">//make sure to pass these values</span></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        <span style="color:green">//String mapguideMapResource = Request.Form.Get("mapguideMapName");</span></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        <span style="color:#2b91af">String</span> mapguideMapResource = <span style="color:#a31515">"Cid_Map"</span>;</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        <span style="color:green">//String mapguideLayer = Request.Form.Get("mapguideCleanedLinesLayer");</span></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        <span style="color:#2b91af">String</span> mapguideLayer = <span style="color:#a31515">"linesCleaned2017"</span>;</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        <span style="color:#2b91af">String</span> realPath = Request.ServerVariables[<span style="color:#a31515">"APPL_PHYSICAL_PATH"</span>];</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        realPath = realPath.Replace(<span style="color:#a31515">@"Cid_Map\"</span>, <span style="color:#a31515">""</span>);</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        <span style="color:#2b91af">String</span> configPath = realPath + <span style="color:#a31515">"webconfig.ini"</span>;</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        <span style="color:#2b91af">MapGuideApi</span>.MgInitializeWebTier(configPath);</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> </span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        <span style="color:#2b91af">MgUserInformation</span> userInfo = <span style="color:blue">new</span> <span style="color:#2b91af">MgUserInformation</span>(sessionId);</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        <span style="color:#2b91af">MgSiteConnection</span> siteConnection = <span style="color:blue">new</span> <span style="color:#2b91af">MgSiteConnection</span>();</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        siteConnection.Open(userInfo);</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> </span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        <span style="color:#2b91af">MgResourceService</span> resService = (<span style="color:#2b91af">MgResourceService</span>)siteConnection.CreateService(<span style="color:#2b91af">MgServiceType</span>.ResourceService);</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> </span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        <span style="color:#2b91af">MgMap</span> map = <span style="color:blue">new</span> <span style="color:#2b91af">MgMap</span>(siteConnection);</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        map.Open(resService, mapguideMapResource);</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        </span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        <span style="color:#2b91af">MgLayerCollection</span> layers = map.GetLayers();</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        <span style="color:green">//MgLayerBase layerClean2017 = layers.GetItem(mapguideLayer);</span></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        <span style="color:#2b91af">MgLayer</span> layer = (<span style="color:#2b91af">MgLayer</span>)layers.GetItem(mapguideLayer);</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        <span style="color:blue">if</span> (layer.GetVisible())</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        {</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">            layer.SetVisible(<span style="color:blue">false</span>);</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        }</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        <span style="color:blue">else</span></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        {</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">            layer.SetVisible(<span style="color:blue">true</span>);</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        }</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        layer.ForceRefresh();</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        map.Save(resService);</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        </span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        Response.Write(sessionId + <span style="color:#a31515">"</br>"</span>);</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        Response.Write(<span style="color:#a31515">"Map Name: "</span> + map.GetName() + <span style="color:#a31515">"</br>"</span>);</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">        Response.Write(layer.GetName() + <span style="color:#a31515">" "</span> + layer.GetVisible());</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">    <span style="background:yellow">%></span></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> </span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue"></</span><span style="font-size:9.5pt;font-family:Consolas;color:maroon">body</span><span style="font-size:9.5pt;font-family:Consolas;color:blue">></span></p><p class="MsoNormal"> </p><p class="MsoNormal"> </p><p class="MsoNormal"> </p></div></body></html>