ThinkGeo.com    |     Blog    |     Wiki    |     Support

Shape File over google map

Hi i am displaying shape file over google map
but at a time am able to get only one of the layers either shape file layer or google map layer.
I used this projection
proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
bt it didnt help me.
I want both layers to display
here i am attaching my code…

Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.StandardColors.Transparent);
Map1.MapUnit = GeographyUnit.Meter;
Map1.CurrentExtent = new RectangleShape(-13939426.6371, 6701997.4056, -7812401.86, 2626987.386962);
Map1.MapTools.PanZoomBar.Enabled = true;
//To add Google Map Layer
Map1.MapTools.OverlaySwitcher.Enabled = true;
Map1.MapTools.MouseCoordinate.Enabled = true;
GoogleOverlay google = new GoogleOverlay(“Google Map”);
google.JavaScriptLibraryUri = new Uri(ConfigurationManager.AppSettings[“GoogleUri”]);
google.GoogleMapType = GoogleMapType.Normal;

        //To add ShapeFile Layer
        ShapeFileFeatureLayer shapeFileLayer = new ShapeFileFeatureLayer("D:/GISShapeFiles/WAGHOLI_STR/WAGHOLI.shp");
        shapeFileLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.RequiredColumnNames.Add("GISID");
        shapeFileLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("GISID,LU_TYPE", "Arial", 15, DrawingFontStyles.Bold, GeoColor.StandardColors.Transparent, 0, 0);
        //shapeFileLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Transparent, GeoColor.FromArgb(255, 132, 132, 154), 2);
        //shapeFileLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Color = GeoColor.StandardColors.Gray;
        shapeFileLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.PointPlacement = PointPlacement.Center;
        shapeFileLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.OverlappingRule = LabelOverlappingRule.AllowOverlapping;
        shapeFileLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
        ShapeFileFeatureSource.BuildIndexFile(shapeFileLayer.ShapePathFileName);
        //InMemoryFeatureLayer memoryLaer = new InMemoryFeatureLayer();
        //memoryLaer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
        //LayerOverlay staticOverlay = new LayerOverlay("Shape Layer",false,TileType.SingleTile);
        //staticOverlay.TransitionEffect = TransitionEffect.None;

        //The Google map projection is 3857
        //Proj4Projection proj4 = new Proj4Projection(4326, 3857);//4326           
        Proj4Projection proj4 = new Proj4Projection();
        proj4.InternalProjectionParametersString = 
      Proj4Projection.GetEpsgParametersString(4326);
        proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
        proj4.Open();
        shapeFileLayer.FeatureSource.Projection = proj4;

        LayerOverlay staticOverlay = new LayerOverlay();
        staticOverlay.Layers.Add("ShapeLayer",shapeFileLayer);

        Map1.CustomOverlays.Add(google);
        Map1.CustomOverlays.Add(staticOverlay);
        shapeFileLayer.Open();
        Map1.CurrentExtent = shapeFileLayer.GetBoundingBox();
        shapeFileLayer.Close();

Hi Djay,

It looks you don’t set the DefaultAreaStyle for your layer, that means your layer only have label but without shape.

Your other code looks correct, if that still don’t works you can upload your data and we can see why it don’t works.

Regards,

Ethan