We are creating a map that requires a lot of layers, there is nothing we can do but have all these layers available to the user.
To solve this we contacted a member at thinkgeo to help us with an issue of hiding layers on map load. This function works but when you try to add some of the layers back in , we get some of this map not being uploaded again. I know we have been warned from using so many layers but we cant take any out.
Any Help would be much appreciated.
I have attached a picture to highlight the problem.
Here is the code in our java script to get the is visible and invisible layers to work
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 () { });})}}}
And here is our server side code
[MapActionFilter]public void ChangeOverlayVisibility(Map map, GeoCollection<object> args){LayerOverlay overlay = map.CustomOverlays[args[0].ToString()] as LayerOverlay;if (overlay != null){bool visible = bool.Parse(args[1].ToString());overlay.IsVisible = visible;}}