protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.DisplayMapView);

            RegexStyle regexStyle = new RegexStyle();

            regexStyle.ColumnName = "CNTRY_NAME";
            regexStyle.RegexItems.Add(new RegexItem(".*land", new AreaStyle(new GeoSolidBrush(GeoColor.StandardColors.LightGreen))));

            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath(@"SampleData/Countries02.shp"));

            worldLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(255, 233, 232, 214), GeoColor.FromArgb(255, 118, 138, 69)));
            worldLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(regexStyle);
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay layerOverlay = new LayerOverlay();

            layerOverlay.Layers.Add(worldLayer);

            androidMap               = FindViewById <MapView>(Resource.Id.androidmap);
            androidMap.MapUnit       = GeographyUnit.DecimalDegree;
            androidMap.CurrentExtent = new RectangleShape(-135.7, 83.6, 113.5, -53);
            androidMap.Overlays.Add(layerOverlay);

            SampleViewHelper.InitializeInstruction(this, FindViewById <RelativeLayout>(Resource.Id.MainLayout), GetType());
        }
        private void DrawFeaturesBasedRegexExpression_Load(object sender, EventArgs e)
        {
            winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);

            WorldMapKitWmsDesktopOverlay worldMapKitDesktopOverlay = new WorldMapKitWmsDesktopOverlay();

            winformsMap1.Overlays.Add(worldMapKitDesktopOverlay);

            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(Samples.RootDirectory + @"Data\Countries02.SHP");

            worldLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(100, GeoColor.SimpleColors.Green)));
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            // Draw features based regular expression
            RegexStyle regexStyle = new RegexStyle();

            regexStyle.ColumnName = "CNTRY_NAME";
            regexStyle.RegexItems.Add(new RegexItem(".*land", new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, GeoColor.SimpleColors.Green)))));
            worldLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(regexStyle);

            LayerOverlay worldOverlay = new LayerOverlay();

            worldOverlay.Layers.Add("WorldLayer", worldLayer);
            winformsMap1.Overlays.Add(worldOverlay);

            winformsMap1.ZoomLevelSnapping = ZoomLevelSnappingMode.Default;
            winformsMap1.CurrentExtent     = new RectangleShape(-75.0, 83.0, 176.0, -50.0);
            winformsMap1.Refresh();
        }
Example #3
0
        private void Form_Load(object sender, EventArgs e)
        {
            // Set the map's unit of measurement to meters(Spherical Mercator)
            mapView.MapUnit = GeographyUnit.Meter;

            // Add Cloud Maps as a background overlay
            var thinkGeoCloudVectorMapsOverlay = new ThinkGeoCloudVectorMapsOverlay("itZGOI8oafZwmtxP-XGiMvfWJPPc-dX35DmESmLlQIU~", "bcaCzPpmOG6le2pUz5EAaEKYI-KSMny_WxEAe7gMNQgGeN9sqL12OA~~", ThinkGeoCloudVectorMapsMapType.Light);

            mapView.Overlays.Add(thinkGeoCloudVectorMapsOverlay);

            ShapeFileFeatureLayer coyoteSightings = new ShapeFileFeatureLayer(@"../../../Data/Shapefile/Frisco_Coyote_Sightings.shp");

            // Project the layer's data to match the projection of the map
            coyoteSightings.FeatureSource.ProjectionConverter = new ProjectionConverter(2276, 3857);

            // Add the layer to a layer overlay
            var layerOverlay = new LayerOverlay();

            layerOverlay.Layers.Add("coyoteSightings", coyoteSightings);

            // Add the overlay to the map
            mapView.Overlays.Add(layerOverlay);

            // Create a regex style and item that looks for big / large / huge based on the comments
            // from users and draws them differently
            RegexStyle regexStyle = new RegexStyle();

            regexStyle.ColumnName = "Comments";

            RegexItem largeItem = new RegexItem("big|large|huge", new PointStyle(PointSymbolType.Circle, 12, GeoBrushes.Red));

            regexStyle.RegexItems.Add(largeItem);

            // We have a default drawing style for every sighting
            PointStyle allSightingsStyle = new PointStyle(PointSymbolType.Circle, 5, GeoBrushes.Green);

            // Add the point style to the collection of custom styles for ZoomLevel 1.
            coyoteSightings.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(allSightingsStyle);
            coyoteSightings.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(regexStyle);

            // Apply the styles for ZoomLevel 1 down to ZoomLevel 20. This effectively applies the point style on every zoom level on the map.
            coyoteSightings.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            // Set the map extent
            mapView.CurrentExtent = new RectangleShape(-10781794.4716492, 3917077.66579861, -10775416.8466492, 3913528.63559028);
        }
