ThinkGeo.com    |     Documentation    |     Premium Support

InMemoryFeatureLayer is not displaying features



//My WellKnownBinary is stored in a SQL database table which I am calling from my GetGeoZone method.  geoZoneModel.geoZoneLayersDS contains 

//the values of my data.  I have uploaded the results of the table for your reference and it is attached on this post.  Please see the code below.



            geoZoneModel.GetGeoZone();



            //create layer
            InMemoryFeatureLayer inMemoryFeatureLayer = new InMemoryFeatureLayer();



            inMemoryFeatureLayer.Open();



            //create columns
            inMemoryFeatureLayer.Columns.Add(new FeatureSourceColumn("Name"));



            //set shapes
            inMemoryFeatureLayer.FeatureSource.BeginTransaction();            
            //inMemoryFeatureLayer.EditTools.BeginTransaction();



            Feature geoZoneFeature;



            foreach (GeoZoneLayersDataStructure ds in geoZoneModel.geoZoneLayersDS)
            {                
                geoZoneFeature = new Feature(ds.ShapeWKB);              



                geoZoneFeature.ColumnValues.Add("Name", ds.GeoZoneName);
                
                inMemoryFeatureLayer.FeatureSource.AddFeature(geoZoneFeature);                
                //inMemoryFeatureLayer.InternalFeatures.Add(geoZoneFeature);
            }
            inMemoryFeatureLayer.FeatureSource.CommitTransaction();
            //inMemoryFeatureLayer.EditTools.CommitTransaction();



            inMemoryFeatureLayer.Close();



            return inMemoryFeatureLayer;



Is there something wrong with my code above?  because it is not displaying the shapes, what am i missing?



I call this function to add it on the map.



                MapSystemLayer ml = item.Value;



                FeatureLayer layer = ml.GetFeatureLayer();
                layer.Close();
                layer.FeatureSource.Projection = _proj4.CloneDeep();
                



                LayerOverlay layerOverlay = new LayerOverlay(ml.LayerName);
                layerOverlay.Layers.Add(ml.LayerName, layer);
                layerOverlay.JpegQuality = 50;
                layerOverlay.IsBaseOverlay = false;
                layerOverlay.TileType = TileType.SingleTile;
                layerOverlay.TransitionEffect = TransitionEffect.None;
                layerOverlay.WebImageFormat = WebImageFormat.Png;
                layerOverlay.ClientCache.CacheId = ml.LayerName;
                layerOverlay.IsVisible = true;// ml.Visible;



                map.CustomOverlays.Add(layerOverlay);



Please assist.


Hi Raymond, 
  
 Thanks for your post, but it seems that the “the results of the table” is not uploaded successfully, would you please check it again?  
  
 From your code, I think the two potential problems  
  
 1st is that the map.CurrentExtent is not set correctly, would you please try to use, 
 map.CurrentExtent=layer.GetBoundingBox(); 
  
 2nd is that the map.MapUnit is not set correctly, map.MapUnit should be set the same with the data’s unit, if the data in under decimal degree then set map.MapUnit = GeographyUnit.DecimalDegree; if the data is under meter then set map.MapUnit = GeographyUnit.Meter; 
  
 Would you please check above two potential problems again, if the problem is still there, would you please upload your data again? 
  
 Waiting for your further information. 
  
 Best Regards 
  
 Summer