ThinkGeo.com    |     Documentation    |     Premium Support

Custom Overlays Not Rendering After Upgrade to MVC Edition 8

Hello,

We just upgraded from MVC Edition version 7.0 to version 8.0.336.0 to correct an issue we were having with the deployment. Since the upgrade our Overlays containing our layers are not rendering at all if the IsVisible property is set to false when the map is created in the controller. Furthermore, toggling the visibility in the OverlaySwitcher does not do anything, even the though the properties on the javascript objects for the layers are being changed. If the Overlays’ IsVisible properties are set to true, the Overlays work properly. Meanwhile, the HighLightOverlay behaves properly and and functions according to the IsVisible property, which is  good as it did not do this in version 7.0.

Hi Michael,



As you mentioned, the OverlaySwitcher changes the client side layer visibility, however, the CustomOverlays are drawn from server side and the server side Overlays visibility still keep the original status. So, we also need to change the server side status by an Ajax call. Please following the below codes:




OnMapCreated = function (map) {
           for (var i = 0; i < map.layers.length; i++) {
                var layer = map.layers;
                if (layer && layer.initVisibility == false) {
                     layer.events.register(“visibilitychanged”, layer, function (layer) {
                         Map1.ajaxCallAction(’@(ViewContext.RouteData.Values[“Controller”].ToString())’‘ChangeOverlayVisibility’, { id: layer.object.id, visibility: layer.object.visibility },
                        function () {
                            Map1.redrawLayer(layer.object.id)
                        });
                })
                }
            }
}

Please let us know if any questions.



Thanks,



Troy

Thanks. This is working properly now. Did something change between version 7 and 8 that caused this to be necessary to do?

Michael,



At this part, No, the v8 still kept the same as v7. Just let you know, if we make all the overlays as visibility by default in the server side, then we don’t need the above codes.



Thanks,



Troy