ThinkGeo.com    |     Documentation    |     Premium Support

Adding custom Shapefiles to Bing

I have reviewed the tutorial and still cannot get this to work, please point out any mistake i am making.

I will post the code below. i cant get the feature layers to add correctly any help would be greatly appreciated.


@{Html.ThinkGeo().Map("Map1", new System.Web.UI.WebControls.Unit(100, System.Web.UI.WebControls.UnitType.Percentage), 548)
                     .MapBackground(new BackgroundLayer(new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"))))
                     .CurrentExtent(-11359342, 4616228 ,- 11302243, 4542543)
                     .MapUnit(GeographyUnit.DecimalDegree)
                     .MapTools(tools =>
                         {
                             tools.OverlaySwitcherMapTool().Enabled(true);  
                         })
                     .CustomOverlays(overlays =>
                     {
                         overlays.BingMapsOverlay("Bing Map").MapType(BingMapsStyle.Hybrid);
                         overlays.InMemoryMarkerOverlay("MarkerOverlayD")
                           .ZoomLevelSet(z =>
                            {
 
                                z.ZoomLevel01.DefaultMarkerStyle.WebImage.ImageOffsetX = -10.5f;
                                z.ZoomLevel01.DefaultMarkerStyle.WebImage.ImageOffsetY = -25f;
                                z.ZoomLevel01.DefaultMarkerStyle.WebImage.ImageWidth = 21;
                                z.ZoomLevel01.DefaultMarkerStyle.WebImage.ImageHeight = 25;
                                z.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                                 
                            });
                         overlays.InMemoryMarkerOverlay("MarkerOverlayS")
                             .ZoomLevelSet(x =>
                              {
                                  x.ZoomLevel01.DefaultMarkerStyle.WebImage.ImageOffsetX = -10.5f;
                                  x.ZoomLevel01.DefaultMarkerStyle.WebImage.ImageOffsetY = -25f;
                                  x.ZoomLevel01.DefaultMarkerStyle.WebImage.ImageWidth = 21;
                                  x.ZoomLevel01.DefaultMarkerStyle.WebImage.ImageHeight = 25;
                                  x.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                              });
                         FeatureLayer lyrAddresses = new ShapeFileFeatureLayer(Server.MapPath("~/App_Data/addresspoints.shp"));
                         lyrAddresses.ZoomLevelSet.ZoomLevel09.DefaultPointStyle = ThinkGeo.MapSuite.Core.PointStyles.CreateSimpleStarStyle(GeoColor.StandardColors.Red, 5, GeoColor.StandardColors.RoyalBlue);
                         lyrAddresses.ZoomLevelSet.ZoomLevel09.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level15;
                         lyrAddresses.ZoomLevelSet.ZoomLevel16.DefaultPointStyle = ThinkGeo.MapSuite.Core.PointStyles.CreateSimpleTriangleStyle(GeoColor.StandardColors.HotPink, 7, GeoColor.StandardColors.HotPink);
                         lyrAddresses.ZoomLevelSet.ZoomLevel16.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                         FeatureLayer lyrAddressLabels = new ShapeFileFeatureLayer(Server.MapPath("~/App_Data/addresspoints.shp"));
                         lyrAddressLabels.ZoomLevelSet.ZoomLevel17.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("FULLADDRES", "Arial", 8, DrawingFontStyles.Bold, GeoColor.StandardColors.Red, 6, 0);
                         lyrAddressLabels.ZoomLevelSet.ZoomLevel17.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                         lyrAddressLabels.DrawingMarginPercentage = 50;
                         Proj4Projection proj4 = new Proj4Projection();
                         proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(3420);
 
                         proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
                         lyrAddresses.FeatureSource.Projection = proj4;
                         lyrAddressLabels.FeatureSource.Projection = proj4;
                         proj4.Open();
                         overlays.LayerOverlay("Address Points", false, TileType.SingleTile).Layer(lyrAddresses);
          
                          
 
                     })
                     .OnClientDoubleClick("mapClick")
                     .Render();
                           }


Hi Gordon,



The problem is that you are using “.MapUnit(GeographyUnit.DecimalDegree)”, please use “.MapUnit(GeographyUnit.Meter)” instead.



Thanks,

Johnny