ThinkGeo.com    |     Documentation    |     Premium Support

Load Map From PostGIS

Dear Support Team,



I have imported a shape file to postGIS with
SRID value of 21036 and I have used the code below to load the map from
postGIS but it does not show anything and no any error message given out. Can you please help me?


string connectString = "Server=localhost;User Id=postgres;Password=postgres;DataBase=my_spatial_db;";
           //PostgreSqlFeatureLayer postgreLayer = new PostgreSqlFeatureLayer(connectString, "my_region", "gid", 21036, "public", "geom");
           PostgreSqlFeatureLayer postgreLayer = new PostgreSqlFeatureLayer(connectString, "my_region", "gid");
           postgreLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
           postgreLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
           
           InMemoryFeatureLayer spatialQueryResultLayer = new InMemoryFeatureLayer();
           spatialQueryResultLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(200, GeoColor.SimpleColors.PastelRed)));
           spatialQueryResultLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Color = GeoColor.StandardColors.Red;
           spatialQueryResultLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
           postgreLayer.Open();
           Collection<Feature> call = postgreLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns);
           postgreLayer.Close();
 
           foreach (Feature feature in call)
           {spatialQueryResultLayer.InternalFeatures.Add(feature.Id, feature);               
           }           
           spatialQueryResultLayer.Open();
           RectangleShape _boundingbox = spatialQueryResultLayer.FeatureSource.GetBoundingBox();
           spatialQueryResultLayer.Close();
           Map1.CurrentExtent = _boundingbox;
           Map1.StaticOverlay.Layers.Add(spatialQueryResultLayer);




Best Regards,

Vincent









I have discovered my mistake. It was all about map unit. Now it is working fine. Thank you

Hi Vincent, 
  
 You are so welcome! 
 Any questions don’t hesitate to let us know. 
  
 Thanks, 
 Johnny