Richar,
Don is working the other projects, so I work on this post temporarily for you. Actually the CreatingRequest event will be fired when getting GoogleMaps images, so it will be fired when loading the GoogleMaps layer. Here is my code below:
private void TestForm_Load(object sender, EventArgs e)
{
//We need to set the map unit to meter because we are using Google Map Spherical Mercator projection.
winformsMap1.MapUnit = GeographyUnit.Meter;
winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 198, 255, 255));
//Sets Google Map as the background map.
GoogleMapsLayer googleMapsOverlay = new GoogleMapsLayer();
googleMapsOverlay.CreatingRequest += new EventHandler<CreatingRequestGoogleMapsLayerEventArgs>(googleMapsOverlay_CreatingRequest);
LayerOverlay overlay = new LayerOverlay();
overlay.Layers.Add(googleMapsOverlay);
winformsMap1.Overlays.Add(overlay);
//Projection to go from Geodetic (Longitude/Latitude) to Google Map projection (Spherical Mercator).
Proj4Projection proj4 = new Proj4Projection();
proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326); //Geodetic projection (Longitude/Latitude).
proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
ShapeFileFeatureLayer schoolShapeLayer = new ShapeFileFeatureLayer(@"..\..\Data\austinschools.shp");
schoolShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimplePointStyle(PointSymbolType.Circle, GeoColor.StandardColors.Red,GeoColor.StandardColors.Black, 9);
schoolShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateMaskTextStyle("NAME", new GeoFont("Arial", 10, DrawingFontStyles.Bold),
new GeoSolidBrush(GeoColor.StandardColors.Black), new AreaStyle(new GeoSolidBrush(GeoColor.StandardColors.LightGoldenrodYellow)), 13, 0);
schoolShapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
//Sets the projection to the shapefile layer.
schoolShapeLayer.FeatureSource.Projection = proj4;
LayerOverlay staticOverlay = new LayerOverlay();
staticOverlay.Layers.Add("SchoolShapeLayer", schoolShapeLayer);
winformsMap1.Overlays.Add(staticOverlay);
//Sets the extent of the map as the bounding box of the shapefile layer as projected (Google Map Spherical Mercator).
schoolShapeLayer.Open();
winformsMap1.CurrentExtent = schoolShapeLayer.GetBoundingBox();
schoolShapeLayer.Close();
winformsMap1.Refresh();
}
void googleMapsOverlay_CreatingRequest(object sender, CreatingRequestGoogleMapsLayerEventArgs e)
{
string requesturl = e.RequestUri.AbsoluteUri;
}
You can set a breakpoint in the CreatingRequest event and check if it is fired. The event can be fired correctly and return the correct request url, here is the returned URL what I tested below:
maps.google.com/maps/api/staticmap?center=30.449858,-98.087311&zoom=10&size=512x512&maptype=roadmap&format=jpg-baseline&key=&sensor=false
When you used the web proxy to access the GoogleMaps layer you can watch the request URL correctly, the latest version of development branch is 5.0.119.0, there are not any exceptions occurred. Please use the code to try again,
Thanks,
Scott,