I’m just learning how to use the Map Suite MVC Edition for use in a project and have encountered odd behavior. The code is very rough and dirty, as this is just me playing around with some of the features in a practice project and making sure the client’s data loads. It’s modeled after the Quick Start guide and a few others. The basic idea for this test is to have an OpenStreetMaps base layer and then using the layer selection tool to toggle some additional layers based on data from the client. I am getting inconsistent behavior when it comes to rendering the page. Sometimes the either one or both areas will have holes in them where that particular layer just doesn’t render. Other times, the whole layer fails to render with the message “points must form a closed linestring” displayed on top of the map in the top left corner near the zoom and pan tools. The most perplexing thing is that it seems to change between working seemingly correctly or giving the above behaviors simply from panning or zooming with no discernible consistency to help me narrow down why. Furthermore, it doesn’t appear to be consistent between each time I attempt to run the code. I’ve attached a zip containing a screen grab showcasing the hole. The hole is roughly near the center of the picture. One layer is set to render in a partially transparent red, while the other is set to render in a partially transparent blue. The blue area in the purple blob shows where the red layer isn’t rendering. Here is the code block I’m using to setup and render the map. The two shapefiles referenced are the client’s data which are in NAD83 projection(EPSG:4269).
Html.ThinkGeo().Map(
“Map1”
,
new
System.Web.UI.WebControls.Unit(100, System.Web.UI.WebControls.UnitType.Percentage),
new
System.Web.UI.WebControls.Unit(100,System.Web.UI.WebControls.UnitType.Percentage))
.MapBackground(
new
BackgroundLayer(
new
GeoSolidBrush(GeoColor.FromHtml(
"#E5E3DF"
))))
.CurrentExtent(-8926320, 4948463, -8878542, 4909473)
.MapUnit(GeographyUnit.Meter)
.MapTools(tools =>
{
tools.MouseCoordinateMapTool().Enabled(
true
);
tools.OverlaySwitcherMapTool().Enabled(
true
);
})
.CustomOverlays(overlays =>
{
overlays.OpenStreetMapOverlay(
“Open Street Map”
);
//Projection from NAD83 to OpenStreetMaps
Proj4Projection proj4 =
new
Proj4Projection();
proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4269);
proj4.ExternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(3857);
// Zip Layer
FeatureLayer ziplayer =
new
ShapeFileFeatureLayer(Server.MapPath(@
"\App_Data\Zips.shp"
));
ziplayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle =
AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(50, GeoColor.StandardColors.Red), GeoColor.StandardColors.Purple);
ziplayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle =
TextStyles.CreateSimpleTextStyle(
“ZIP”
,
“Arial”
, 8, DrawingFontStyles.Regular, GeoColor.StandardColors.Black);
ziplayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
proj4.Open();
ziplayer.FeatureSource.Projection = proj4;
ClientCache mapCache =
new
ClientCache(
new
TimeSpan(1, 0, 0),
“mapCache”
);
overlays.LayerOverlay(
“Zip”
,
false
, TileType.SingleTile).Layer(ziplayer).ClientCache(mapCache);
//Zone Layer
ShapeFileFeatureLayer zoneLayer =
new
ShapeFileFeatureLayer(Server.MapPath(@
"\App_Data\Zones.shp"
));
zoneLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle=
AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(50, GeoColor.StandardColors.Blue), GeoColor.StandardColors.Green);
zoneLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle =
TextStyles.CreateSimpleTextStyle(
“ZONE”
,
“Arial”
, 8, DrawingFontStyles.Regular, GeoColor.StandardColors.Chartreuse);
zoneLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
proj4.Open();
zoneLayer.FeatureSource.Projection = proj4;
overlays.LayerOverlay(
“Zones”
,
false
, TileType.SingleTile).Layer(zoneLayer).ClientCache(mapCache);
})
.Render();