I would like to have google base maps shown when I zoom in. I have a button for zooming in the my area of interest. I get configuration manager does not exist in current context error message. Note that I am not good at VB. So I guess it some thing not well defined.Pleas help. .
using ThinkGeo.MapSuite.WebEdition;
using ThinkGeo.MapSuite.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebmAP
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// Set the Map Unit. The reason for setting it to DecimalDegrees is that is what the shapefile’s unit of measure is inherently in.
Map1.MapUnit = GeographyUnit.DecimalDegree;
// We create a new Layer and pass the path to a Shapefile into its constructor.
ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@“C:\Program Files\ThinkGeo\Map Suite Web Evaluation Edition 4.5\Samples\CSharp Samples\SampleData\World\cntry02.shp”);
// Set the worldLayer with a preset Style, as AreaStyles.Country1 has YellowGreen background and black border, our worldLayer will have the same render style.
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
// This setting will apply from ZoonLevel01 to ZoomLevel20, that means we can see the world the same style with ZoomLevel01 all the time no matter how far we zoom out/in.
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level17;
ShapeFileFeatureLayer roadLayer = new ShapeFileFeatureLayer(@“C:\Pers_2010\IT_Lessons\MSWeb_ED\shp_files\Roads\Road_arc.shp”);
ShapeFileFeatureLayer.BuildIndexFile(@“C:\Pers_2010\IT_Lessons\MSWeb_ED\shp_files\Roads\Road_arc.shp”);
// We can customize our own Style. Here we passed in a color and a size.
roadLayer.ZoomLevelSet.ZoomLevel05.DefaultLineStyle = LineStyles.LocalRoad4;
// The Style we set here is available from ZoomLevel10 to ZoomLevel20. That means if we zoom in a bit out, the appearance we set here will not be visible anymore.
roadLayer.ZoomLevelSet.ZoomLevel05.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level14;
roadLayer.ZoomLevelSet.ZoomLevel15.DefaultLineStyle = LineStyles.LocalRoad3;
// The Style we set here is available from ZoomLevel10 to ZoomLevel20. That means if we zoom in a bit out, the appearance we set here will not be visible anymore.
roadLayer.ZoomLevelSet.ZoomLevel15.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
ShapeFileFeatureLayer capitalLayer = new ShapeFileFeatureLayer(@“C:\Program Files\ThinkGeo\Map Suite Web Evaluation Edition 4.5\Samples\CSharp Samples\SampleData\World\capital.shp”);
// We can customize our own Style. Here we passed in a color and a size.
capitalLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.StandardColors.White, 7, GeoColor.StandardColors.Brown);
// The Style we set here is available from ZoomLevel01 to ZoomLevel05. That means if we zoom in a bit more, the appearance we set here will not be visible anymore.
capitalLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level04;
capitalLayer.ZoomLevelSet.ZoomLevel05.DefaultPointStyle = PointStyles.Capital3;
capitalLayer.ZoomLevelSet.ZoomLevel05.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level07;
ShapeFileFeatureLayer bizLayer = new ShapeFileFeatureLayer(@“C:\Pers_2010\IT_Lessons\MSWeb_ED\shp_files\BIZ\Biz_pts.shp”);
ShapeFileFeatureLayer.BuildIndexFile(@“C:\Pers_2010\IT_Lessons\MSWeb_ED\shp_files\BIZ\Biz_pts.shp”);
bizLayer.ZoomLevelSet.ZoomLevel10.DefaultPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.StandardColors.White, 4, GeoColor.StandardColors.Brown);
bizLayer.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
// We create a new Layer for labeling the capitals.
ShapeFileFeatureLayer capitalLabelLayer = new ShapeFileFeatureLayer(@“C:\Program Files\ThinkGeo\Map Suite Web Evaluation Edition 4.5\Samples\CSharp Samples\SampleData\World\capital.shp”);
ShapeFileFeatureLayer bizLabelLayer = new ShapeFileFeatureLayer(@“C:\Pers_2010\IT_Lessons\MSWeb_ED\shp_files\BIZ\Biz_pts.shp”);
// We can customize our own TextStyle. Here we passed in the font, the size, the style and the color.
capitalLabelLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle(“CITY_NAME”, “Arial”, 8, DrawingFontStyles.Italic, GeoColor.StandardColors.Black, 3, 3);
// The TextStyle we set here is available from ZoomLevel01 to ZoomLevel05.
capitalLabelLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level04;
capitalLabelLayer.ZoomLevelSet.ZoomLevel05.DefaultTextStyle = TextStyles.Capital3(“CITY_NAME”);
capitalLabelLayer.ZoomLevelSet.ZoomLevel05.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level10;
bizLabelLayer.ZoomLevelSet.ZoomLevel13.DefaultTextStyle = TextStyles.Capital2(“PNMAE”);
bizLabelLayer.ZoomLevelSet.ZoomLevel13.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
// As the map is drawn by tiles, it needs to draw on the margin to make sure the text is complete after we joining the tiles together.
// Change the number to another one (for example 0) and you can see the difference.
capitalLabelLayer.DrawingMarginPercentage = 50;
bizLabelLayer.DrawingMarginPercentage = 100;
Map1.StaticOverlay.Layers.Add(worldLayer);
Map1.StaticOverlay.Layers.Add(capitalLayer);
// Add the label layer to Map.
Map1.StaticOverlay.Layers.Add(capitalLabelLayer);
Map1.StaticOverlay.Layers.Add(roadLayer);
Map1.StaticOverlay.Layers.Add(bizLayer);
Map1.StaticOverlay.Layers.Add(bizLabelLayer);
// Set a proper extent for the map, that’s the place you want it to display.
Map1.CurrentExtent = new RectangleShape(5, 40, 40, -26);
// Set the background color to make the map beautiful.
Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Map1.CurrentExtent = new RectangleShape(30, 4, 36, -1);
if (!Map1.MarkerOverlay.Features.Contains(“Marker”))
{
// Add a new feature as a marker
Map1.MarkerOverlay.Features.Add(“Marker”, new Feature(32.6, 0.4));
// Set the marker style, and make it available all over the zoomlevels.
Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.WebImage = new WebImage("…/…/theme/default/img/marker_blue.gif", 21, 25);
Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level10;
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Map1.CurrentExtent = new RectangleShape(32.45, 0.5, 32.7, 0.25);
Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);
Map1.CurrentExtent = new RectangleShape(-13939426.6371, 6701997.4056, -7812401.86, 2626987.386962);
Map1.MapUnit = GeographyUnit.Meter;
GoogleOverlay google = new GoogleOverlay(“Google Map”);
google.JavaScriptLibraryUri = new Uri(ConfigurationManager.AppSettings[“GoogleUri”]);
google.IsBaseOverlay = false;
google.GoogleMapType = GoogleMapType.Hybrid;
Map1.CustomOverlays.Add(overlay);
Map1.CustomOverlays.Add(google);
Map1.OnClientExtentChanged = “updateZindex”;
}
}
}