Hi,
After finding that having the map control defined inside the view was limiting options like drag markers... I moved away from having the control defined inside the view... Now I have the map control defined inside the controller index method and I do return it to the view when ready ... Well so far so good but i am now finding that overlays / layers do not behave anymore in a way that I was used to.
For instance, using layer name property as indexer does not work anymore....
Before I was able to access the properties of my "STATES" layer within the "layerOverlay_USA_GEO_POSTAL" overlay but now doing so generate an exception????
could you advice?
my code:
[MapActionFilter]
public JsonResult loadStates(Map map, GeoCollection<object> args)
{
JsonResult _JsonResult = null;
_redrawLayers.Clear();
if (map != null)
{
Proj4Projection proj4 = _geospatialDomain.Prj4Mercator();
proj4.Open();
LayerOverlay layerOverlay_USA_GEO_POSTAL = (LayerOverlay)map.CustomOverlays["layerOverlay_USA_GEO_POSTAL"];
Layer _tmp = layerOverlay_USA_GEO_POSTAL.Layers.Where(l => l.Name == "STATES").FirstOrDefault();
if (_tmp != null)
{
if (_tmp.Name == "STATES")
if (layerOverlay_USA_GEO_POSTAL.Layers["STATES"].IsVisible)
layerOverlay_USA_GEO_POSTAL.Layers["STATES"].IsVisible = false;
else
layerOverlay_USA_GEO_POSTAL.Layers["STATES"].IsVisible = true;
}
else
{
layerOverlay_USA_GEO_POSTAL.Layers.Add(_geospatialDomain.LoadStatesShapes(_geospatialDomain.Prj4Mercator()));
}
proj4.Close();
_redrawLayers.Add("layerOverlay_USA_GEO_POSTAL");
_JsonResult = Json(_DtoDomain.EnveloppeDto(null, _redrawLayers, new ErrorPayload { code = 0, message = "SUCCESS", status = "SUCCESS" }), JsonRequestBehavior.AllowGet);
}
else
{
_JsonResult = Json(_DtoDomain.EnveloppeDto(null, null, new ErrorPayload { code = 2001, message = "ERROR", status = "ERROR" }), JsonRequestBehavior.AllowGet);
}
return (_JsonResult);
}