Example #4
0
        /// <summary>
        /// Setup the map with the ThinkGeo Cloud Maps overlay.
        /// </summary>
        protected override void OnAppearing()
        {
            base.OnAppearing();

            // Set the map's unit of measurement to meters(Spherical Mercator)
            mapView.MapUnit = GeographyUnit.Meter;

            // Add Cloud Maps as a background overlay
            var thinkGeoCloudVectorMapsOverlay = new ThinkGeoCloudVectorMapsOverlay("itZGOI8oafZwmtxP-XGiMvfWJPPc-dX35DmESmLlQIU~", "bcaCzPpmOG6le2pUz5EAaEKYI-KSMny_WxEAe7gMNQgGeN9sqL12OA~~", ThinkGeoCloudVectorMapsMapType.Light);

            mapView.Overlays.Add(thinkGeoCloudVectorMapsOverlay);

            ShapeFileFeatureLayer coyoteSightings = new ShapeFileFeatureLayer(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Data/Shapefile/Frisco_Coyote_Sightings.shp"));

            // Project the layer's data to match the projection of the map
            coyoteSightings.FeatureSource.ProjectionConverter = new ProjectionConverter(2276, 3857);

            // Add the layer to a layer overlay
            var layerOverlay = new LayerOverlay();

            layerOverlay.Layers.Add("coyoteSightings", coyoteSightings);

            // Add the overlay to the map
            mapView.Overlays.Add(layerOverlay);

            RegexStyle regexStyle = new RegexStyle();

            regexStyle.ColumnName = "Comments";

            RegexItem largeItem = new RegexItem("big|large|huge", new PointStyle(PointSymbolType.Circle, 12, GeoBrushes.Red));

            regexStyle.RegexItems.Add(largeItem);

            PointStyle allSightingsStyle = new PointStyle(PointSymbolType.Circle, 5, GeoBrushes.Green);

            // Add the point style to the collection of custom styles for ZoomLevel 1.
            coyoteSightings.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(allSightingsStyle);
            coyoteSightings.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(regexStyle);

            // Apply the styles for ZoomLevel 1 down to ZoomLevel 20. This effectively applies the point style on every zoom level on the map.
            coyoteSightings.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            // Set the map extent
            mapView.CurrentExtent = new RectangleShape(-10781794.4716492, 3917077.66579861, -10775416.8466492, 3913528.63559028);
        }
        public static bool CheckIsValid(this Style style)
        {
            AreaStyle       areaStyle       = style as AreaStyle;
            LineStyle       lineStyle       = style as LineStyle;
            PointStyle      pointStyle      = style as PointStyle;
            TextStyle       textStyle       = style as TextStyle;
            DotDensityStyle dotDensityStyle = style as DotDensityStyle;
            ClassBreakStyle classBreakStyle = style as ClassBreakStyle;
            RegexStyle      regexStyle      = style as RegexStyle;
            FilterStyle     filterStyle     = style as FilterStyle;
            CompositeStyle  componentStyle  = style as CompositeStyle;

            bool isStyleValid = style.IsActive && !string.IsNullOrEmpty(style.Name);

            if (areaStyle != null)
            {
                isStyleValid &= (!areaStyle.FillSolidBrush.Color.IsTransparent ||
                                 !areaStyle.OutlinePen.Color.IsTransparent ||
                                 areaStyle.Advanced.FillCustomBrush != null);
            }
            else if (lineStyle != null)
            {
                isStyleValid &= (!lineStyle.CenterPen.Color.IsTransparent ||
                                 !lineStyle.OuterPen.Color.IsTransparent ||
                                 !lineStyle.InnerPen.Color.IsTransparent);
            }
            else if (pointStyle != null)
            {
                switch (pointStyle.PointType)
                {
                case PointType.Symbol:
                    isStyleValid &= (!pointStyle.SymbolPen.Color.IsTransparent ||
                                     pointStyle.Image != null ||
                                     !pointStyle.SymbolSolidBrush.Color.IsTransparent ||
                                     pointStyle.Advanced.CustomBrush != null);
                    break;

                case PointType.Bitmap:
                    isStyleValid &= pointStyle.Image != null;
                    break;

                case PointType.Character:
                    isStyleValid &= pointStyle.CharacterFont != null &&
                                    (!pointStyle.CharacterSolidBrush.Color.IsTransparent ||
                                     pointStyle.Advanced.CustomBrush != null);
                    break;

                default:
                    break;
                }
            }
            else if (textStyle != null)
            {
                isStyleValid &= !string.IsNullOrEmpty(textStyle.TextColumnName) &&
                                (!textStyle.HaloPen.Color.IsTransparent ||
                                 !textStyle.TextSolidBrush.Color.IsTransparent ||
                                 textStyle.Advanced.TextCustomBrush != null);
            }
            else if (dotDensityStyle != null)
            {
                isStyleValid &= !string.IsNullOrEmpty(dotDensityStyle.ColumnName) &&
                                (dotDensityStyle.CustomPointStyle != null &&
                                 CheckIsValid(dotDensityStyle.CustomPointStyle) &&
                                 dotDensityStyle.PointToValueRatio != 0);
            }
            else if (classBreakStyle != null)
            {
                isStyleValid &= !string.IsNullOrEmpty(classBreakStyle.ColumnName) &&
                                classBreakStyle.ClassBreaks.Count != 0;
            }
            else if (regexStyle != null)
            {
                isStyleValid &= !string.IsNullOrEmpty(regexStyle.ColumnName) &&
                                regexStyle.RegexItems.Count != 0;
            }
            else if (filterStyle != null)
            {
                isStyleValid &= filterStyle.Conditions.Count > 0;
            }
            else if (componentStyle != null)
            {
                isStyleValid = true;
            }
            return(isStyleValid);
        }