ThinkGeo.com    |     Blog    |     Wiki    |     Support

Shape File Over GoogleMap

i want to display shape file over Google map
I have tried the code from How do i sample…
bt i am unable to get shape file layer on google map.
Here i am attaching my code…
protected void GetShapeFile()
{
Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF")); //GeoSolidBrush(GeoColor.SimpleColors.White);
//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;
Map1.CurrentExtent = new RectangleShape(-5E-06, 5E-06, 5E-06, -5E-06); //Default RectangleShape
//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.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.DarkGreen, GeoColor.StandardColors.Gray, 2);
        //shapeFileLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("GISID,LU_TYPE", "Arial", 15, DrawingFontStyles.Bold, GeoColor.StandardColors.DeepSkyBlue, 0, 0);
        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);
        Map1.StaticOverlay.Layers.Add("StaticShapeLayer", shapeFileLayer);
        shapeFileLayer.Open();
        Map1.CurrentExtent = shapeFileLayer.GetBoundingBox();
        shapeFileLayer.Close();

        //dynamicOverlay.Layers.Add("InMemoryFeatureLayer", memoryLaer);
        //dynamicOverlay.IsBaseOverlay = false;
        //Map1.CustomOverlays.Add(dynamicOverlay);
                    
        //To get Map Current Extent zoom to country India
        /*InMemoryFeatureLayer inMemoryFeatureLayer = new InMemoryFeatureLayer();
        inMemoryFeatureLayer.InternalFeatures.Add("Ind", new Feature(8557480, 2261925.0422517));
        RectangleShape rshp = new RectangleShape();
        rshp = inMemoryFeatureLayer.InternalFeatures["Ind"].GetBoundingBox();
        PointShape pt = new PointShape();
        pt = rshp.GetCenterPoint();
        Map1.ZoomTo(rshp.GetCenterPoint(), 15000000);*/
    }
    protected void GetColorCodes()
    {
        //Code to get Colors for Structure
        ShapeFileFeatureLayer ColourLayer = (ShapeFileFeatureLayer)((LayerOverlay)Map1.CustomOverlays[1]).Layers["ShapeLayer"];
        AreaStyle areaSt = new AreaStyle();
        areaSt.OutlinePen.Color = GeoColor.StandardColors.Gray;
        ValueStyle valueStyle = new ValueStyle();
        valueStyle.ColumnName = "LU_TYPE";
        valueStyle.ValueItems.Add(new ValueItem("AGRICULTURE", new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(110,162, 222,145)))));
        valueStyle.ValueItems.Add(new ValueItem("COMMERCIAL", new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(110,102,140,255)))));
        valueStyle.ValueItems.Add(new ValueItem("FOREST", new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(130,38,153,0)))));
        valueStyle.ValueItems.Add(new ValueItem("HILLTOP_HILLSLOPE", new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(110, 219, 139, 238)))));
        valueStyle.ValueItems.Add(new ValueItem("INDUSTRIAL", new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(110, 219,139,238)))));
        valueStyle.ValueItems.Add(new ValueItem("PUBLIC SERVICES", new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(110,247,105,144)))));            
        valueStyle.ValueItems.Add(new ValueItem("PUBLIC UTILITY", new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(110,245,245,122)))));
        valueStyle.ValueItems.Add(new ValueItem("RECREATIONAL", new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(110,76,230,0)))));
        valueStyle.ValueItems.Add(new ValueItem("RESIDENTIAL", new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(110, 245, 245, 122)))));
        valueStyle.ValueItems.Add(new ValueItem("SPECIAL AREAS", new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(110,151,219,245)))));
        valueStyle.ValueItems.Add(new ValueItem("TRANSPORT", new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(110,206,203,202)))));
        valueStyle.ValueItems.Add(new ValueItem("VACANT", new AreaStyle(new GeoSolidBrush(GeoColor.StandardColors.White))));
        valueStyle.ValueItems.Add(new ValueItem("WATER", new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(110,127,223,255)))));           
        //valueStyle.ValueItems.Add(new ValueItem("HOSPITAL", new AreaStyle(new GeoSolidBrush(GeoColor.StandardColors.Magenta))));
        ColourLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);
        ColourLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(areaSt);
        Map1.StaticOverlay.Redraw();
    }

Hi Djay,

In fact you can upload your simple sample instead of the code, because if we can directly run your sample, generally we don’t need to ask you about more detail information.

You can follow this guide to quickly create a sample: http://wiki.thinkgeo.com/wiki/map_suite_project_template_guide

For your question I think a sample with your data should be helpful.

Regards,

Ethan