/// <summary> /// Create a Google Maps overlay and add it to the map view. /// </summary> private void DisplayGoogleMaps_Click(object sender, EventArgs e) { GoogleMapsOverlay googleMapsOverlay = new GoogleMapsOverlay(googleApiKey.Text, googleSigningSecret.Text); mapView.Overlays.Add(googleMapsOverlay); mapView.Refresh(); }
private void RenderMap() { winformsMap1.MapUnit = GeographyUnit.Meter; winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#e6e5d1")); winformsMap1.CurrentExtent = new RectangleShape(-10787478.039515, 3885514.4616168, -10759196.432323, 3861498.009642); GoogleMapsOverlay googleMapsOverlay = new GoogleMapsOverlay(); googleMapsOverlay.TileCache = new FileBitmapTileCache("C:\\ImageCache"); winformsMap1.Overlays.Add(googleMapsOverlay); ShapeFileFeatureSource featureSource = new ShapeFileFeatureSource(Path.Combine(rootPath, "DallasCounty-3857.shp")); featureSource.Open(); RoutingLayer routingLayer = new RoutingLayer(); routingLayer.StartPoint = featureSource.GetFeatureById(txtStartId.Text, ReturningColumnsType.NoColumns).GetShape().GetCenterPoint(); routingLayer.EndPoint = featureSource.GetFeatureById(txtEndId.Text, ReturningColumnsType.NoColumns).GetShape().GetCenterPoint(); LayerOverlay routingOverlay = new LayerOverlay(); routingOverlay.Layers.Add("RoutingLayer", routingLayer); winformsMap1.Overlays.Add("RoutingOverlay", routingOverlay); InMemoryFeatureLayer routingExtentLayer = new InMemoryFeatureLayer(); routingExtentLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(new GeoPen(GeoColor.SimpleColors.Green)); routingExtentLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; routingExtentLayer.InternalFeatures.Add(new Feature(new RectangleShape(-10806916.7603168, 3897094.80494128, -10738458.3904247, 3827820.76830281))); routingOverlay.Layers.Add("RoutingExtentLayer", routingExtentLayer); winformsMap1.Refresh(); }
private void InitializeMap() { map.MapUnit = GeographyUnit.Meter; WorldStreetsAndImageryOverlay worldOverlay = new WorldStreetsAndImageryOverlay(); worldOverlay.IsVisible = false; worldOverlay.Projection = WorldStreetsAndImageryProjection.SphericalMercator; worldOverlay.MapType = WorldStreetsAndImageryMapType.Road; map.Overlays.Add("World Kit Map", worldOverlay); GoogleMapsOverlay googleMapOverlay = new GoogleMapsOverlay(); googleMapOverlay.IsVisible = false; map.Overlays.Add("Google Maps", googleMapOverlay); BingMapsOverlay bingMapOverlay = new BingMapsOverlay(); bingMapOverlay.ApplicationId = ""; //Please set your application id. bingMapOverlay.IsVisible = false; map.Overlays.Add("Bing Maps", bingMapOverlay); OpenStreetMapOverlay osmOverlay = new OpenStreetMapOverlay(); osmOverlay.IsVisible = false; map.Overlays.Add("Open Street Map", osmOverlay); }
private void TestForm_Load(object sender, EventArgs e) { winformsMap1.MapUnit = GeographyUnit.Meter; winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.StandardColors.Snow); //Background map with Google Map. GoogleMapsOverlay googleMapsOverlay = new GoogleMapsOverlay(); winformsMap1.Overlays.Add(googleMapsOverlay); //Applies class break style to show sample points of pH level of a field. ClassBreakStyle classBreakStyle = new ClassBreakStyle("PH"); int Alpha = 180; int symbolSize = 10; classBreakStyle.ClassBreaks.Add(new ClassBreak(double.MinValue, new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.SimpleColors.Transparent), symbolSize))); classBreakStyle.ClassBreaks.Add(new ClassBreak(6.2, new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(Alpha, 255, 0, 0)), symbolSize))); classBreakStyle.ClassBreaks.Add(new ClassBreak(6.83, new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(Alpha, 255, 128, 0)), symbolSize))); classBreakStyle.ClassBreaks.Add(new ClassBreak(7.0, new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(Alpha, 245, 210, 10)), symbolSize))); classBreakStyle.ClassBreaks.Add(new ClassBreak(7.08, new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(Alpha, 225, 255, 0)), symbolSize))); classBreakStyle.ClassBreaks.Add(new ClassBreak(7.15, new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(Alpha, 224, 251, 132)), symbolSize))); classBreakStyle.ClassBreaks.Add(new ClassBreak(7.21, new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(Alpha, 128, 255, 128)), symbolSize))); classBreakStyle.ClassBreaks.Add(new ClassBreak(7.54, new PointStyle(PointSymbolType.Circle, new GeoSolidBrush(GeoColor.FromArgb(Alpha, 0, 255, 0)), symbolSize))); ShapeFileFeatureLayer samplesLayer = new ShapeFileFeatureLayer(@"..\..\data\sample_ph_2.shp"); samplesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(classBreakStyle); samplesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; LayerOverlay gridOverlay = new LayerOverlay(); gridOverlay.Layers.Add("GridFeatureLayer", samplesLayer); winformsMap1.Overlays.Add("GridFeatureOverlay", gridOverlay); samplesLayer.Open(); winformsMap1.CurrentExtent = samplesLayer.GetBoundingBox(); samplesLayer.Close(); winformsMap1.Refresh(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { //Sets the correct map unit and the extent of the map. wpfMap1.MapUnit = GeographyUnit.Meter; wpfMap1.CurrentExtent = new RectangleShape(-13086298.60, 7339062.72, -8111177.75, 2853137.62); wpfMap1.Background = new SolidColorBrush(Color.FromRgb(148, 196, 243)); GoogleMapsOverlay googleMapsOverlay = new GoogleMapsOverlay(); wpfMap1.Overlays.Add(googleMapsOverlay); //Custom projection that will allow to project from State Plane Central North Texas to Spherical Mercator while applying a rotation. customRotationProjection = new Projections.CustomRotationProjection(Proj4Projection.GetEsriParametersString(102738), Proj4Projection.GetGoogleMapParametersString()); ShapeFileFeatureLayer streetLayer = new ShapeFileFeatureLayer(@"../../data/Streets_subset.shp"); streetLayer.FeatureSource.Projection = customRotationProjection; streetLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.CreateSimpleLineStyle (GeoColor.StandardColors.Red, 3, GeoColor.FromArgb(255, GeoColor.StandardColors.Black), 5, true); streetLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; LayerOverlay layerOverlay = new LayerOverlay(); layerOverlay.Layers.Add("StreetLayer", streetLayer); wpfMap1.Overlays.Add("StreetOverlay", layerOverlay); //Sets the pivot point to be the center of the layer. streetLayer.Open(); customRotationProjection.PivotVertex = new Vertex(streetLayer.GetBoundingBox().GetCenterPoint()); streetLayer.Close(); customRotationProjection.Angle = 20; wpfMap1.Refresh(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.DisplayMapView); androidMap = FindViewById <MapView>(Resource.Id.androidmap); androidMap.MapUnit = GeographyUnit.Meter; androidMap.ZoomLevelSet = new SphericalMercatorZoomLevelSet(); GoogleMapsOverlay googleMapsOverlay = new GoogleMapsOverlay(); googleMapsOverlay.TileType = TileType.MultiTile; androidMap.Overlays.Add(googleMapsOverlay); Proj4Projection proj4 = new Proj4Projection(); proj4.InternalProjectionParametersString = Proj4Projection.GetDecimalDegreesParametersString(); proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString(); proj4.Open(); androidMap.CurrentExtent = proj4.ConvertToExternalProjection(new RectangleShape(-139.2, 92.4, 120.9, -93.2)) as RectangleShape; SampleViewHelper.InitializeInstruction(this, FindViewById <RelativeLayout>(Resource.Id.MainLayout), GetType()); }
public static GoogleMapsOverlay CreateGoogleMapsOverlay() { string cacheDirectory = Path.Combine(Path.GetTempPath(), "TileCache"); const string googleMapsOverlayName = "Google Maps"; GoogleMapsOverlay googleMapsOverlay = new GoogleMapsOverlay(); // Set the name of overlay and it will be displayed in the swicher overlay. googleMapsOverlay.Name = googleMapsOverlayName; // Set the image format as Jpeg. The default value is Png. googleMapsOverlay.ImageFormat = TileImageFormat.Jpeg; // Set the height and width of the image. The default value is 256. googleMapsOverlay.TileHeight = 512; googleMapsOverlay.TileWidth = 512; googleMapsOverlay.TileCache = new FileBitmapTileCache(cacheDirectory, googleMapsOverlayName); return googleMapsOverlay; }
private void TestForm_Load(object sender, EventArgs e) { winformsMap1.MapUnit = GeographyUnit.Meter; winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 198, 255, 255)); GoogleMapsOverlay googleOverlay = new GoogleMapsOverlay(); //(@"Insert your key here!", @"C:\GoogleCache"); googleOverlay.MapType = GoogleMapsMapType.Terrain; winformsMap1.Overlays.Add(googleOverlay); // This sets the zoom levels to map to Googles. We next make sure we snap to the zoomlevels winformsMap1.ZoomLevelSet = new GoogleMapsZoomLevelSet(); InMemoryFeatureLayer pointLayer = new InMemoryFeatureLayer(); pointLayer.Open(); pointLayer.Columns.Add(new FeatureSourceColumn("Text")); pointLayer.Close(); //Sets the projection parameters to go from Geodetic (EPSG 4326) or decimal degrees to Google Map projection (Spherical Mercator). Proj4Projection proj4 = new Proj4Projection(); proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326); proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString(); //Applies the projection to the InMemoryFeatureLayer so that the point in decimal degrees (Longitude/Latitude) can be //match the projection of Google Map. pointLayer.FeatureSource.Projection = proj4; //Values in Longitude and Latitude. double Longitude = -95.2809; double Latitude = 38.9543; //Creates the feature made of a PointShape with the Longitude and Latitude values. Feature GPSFeature = new Feature(new PointShape(Longitude, Latitude)); //Format the Longitude and Latitude into a nice string as Degrees Minutes and Seconds string LongLat = DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegreePoint(GPSFeature); //Sets the InMemoryFeatureLayer to have it displayed with Square symbol and with text. GPSFeature.ColumnValues.Add("Text", LongLat); pointLayer.InternalFeatures.Add(GPSFeature); pointLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimplePointStyle(PointSymbolType.Square, GeoColor.StandardColors.Red, GeoColor.StandardColors.Black, 2, 12); pointLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("Text", "Arial", 12, DrawingFontStyles.Bold, GeoColor.StandardColors.Black, GeoColor.StandardColors.White, 3, -10, 10); pointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; LayerOverlay pointOverlay = new LayerOverlay(); pointOverlay.Layers.Add("PointLayer", pointLayer); winformsMap1.Overlays.Add("PointOverlay", pointOverlay); //Sets the extend of the map based on the GPS point. proj4.Open(); Vertex projVertex = proj4.ConvertToExternalProjection(Longitude, Latitude); proj4.Close(); double extendWidth = 2300; double extendHeight = 1200; winformsMap1.CurrentExtent = new RectangleShape((projVertex.X - extendWidth), (projVertex.Y + extendHeight), (projVertex.X + extendWidth), (projVertex.Y - extendHeight)); winformsMap1.Refresh(); }