Good morning,
I'm working on making mods to some of the "Getting Started" guide samples to learn stuff. While I may be wrong, I think with the complicated map we will be using the proper place to build the map is in the controller. I have been able to do that, but I simply can't get anything else to work. For example, I made a modification to a map with two layers to toggle a roads layer on and off in response to clicking a button. When I debug the controller method I toggle the layer's IsVisible status and I can see that change, but it doesn't do anything to the map: both of my layers are still visible. I tried changing MapBackground and I can't get that to work either. This is an example of what I'm trying to do:
Since all of the examples are written the other way around (coding the map in the view) I don't have much to go on. Any ideas of what I'm doing wrong?
[MapActionFilter]
public ActionResult ToggleRoads(Map map, GeoCollection<object> args)
{
LayerOverlay bg = (LayerOverlay)map.BackgroundOverlay;
foreach (Layer layer in bg.Layers)
{
if (layer.Name == "roads")
{
layer.IsVisible = !layer.IsVisible;
}
}
return View(map);
}
Thanks,
Allen