ThinkGeo.com    |     Documentation    |     Premium Support

Display CustomOverlay with Multiple Feature Layers via mapCallback

Hi,


I need help to achieve this functionality. I have server-side codes that dynamically add InMemoryFeatureLayers when a button is clicked.


These layers are features from the MsSQL2008FeatureLayer that are being added to a CustomOverlay. The custom overaly shows but my problem is the layers in it don't show on the map. I need to do the map redraw via client-side, meaning in the mapCallback. My codes below:


Server side: 



[MapActionFilter]
        public string ShowSQLFeatureLayers(Map map, GeoCollection<object> args)
        {
            string name = args["uiLayerName"].ToString();
            string id = args["uiLayerId"].ToString();
 
            try
            {
                MsSql2008FeatureLayer layer = GetLayer(decimal.Parse(id));
                layer.Open();
 
                var features = layer.QueryTools.GetAllFeatures(ReturningColumnsType.AllColumns).ToList();
 
                LayerOverlay co = (LayerOverlay)map.CustomOverlays.FirstOrDefault(f => f.Id == string.Format("{0}|{1}", name, id));
 
                foreach (var feature in features)
                {
                    InMemoryFeatureLayer inMemoryFeatureLayer = new InMemoryFeatureLayer();
                    inMemoryFeatureLayer.Open();
 
                    inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.FromArgb(100, GeoColor.StandardColors.RoyalBlue);
                    inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Color = GeoColor.StandardColors.Blue;
                    inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.OuterPen = new GeoPen(GeoColor.FromArgb(200, GeoColor.StandardColors.Red), 10);
                    inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.SymbolPen = new GeoPen(GeoColor.FromArgb(255, GeoColor.StandardColors.Red), 20);
                    inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
 
                    // Projection
                    Proj4Projection projection = Utils.Spatial.GetDefaultMapProjection();
                    projection.Open();
                    inMemoryFeatureLayer.FeatureSource.Projection = projection;
 
                    inMemoryFeatureLayer.InternalFeatures.Add(feature);
                    co.Layers.Add(inMemoryFeatureLayer);
                    co.IsVisible = true;
                }
            }
            catch
            {
                // Swallow the exception
            }
 
            return string.Format("{0}|{1}", name, id);
        }

 


 


Client-side:


 


<script type="text/javascript">
    function loadSQLFeatureLayersForOverlay(layerName, layerId) {
        Map1.ajaxCallAction('Map', 'ShowSQLFeatureLayers', { 'uiLayerName': layerName, 'uiLayerId': layerId }, showGeomsForFeature);
    }
 
    function showGeomsForFeature(data) {
        if (data.get_statusCode() != '404') {
            var result = data.get_responseData();
            var layer = Map1.getLayer(result);
            layer.redraw(true);
        }
    }
</script>      
I appreciate any help.

Thanks,
Benito

 


 


 


 



Hi Benito, 
  
 Thanks for your post and welcome to MapSuite World, I think the problem should be because the “LayerOverlay.IsBaseOverlay=false” is not set and therefore the overlay’s content maybe is blocked by other overlays. Attached is our test sample, would you please try it and check if we missed anything? 
  
 Hope it helps 
  
 Johnny 


 Sorry that I missed the attachement just now, please check it out now.



Post_11287Sample.txt (1.94 KB)

Hi,



Thank you for your response. I will try it out and see if it works.



Regards,

Benito

Hi,



I applied your technique into my codes and it’s working now. Thanks a lot!

Hi Benito, 
   
 You are always welcome, hope it would be helpful, if you have any more question, please feel free to let us know. 
   
 Best Regards 
   
 Johnny