Ejemplo n.º 1
0
        /// <summary>
        /// Display a popup containing a feature's info
        /// </summary>
        private void DisplayFeatureInfo(Collection <Feature> features)
        {
            if (features.Count > 0)
            {
                StringBuilder weatherWarningString = new StringBuilder();

                // Each column in a feature is a data attribute
                // Add all attribute pairs to the info string


                foreach (Feature feature in features)
                {
                    weatherWarningString.AppendLine($"{feature.ColumnValues["TITLE"]}");
                }

                // Create a new popup with the park info string
                PopupOverlay popupOverlay = (PopupOverlay)mapView.Overlays["Info Popup Overlay"];
                Popup        popup        = new Popup(features[0].GetShape().GetCenterPoint());
                popup.Content    = weatherWarningString.ToString();
                popup.FontSize   = 10d;
                popup.FontFamily = new System.Windows.Media.FontFamily("Verdana");

                // Clear the popup overlay and add the new popup to it
                popupOverlay.Popups.Clear();
                popupOverlay.Popups.Add(popup);

                // Refresh the overlay to redraw the popups
                popupOverlay.Refresh();
            }
        }
        private void UpdateElementsRotation(double angle)
        {
            LayerOverlay          layerOverlay = (LayerOverlay)Map1.Overlays["LayerOverlay"];
            ShapeFileFeatureLayer worldLayer   = (ShapeFileFeatureLayer)layerOverlay.Layers["SampleLayer"];

            worldLayer.Open();

            SimpleMarkerOverlay markerOverlay = (SimpleMarkerOverlay)Map1.Overlays["MarkerOverlay"];

            foreach (var marker in markerOverlay.Markers)
            {
                marker.RenderTransform = new RotateTransform(-angle, marker.ActualWidth / 2, marker.ActualHeight);
            }

            PopupOverlay popupOverlay = (PopupOverlay)Map1.Overlays["PopupOverlay"];

            foreach (var popup in popupOverlay.Popups)
            {
                popup.RenderTransform = new RotateTransform(-angle, popup.ActualWidth, popup.ActualHeight);
            }

            if (worldLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle != null)
            {
                worldLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.RotationAngle = angle;
            }
        }
        private void MapView_Loaded(object sender, RoutedEventArgs e)
        {
            mapView.MapUnit       = GeographyUnit.Meter;
            mapView.CurrentExtent = new RectangleShape(-10881016, 3541873, -10879054, 3540253);


            ShapeFileFeatureLayer roadLayer = new ShapeFileFeatureLayer(SampleHelper.Get("austinstreets_3857.shp"));

            roadLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            roadLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle    = LineStyle.CreateSimpleLineStyle(GeoColors.White, 9.2F, GeoColors.DarkGray, 12.2F, true);

            LayerOverlay roadOverlay = new LayerOverlay();

            roadOverlay.Layers.Add(new BackgroundLayer(new GeoSolidBrush(GeoColor.FromArgb(255, 233, 232, 214))));
            roadOverlay.Layers.Add("RoadLayer", roadLayer);
            mapView.Overlays.Add("RoadOverlay", roadOverlay);

            InMemoryFeatureLayer highlightLayer = new InMemoryFeatureLayer();

            highlightLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyle.CreateSimpleLineStyle(GeoColors.White, 9.2F, GeoColors.DarkGray, 12.2F, true);
            highlightLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.InnerPen.Brush = new GeoSolidBrush(GeoColor.FromArgb(150, GeoColors.Blue));
            highlightLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel             = ApplyUntilZoomLevel.Level20;

            LayerOverlay highlightOverlay = new LayerOverlay();

            highlightOverlay.Layers.Add("HighlightLayer", highlightLayer);
            mapView.Overlays.Add("HighlightOverlay", highlightOverlay);

            PopupOverlay popupOverlay = new PopupOverlay();

            mapView.Overlays.Add("PopupOverlay", popupOverlay);

            mapView.Refresh();
        }
Ejemplo n.º 4
0
        public static void MarkerMouseClick(object sender, MouseButtonEventArgs e)
        {
            Marker currentMarker = (Marker)sender;

            if (e.ChangedButton == MouseButton.Left)
            {
                ClosablePopup attachedPopup = currentMarker.Tag as ClosablePopup;
                PopupOverlay  popupOverlay  = CurrentOverlays.PopupOverlay;
                if (attachedPopup == null || !popupOverlay.Popups.Contains(attachedPopup))
                {
                    PointShape position = new PointShape(currentMarker.Position.X, currentMarker.Position.Y);
                    attachedPopup                = new ClosablePopup(position);
                    attachedPopup.ParentMap      = GisEditor.ActiveMap;
                    attachedPopup.WorkingContent = GetWorkingContent(position);
                    SetPopupOffset(attachedPopup);
                    popupOverlay.Popups.Add(attachedPopup);

                    GisEditor.ActiveMap.Refresh(popupOverlay);
                    currentMarker.Tag = attachedPopup;
                }

                if (attachedPopup != null && attachedPopup.Visibility == Visibility.Collapsed)
                {
                    attachedPopup.Visibility = Visibility.Visible;
                }
            }
        }
Ejemplo n.º 5
0
        private void MapView_Loaded(object sender, RoutedEventArgs e)
        {
            mapView.MapUnit       = GeographyUnit.Meter;
            mapView.ZoomLevelSet  = new ThinkGeoCloudMapsZoomLevelSet();
            mapView.CurrentExtent = new RectangleShape(-14283508, 20037508, 14676953, -9263005);

            // Create background world map with vector tile requested from ThinkGeo Cloud Service.
            ThinkGeoCloudVectorMapsOverlay thinkGeoCloudVectorMapsOverlay = new ThinkGeoCloudVectorMapsOverlay(SampleHelper.ThinkGeoCloudId, SampleHelper.ThinkGeoCloudSecret, ThinkGeoCloudVectorMapsMapType.Light);

            mapView.Overlays.Add(thinkGeoCloudVectorMapsOverlay);

            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(SampleHelper.Get("Countries02_3857.shp"));

            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = AreaStyle.CreateSimpleAreaStyle(GeoColors.Transparent, GeoColor.FromArgb(100, GeoColors.Green));
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay staticOverlay = new LayerOverlay();

            staticOverlay.TileType = TileType.SingleTile;
            staticOverlay.Layers.Add("WorldLayer", worldLayer);
            mapView.Overlays.Add(staticOverlay);

            PopupOverlay popupOverlay = new PopupOverlay();

            mapView.Overlays.Add("PopupOverlay", popupOverlay);

            mapView.Refresh();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Display a popup containing a feature's info
        /// </summary>
        private void DisplayFeatureInfo(Feature feature)
        {
            StringBuilder parkInfoString = new StringBuilder();

            // Each column in a feature is a data attribute
            // Add all attribute pairs to the info string
            foreach (var column in feature.ColumnValues)
            {
                parkInfoString.AppendLine($"{column.Key}: {column.Value}");
            }

            //Create a new popup with the park info string
            PopupOverlay popupOverlay = (PopupOverlay)mapView.Overlays["Info Popup Overlay"];
            Popup        popup        = new Popup()
            {
                Position = feature.GetShape().GetCenterPoint()
            };

            popup.Content = parkInfoString.ToString();

            //Clear the popup overlay and add the new popup to it
            popupOverlay.Popups.Clear();
            popupOverlay.Popups.Add(popup);

            //Refresh the overlay to redraw the popups
            popupOverlay.Refresh();
        }
        private void WpfMap_Loaded(object sender, RoutedEventArgs e)
        {
            wpfMap1.MapUnit = GeographyUnit.DecimalDegree;
            wpfMap1.CurrentExtent = new RectangleShape(-97.745827547760484, 30.297694742808115, -97.728208518132988, 30.285123327073894);

            ShapeFileFeatureLayer roadLayer = new ShapeFileFeatureLayer(@"..\..\SampleData\Data\austinstreets.shp");
            roadLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            roadLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.LocalRoad1;

            LayerOverlay roadOverlay = new LayerOverlay();
            roadOverlay.Layers.Add(new BackgroundLayer(new GeoSolidBrush(GeoColor.FromArgb(255, 233, 232, 214))));
            roadOverlay.Layers.Add("RoadLayer", roadLayer);
            wpfMap1.Overlays.Add("RoadOverlay", roadOverlay);

            InMemoryFeatureLayer highlightLayer = new InMemoryFeatureLayer();
            highlightLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.LocalRoad1;
            highlightLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.InnerPen.Brush = new GeoSolidBrush(GeoColor.FromArgb(150, GeoColor.SimpleColors.Blue));
            highlightLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay highlightOverlay = new LayerOverlay();
            highlightOverlay.Layers.Add("HighlightLayer", highlightLayer);
            wpfMap1.Overlays.Add("HighlightOverlay", highlightOverlay);

            PopupOverlay popupOverlay = new PopupOverlay();
            wpfMap1.Overlays.Add("PopupOverlay", popupOverlay);

            wpfMap1.Refresh();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Adds hotel popups to the map
        /// </summary>
        private void AddHotelPopups()
        {
            // Create a PopupOverlay
            var popupOverlay = new PopupOverlay();

            // Create a layer in order to query the data
            var hotelsLayer = new ShapeFileFeatureLayer(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Data/Shapefile/Hotels.shp"));

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

            // Open the layer so that we can begin querying
            hotelsLayer.Open();

            // Query all the hotel features
            var hotelFeatures = hotelsLayer.QueryTools.GetAllFeatures(ReturningColumnsType.AllColumns);

            // Add each hotel feature to the popupOverlay
            foreach (var feature in hotelFeatures)
            {
                var popup = new Popup()
                {
                    Position = feature.GetShape().GetCenterPoint(),
                    Content  = feature.ColumnValues["NAME"]
                };
                popupOverlay.Popups.Add(popup);
            }

            // Close the hotel layer
            hotelsLayer.Close();

            // Add the popupOverlay to the map and refresh
            mapView.Overlays.Add(popupOverlay);
            mapView.Refresh();
        }
Ejemplo n.º 9
0
        private void mapView_MapClick(object sender, MapClickMapViewEventArgs e)
        {
            FeatureLayer worldLayer = mapView.FindFeatureLayer("WorldLayer");

            // Find the country the user clicked on.
            worldLayer.Open();
            Collection <Feature> selectedFeatures = worldLayer.QueryTools.GetFeaturesContaining(e.WorldLocation, new string[1] {
                "CNTRY_NAME"
            });

            worldLayer.Close();

            // Determine the area of the country.
            if (selectedFeatures.Count > 0)
            {
                ProjectionConverter project = new ProjectionConverter(3857, 4326);
                project.Open();
                AreaBaseShape areaShape = (AreaBaseShape)project.ConvertToExternalProjection(selectedFeatures[0].GetShape());
                project.Close();
                double area        = areaShape.GetArea(GeographyUnit.DecimalDegree, AreaUnit.SquareKilometers);
                string areaMessage = string.Format(CultureInfo.InvariantCulture, "{0} has an area of \r{1:N0} square kilometers.", selectedFeatures[0].ColumnValues["CNTRY_NAME"].Trim(), area);

                Popup popup = new Popup(e.WorldLocation);
                popup.Content = areaMessage;
                PopupOverlay popupOverlay = (PopupOverlay)mapView.Overlays["PopupOverlay"];
                popupOverlay.Popups.Clear();
                popupOverlay.Popups.Add(popup);
                popupOverlay.Refresh();
            }
        }
Ejemplo n.º 10
0
        private void mapView_MapClick(object sender, MapClickMapViewEventArgs e)
        {
            FeatureLayer worldLayer = mapView.FindFeatureLayer("WorldLayer");

            worldLayer.Open();
            Collection <Feature> selectedFeatures = worldLayer.QueryTools.GetFeaturesContaining(e.WorldLocation, new string[2] {
                "CNTRY_NAME", "POP_CNTRY"
            });

            worldLayer.Close();

            if (selectedFeatures.Count > 0)
            {
                StringBuilder info = new StringBuilder();
                info.AppendLine(String.Format(CultureInfo.InvariantCulture, "CNTRY_NAME:\t{0}", selectedFeatures[0].ColumnValues["CNTRY_NAME"]));
                info.AppendLine(String.Format(CultureInfo.InvariantCulture, "POP_CNTRY:\t{0}", double.Parse(selectedFeatures[0].ColumnValues["POP_CNTRY"]).ToString("n0")));
                TBInfo.Text = info.ToString();

                PopupOverlay popupOverlay = (PopupOverlay)mapView.Overlays["PopupOverlay"];
                Popup        popup        = new Popup(e.WorldLocation);
                popup.Content    = info.ToString();
                popup.FontSize   = 10d;
                popup.FontFamily = new System.Windows.Media.FontFamily("Verdana");

                popupOverlay.Popups.Clear();
                popupOverlay.Popups.Add(popup);
                popupOverlay.Refresh();
            }
        }
Ejemplo n.º 11
0
        void ThinkGeoMarkerClick(object sender, System.EventArgs e)
        {
            Marker       thinkGeoMarker = (Marker)sender;
            PopupOverlay popupOverlay   = androidMap.Overlays["PopupOverlay"] as PopupOverlay;

            if (popupOverlay.Popups.Count > 0)
            {
                popupOverlay.Popups.Clear();
            }
            else
            {
                ImageView imageView = new ImageView(this);
                imageView.SetImageResource(Resource.Drawable.ThinkGeoLogo);

                TextView textView = new TextView(this);
                textView.Text = string.Format("Longitude : {0:N4}" + "\r\n" + "Latitude : {1:N4}", thinkGeoMarker.Position.X, thinkGeoMarker.Position.Y);
                textView.SetTextColor(Color.Black);
                textView.SetTextSize(ComplexUnitType.Px, 22);

                LinearLayout linearLayout = new LinearLayout(this);
                linearLayout.SetPadding(10, 10, 10, 10);
                linearLayout.Orientation = Orientation.Vertical;
                linearLayout.AddView(imageView);
                linearLayout.AddView(textView);

                Popup popup = new Popup(this);
                popup.Position = thinkGeoMarker.Position;
                popup.YOffset  = (int)(-44 * ThinkGeo.MapSuite.Android.Resources.DisplayMetrics.Density);
                popup.XOffset  = (int)(4 * ThinkGeo.MapSuite.Android.Resources.DisplayMetrics.Density);
                popup.AddView(linearLayout);

                popupOverlay.Popups.Add(popup);
            }
            popupOverlay.Refresh();
        }
Ejemplo n.º 12
0
        private void MapView_Loaded(object sender, RoutedEventArgs e)
        {
            Map1.MapUnit      = GeographyUnit.Meter;
            Map1.ZoomLevelSet = new ThinkGeoCloudMapsZoomLevelSet();

            // Create background world map with vector tile requested from ThinkGeo Cloud Service.
            ThinkGeoCloudVectorMapsOverlay thinkGeoCloudVectorMapsOverlay = new ThinkGeoCloudVectorMapsOverlay(SampleHelper.ThinkGeoCloudId, SampleHelper.ThinkGeoCloudSecret, ThinkGeoCloudVectorMapsMapType.Light);

            Map1.Overlays.Add(thinkGeoCloudVectorMapsOverlay);

            PopupOverlay popupOverlay = new PopupOverlay();

            Map1.Overlays.Add(popupOverlay);

            ShapeFileFeatureLayer majorCitiesShapeLayer = new ShapeFileFeatureLayer(SampleHelper.Get("MajorCities_3857.shp"));

            majorCitiesShapeLayer.Open();
            Collection <Feature> features = majorCitiesShapeLayer.QueryTools.GetAllFeatures(ReturningColumnsType.AllColumns);

            foreach (Feature feature in features)
            {
                Popup popup = new Popup(feature.GetShape().GetCenterPoint());
                popup.Content = feature.ColumnValues["AREANAME"];
                popupOverlay.Popups.Add(popup);
            }
            majorCitiesShapeLayer.Close();

            Map1.CurrentExtent = popupOverlay.GetBoundingBox();
            Map1.Refresh();
        }
Ejemplo n.º 13
0
        public PopupNavigationService(PopupOverlay popupOverlay, INavigationStack navigationStack)
        {
            this._popupOverlay    = popupOverlay;
            this._navigationStack = navigationStack;

            this._popupOverlay.Closing += this.PopupOverlayOnClosing;
            this._popupOverlay.Closed  += this.PopupOverlayOnClosed;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Set up the map with the ThinkGeo Cloud Maps overlay, as well as several feature layers to display the reverse geocoding search area and locations
        /// </summary>
        protected override void OnAppearing()
        {
            base.OnAppearing();
            // Create the background world maps using vector tiles requested from the ThinkGeo Cloud Service.
            ThinkGeoCloudVectorMapsOverlay thinkGeoCloudVectorMapsOverlay = new ThinkGeoCloudVectorMapsOverlay("9ap16imkD_V7fsvDW9I8r8ULxgAB50BX_BnafMEBcKg~", "vtVao9zAcOj00UlGcK7U-efLANfeJKzlPuDB9nw7Bp4K4UxU_PdRDg~~", ThinkGeoCloudVectorMapsMapType.Light);

            thinkGeoCloudVectorMapsOverlay.VectorTileCache = new FileVectorTileCache(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "cache"), "CloudMapsVector");
            mapView.Overlays.Add(thinkGeoCloudVectorMapsOverlay);

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

            // Create a new feature layer to display the search radius of the reverse geocode and create a style for it
            InMemoryFeatureLayer searchRadiusFeatureLayer = new InMemoryFeatureLayer();

            searchRadiusFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = new AreaStyle(new GeoPen(new GeoColor(100, GeoColors.Blue)), new GeoSolidBrush(new GeoColor(10, GeoColors.Blue)));
            searchRadiusFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle   = new PointStyle(PointSymbolType.Cross, 20, GeoBrushes.Red);
            searchRadiusFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            // Create a new feature layer to display selected locations returned from the reverse geocode and create styles for it
            InMemoryFeatureLayer selectedResultItemFeatureLayer = new InMemoryFeatureLayer();

            // Add a point, line, and polygon style to the layer. These styles control how the shapes will be drawn
            selectedResultItemFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle   = new PointStyle(PointSymbolType.Star, 24, GeoBrushes.MediumPurple, GeoPens.Purple);
            selectedResultItemFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle    = LineStyle.CreateSimpleLineStyle(GeoColors.MediumPurple, 6, false);
            selectedResultItemFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = AreaStyle.CreateSimpleAreaStyle(GeoColor.FromArgb(80, GeoColors.MediumPurple), GeoColors.MediumPurple, 2);
            selectedResultItemFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            // Create an overlay and add the feature layers to it
            LayerOverlay searchFeaturesOverlay = new LayerOverlay();

            searchFeaturesOverlay.Layers.Add("Search Radius", searchRadiusFeatureLayer);
            searchFeaturesOverlay.Layers.Add("Result Feature Geometry", selectedResultItemFeatureLayer);

            // Create a popup overlay to display the best match
            PopupOverlay bestMatchPopupOverlay = new PopupOverlay();

            // Add the overlays to the map
            mapView.Overlays.Add("Search Features Overlay", searchFeaturesOverlay);
            mapView.Overlays.Add("Best Match Popup Overlay", bestMatchPopupOverlay);

            // Set the map extent to Frisco, TX
            mapView.CurrentExtent = new RectangleShape(-10780022.026198, 3915814.54657467, -10779119.113802, 3914667.51342533);

            // Initialize the ReverseGeocodingCloudClient with our ThinkGeo Cloud credentials
            reverseGeocodingCloudClient = new ReverseGeocodingCloudClient("FSDgWMuqGhZCmZnbnxh-Yl1HOaDQcQ6mMaZZ1VkQNYw~", "IoOZkBJie0K9pz10jTRmrUclX6UYssZBeed401oAfbxb9ufF1WVUvg~~");

            cboLocationCategories.SelectedIndex = 0;

            mapView.Refresh();
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Setup the map with the ThinkGeo Cloud Maps overlay. Also, add the NOAA Weather Warning layer to the map
        /// </summary>
        protected override void OnAppearing()
        {
            base.OnAppearing();

            // It is important to set the map unit first to either feet, meters or decimal degrees.
            mapView.MapUnit = GeographyUnit.Meter;

            // Create background world map with vector tile requested from ThinkGeo Cloud Service.
            ThinkGeoCloudVectorMapsOverlay thinkGeoCloudVectorMapsOverlay = new ThinkGeoCloudVectorMapsOverlay("9ap16imkD_V7fsvDW9I8r8ULxgAB50BX_BnafMEBcKg~", "vtVao9zAcOj00UlGcK7U-efLANfeJKzlPuDB9nw7Bp4K4UxU_PdRDg~~", ThinkGeoCloudVectorMapsMapType.Light);

            thinkGeoCloudVectorMapsOverlay.VectorTileCache = new FileVectorTileCache(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "cache"), "CloudMapsVector");
            mapView.Overlays.Add(thinkGeoCloudVectorMapsOverlay);

            // Create a new overlay that will hold our new layer and add it to the map.
            LayerOverlay noaaWeatherWarningsOverlay = new LayerOverlay();

            mapView.Overlays.Add("Noaa Weather Warning", noaaWeatherWarningsOverlay);

            // Create the new layer and set the projection as the data is in srid 4326 and our background is srid 3857 (spherical mercator).
            NoaaWeatherWarningsFeatureLayer noaaWeatherWarningsFeatureLayer = new NoaaWeatherWarningsFeatureLayer();

            noaaWeatherWarningsFeatureLayer.FeatureSource.ProjectionConverter = new ProjectionConverter(4326, 3857);

            // Add the new layer to the overlay we created earlier
            noaaWeatherWarningsOverlay.Layers.Add("Noaa Weather Warning", noaaWeatherWarningsFeatureLayer);

            // Get the layers feature source and setup an event that will refresh the map when the data refreshes
            var featureSource = (NoaaWeatherWarningsFeatureSource)noaaWeatherWarningsFeatureLayer.FeatureSource;

            featureSource.WarningsUpdated -= FeatureSource_WarningsUpdated;
            featureSource.WarningsUpdated += FeatureSource_WarningsUpdated;

            featureSource.WarningsUpdating -= FeatureSource_WarningsUpdating;
            featureSource.WarningsUpdating += FeatureSource_WarningsUpdating;

            // Create the weather warnings style and add it on zoom level 1 and then apply it to all zoom levels up to 20.
            noaaWeatherWarningsFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(new NoaaWeatherWarningsStyle());
            noaaWeatherWarningsFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            // Set the extent to a view of the US
            mapView.CurrentExtent = new RectangleShape(-14927495.374917, 8262593.0543992, -6686622.84891633, 1827556.23117885);

            // Add a PopupOverlay to the map, to display feature information
            PopupOverlay popupOverlay = new PopupOverlay();

            mapView.Overlays.Add("Info Popup Overlay", popupOverlay);

            // Refresh the map.
            mapView.Refresh();
        }
Ejemplo n.º 16
0
        private void Form_Load(object sender, EventArgs e)
        {
            // It is important to set the map unit first to either feet, meters or decimal degrees.
            mapView.MapUnit = GeographyUnit.Meter;

            // Create background world map with vector tile requested from ThinkGeo Cloud Service.
            ThinkGeoCloudVectorMapsOverlay thinkGeoCloudVectorMapsOverlay = new ThinkGeoCloudVectorMapsOverlay("itZGOI8oafZwmtxP-XGiMvfWJPPc-dX35DmESmLlQIU~", "bcaCzPpmOG6le2pUz5EAaEKYI-KSMny_WxEAe7gMNQgGeN9sqL12OA~~", ThinkGeoCloudVectorMapsMapType.Light);

            mapView.Overlays.Add(thinkGeoCloudVectorMapsOverlay);

            // Create a new overlay that will hold our new layer and add it to the map.
            LayerOverlay noaaWeatherWarningsOverlay = new LayerOverlay();

            mapView.Overlays.Add("Noaa Weather Warning", noaaWeatherWarningsOverlay);

            // Create the new layer and set the projection as the data is in srid 4326 and our background is srid 3857 (spherical mercator).
            NoaaWeatherWarningsFeatureLayer noaaWeatherWarningsFeatureLayer = new NoaaWeatherWarningsFeatureLayer();

            noaaWeatherWarningsFeatureLayer.FeatureSource.ProjectionConverter = new ProjectionConverter(4326, 3857);

            // Add the new layer to the overlay we created earlier
            noaaWeatherWarningsOverlay.Layers.Add("Noaa Weather Warning", noaaWeatherWarningsFeatureLayer);

            // Get the layers feature source and setup an event that will refresh the map when the data refreshes
            var featureSource = (NoaaWeatherWarningsFeatureSource)noaaWeatherWarningsFeatureLayer.FeatureSource;

            featureSource.WarningsUpdated -= FeatureSource_WarningsUpdated;
            featureSource.WarningsUpdated += FeatureSource_WarningsUpdated;

            featureSource.WarningsUpdating -= FeatureSource_WarningsUpdating;
            featureSource.WarningsUpdating += FeatureSource_WarningsUpdating;

            // Create the weather warnings style and add it on zoom level 1 and then apply it to all zoom levels up to 20.
            noaaWeatherWarningsFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(new NoaaWeatherWarningsStyle());
            noaaWeatherWarningsFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            // Set the extent to a view of the US
            mapView.CurrentExtent = new RectangleShape(-14927495.374917, 8262593.0543992, -6686622.84891633, 1827556.23117885);

            // Add a PopupOverlay to the map, to display feature information
            PopupOverlay popupOverlay = new PopupOverlay();

            mapView.Overlays.Add("Info Popup Overlay", popupOverlay);

            // Refresh the map.
            mapView.Refresh();
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Set up the map with the ThinkGeo Cloud Maps overlay and a feature layer containing Frisco parks data
        /// </summary>
        protected override void OnAppearing()
        {
            base.OnAppearing();
            // Create the background world maps using vector tiles requested from the ThinkGeo Cloud Service.
            ThinkGeoCloudVectorMapsOverlay thinkGeoCloudVectorMapsOverlay = new ThinkGeoCloudVectorMapsOverlay("9ap16imkD_V7fsvDW9I8r8ULxgAB50BX_BnafMEBcKg~", "vtVao9zAcOj00UlGcK7U-efLANfeJKzlPuDB9nw7Bp4K4UxU_PdRDg~~", ThinkGeoCloudVectorMapsMapType.Light);

            thinkGeoCloudVectorMapsOverlay.VectorTileCache = new FileVectorTileCache(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "cache"), "CloudMapsVector");

            mapView.Overlays.Add(thinkGeoCloudVectorMapsOverlay);

            // Set the Map Unit to meters (used in Spherical Mercator)
            mapView.MapUnit = GeographyUnit.Meter;

            // Create a feature layer to hold the Frisco parks data
            ShapeFileFeatureLayer parksLayer = new ShapeFileFeatureLayer(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Data/Shapefile/Parks.shp"));

            // Convert the Frisco shapefile from its native projection to Spherical Mercator, to match the map
            ProjectionConverter projectionConverter = new ProjectionConverter(2276, 3857);

            parksLayer.FeatureSource.ProjectionConverter = projectionConverter;

            // Add a style to use to draw the Frisco parks polygons
            parksLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            parksLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = AreaStyle.CreateSimpleAreaStyle(GeoColor.FromArgb(50, GeoColors.MediumPurple), GeoColors.MediumPurple, 2);

            // Add the feature layer to an overlay, and add the overlay to the map
            LayerOverlay parksOverlay = new LayerOverlay();

            parksOverlay.Layers.Add("Frisco Parks", parksLayer);
            mapView.Overlays.Add(parksOverlay);

            // Add a PopupOverlay to the map, to display feature information
            PopupOverlay popupOverlay = new PopupOverlay();

            mapView.Overlays.Add("Info Popup Overlay", popupOverlay);

            // Set the map extent to the bounding box of the parks
            parksLayer.Open();
            mapView.CurrentExtent = parksLayer.GetBoundingBox();
            // mapView.ZoomIn();
            parksLayer.Close();

            // Refresh and redraw the map
            mapView.Refresh();
        }
        private void Map1_Loaded(object sender, RoutedEventArgs e)
        {
            Map1.MapUnit       = GeographyUnit.Meter;
            Map1.CurrentExtent = new RectangleShape(-16965308.8699768, 10390517.8895596, 15908646.0310775, -8922930.61480984);

            LayerOverlay layerOverlay = new LayerOverlay();

            layerOverlay.TileType   = TileType.MultipleTile;
            layerOverlay.TileBuffer = 2;

            BackgroundLayer backgroundLayer = new BackgroundLayer(new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean));

            layerOverlay.Layers.Add(backgroundLayer);

            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"..\..\SampleData\Countries02.shp");

            worldLayer.DrawingMarginInPixel = 200;
            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle      = WorldStreetsAreaStyles.Common();
            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle      = WorldStreetsTextStyles.GeneralPurpose("CNTRY_NAME", 12);
            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.Font = new GeoFont("Arial", 16, DrawingFontStyles.Bold);
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel   = ApplyUntilZoomLevel.Level20;
            layerOverlay.Layers.Add("SampleLayer", worldLayer);
            Map1.Overlays.Add("LayerOverlay", layerOverlay);

            SimpleMarkerOverlay markerOverlay = new SimpleMarkerOverlay();

            Map1.Overlays.Add("MarkerOverlay", markerOverlay);

            PopupOverlay popupOverlay = new PopupOverlay();

            Map1.Overlays.Add("PopupOverlay", popupOverlay);
            Popup popup = new Popup(new PointShape(-10777662.2854073, 3912165.79621789));

            popup.Content = new TextBlock()
            {
                Text = "ThinkGeo", FontSize = 20
            };
            popupOverlay.Popups.Add(popup);

            Map1.TrackOverlay.DrawingMarginPercentage = 80;
            Map1.EditOverlay.DrawingMarginPercentage  = 80;

            Map1.Refresh();
        }
Ejemplo n.º 19
0
        private static ContextMenu GetContextMenuForPlottedMarker(Marker marker)
        {
            ContextMenu ctx = new ContextMenu();

            MenuItem menuItem = new MenuItem();

            menuItem.Header      = "Remove";
            menuItem.DataContext = marker;
            menuItem.Icon        = new Image()
            {
                Width  = 16,
                Height = 16,
                Source = new BitmapImage(new Uri("pack://application:,,,/GisEditorPluginCore;component/Images/Delete.png", UriKind.RelativeOrAbsolute))
            };

            menuItem.Click += (s, e) =>
            {
                MenuItem self          = (MenuItem)s;
                Marker   relatedMarker = self.DataContext as Marker;

                if (relatedMarker != null)
                {
                    Popup relatedPopup = relatedMarker.Tag as Popup;

                    SimpleMarkerOverlay currentMarkerOverlay = CurrentOverlays.PlottedMarkerOverlay;
                    if (currentMarkerOverlay.Markers.Contains(relatedMarker))
                    {
                        currentMarkerOverlay.Markers.Remove(relatedMarker);
                        GisEditor.ActiveMap.Refresh(currentMarkerOverlay);
                    }

                    PopupOverlay currentPopupOverlay = CurrentOverlays.PopupOverlay;
                    if (currentPopupOverlay.Popups.Contains(relatedPopup))
                    {
                        currentPopupOverlay.Popups.Remove(relatedPopup);
                        GisEditor.ActiveMap.Refresh(currentPopupOverlay);
                    }
                }
            };

            ctx.Items.Add(menuItem);
            return(ctx);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Set up the map with the ThinkGeo Cloud Maps overlay
        /// </summary>
        protected override void OnAppearing()
        {
            base.OnAppearing();
            // Create the background world maps using vector tiles requested from the ThinkGeo Cloud Service.
            ThinkGeoCloudVectorMapsOverlay thinkGeoCloudVectorMapsOverlay = new ThinkGeoCloudVectorMapsOverlay("9ap16imkD_V7fsvDW9I8r8ULxgAB50BX_BnafMEBcKg~", "vtVao9zAcOj00UlGcK7U-efLANfeJKzlPuDB9nw7Bp4K4UxU_PdRDg~~", ThinkGeoCloudVectorMapsMapType.Light);

            thinkGeoCloudVectorMapsOverlay.VectorTileCache = new FileVectorTileCache(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "cache"), "CloudMapsVector");
            mapView.Overlays.Add(thinkGeoCloudVectorMapsOverlay);

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

            // Create a PopupOverlay to display time zone information based on locations input by the user
            PopupOverlay timezoneInfoPopupOverlay = new PopupOverlay();

            // Add the overlay to the map
            mapView.Overlays.Add("Timezone Info Popup Overlay", timezoneInfoPopupOverlay);

            // Add a new InMemoryFeatureLayer to hold the timezone shapes
            InMemoryFeatureLayer timezonesFeatureLayer = new InMemoryFeatureLayer();

            // Add a style to use to draw the timezone polygons
            timezonesFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            timezonesFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = AreaStyle.CreateSimpleAreaStyle(GeoColor.FromArgb(50, GeoColors.MediumPurple), GeoColors.MediumPurple, 2);

            // Add the layer to an overlay, and add it to the map
            LayerOverlay timezonesLayerOverlay = new LayerOverlay();

            timezonesLayerOverlay.Layers.Add("Timezone Feature Layer", timezonesFeatureLayer);
            mapView.Overlays.Add("Timezone Layer Overlay", timezonesLayerOverlay);

            // Initialize the TimezoneCloudClient with our ThinkGeo Cloud credentials
            timeZoneCloudClient = new TimeZoneCloudClient("FSDgWMuqGhZCmZnbnxh-Yl1HOaDQcQ6mMaZZ1VkQNYw~", "IoOZkBJie0K9pz10jTRmrUclX6UYssZBeed401oAfbxb9ufF1WVUvg~~");

            // Set the Map Extent
            mapView.CurrentExtent = new RectangleShape(-14269933.09, 6354969.40, -6966221.89, 2759371.58);

            // Get Timezone info for Frisco, TX
            //GetTimeZoneInfo(-10779572.80, 3915268.68);

            mapView.Refresh();
        }
        private void WpfMap_Loaded(object sender, RoutedEventArgs e)
        {
            wpfMap1.MapUnit = GeographyUnit.DecimalDegree;
            wpfMap1.CurrentExtent = new RectangleShape(-133.2515625, 89.2484375, 126.9046875, -88.290625);

            WorldMapKitWmsWpfOverlay worldMapKitOverlay = new WorldMapKitWmsWpfOverlay();
            wpfMap1.Overlays.Add(worldMapKitOverlay);

            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"..\..\SampleData\Data\Countries02.shp");
            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(100, GeoColor.SimpleColors.Green));
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay worldOverlay = new LayerOverlay();
            worldOverlay.Layers.Add("WorldLayer", worldLayer);
            wpfMap1.Overlays.Add("WorldOverlay", worldOverlay);

            PopupOverlay popupOverlay = new PopupOverlay();
            wpfMap1.Overlays.Add("PopupOverlay", popupOverlay);

            wpfMap1.Refresh();
        }
        private void WpfMap_Loaded(object sender, RoutedEventArgs e)
        {
            wpfMap1.MapUnit = GeographyUnit.DecimalDegree;
            wpfMap1.CurrentExtent = new RectangleShape(-128.31093750000002, 95.25, 131.84531249999998, -63.65625);

            WorldMapKitWmsWpfOverlay worldMapKitDesktopOverlay = new WorldMapKitWmsWpfOverlay();
            wpfMap1.Overlays.Add(worldMapKitDesktopOverlay);

            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"..\..\SampleData\Data\Countries02.shp");
            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(100, GeoColor.SimpleColors.Green));
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay staticOverlay = new LayerOverlay();
            staticOverlay.TileType = TileType.SingleTile;
            staticOverlay.Layers.Add("WorldLayer", worldLayer);
            wpfMap1.Overlays.Add(staticOverlay);

            PopupOverlay popupOverlay = new PopupOverlay();
            wpfMap1.Overlays.Add("PopupOverlay", popupOverlay);

            wpfMap1.Refresh();
        }
        private void mapView_MapClick(object sender, MapClickMapViewEventArgs e)
        {
            FeatureLayer         worldLayer     = mapView.FindFeatureLayer("RoadLayer");
            InMemoryFeatureLayer highlightLayer = (InMemoryFeatureLayer)mapView.FindFeatureLayer("HighlightLayer");
            Overlay highlightOverlay            = mapView.Overlays["HighlightOverlay"];

            // Find the road the user clicked on.
            worldLayer.Open();
            Collection <Feature> selectedFeatures = worldLayer.QueryTools.GetFeaturesNearestTo(e.WorldLocation, GeographyUnit.Meter, 1, new string[1] {
                "FENAME"
            });

            worldLayer.Close();

            //Determine the length of the road.
            if (selectedFeatures.Count > 0)
            {
                LineBaseShape lineShape = (LineBaseShape)selectedFeatures[0].GetShape();
                highlightLayer.Open();
                highlightLayer.InternalFeatures.Clear();
                highlightLayer.InternalFeatures.Add(new Feature(lineShape));
                highlightLayer.Close();
                ProjectionConverter project = new ProjectionConverter(3857, 4326);
                project.Open();
                double length = ((LineBaseShape)project.ConvertToExternalProjection(lineShape)).GetLength(GeographyUnit.DecimalDegree, DistanceUnit.Meter);
                project.Close();
                string lengthMessage = string.Format(CultureInfo.InvariantCulture, "{0} has a length of {1:F2} meters.", selectedFeatures[0].ColumnValues["FENAME"].Trim(), length);

                Popup popup = new Popup(e.WorldLocation);
                popup.Content = lengthMessage;
                PopupOverlay popupOverlay = (PopupOverlay)mapView.Overlays["PopupOverlay"];
                popupOverlay.Popups.Clear();
                popupOverlay.Popups.Add(popup);

                highlightOverlay.Refresh();
                popupOverlay.Refresh();
            }
        }
        private void WpfMap1_MapClick(object sender, MapClickWpfMapEventArgs e)
        {
            if (e.MouseButton == MapMouseButton.Left)
            {
                RectangleShape clickedArea = MapSuiteSampleHelper.GetBufferedRectangle(e.WorldLocation, mapControl.CurrentResolution);
                PopupOverlay.Popups.Clear();
                foreach (InMemoryFeatureLayer vehicleLayer in TraceOverlay.Layers.OfType <InMemoryFeatureLayer>())
                {
                    vehicleLayer.Open();
                    Collection <Feature> resultFeatures = vehicleLayer.QueryTools.GetFeaturesIntersecting(clickedArea, ReturningColumnsType.AllColumns);
                    if (resultFeatures.Count > 0)
                    {
                        Popup            popup            = new Popup(e.WorldLocation);
                        PopupUserControl popupUserControl = new PopupUserControl(resultFeatures[0]);
                        popupUserControl.PopupOverlay = PopupOverlay;

                        popup.Content = popupUserControl;
                        PopupOverlay.Popups.Add(popup);
                        PopupOverlay.Refresh();
                        break;
                    }
                }
            }
        }
        private void WpfMap_Loaded(object sender, RoutedEventArgs e)
        {
            Map1.MapUnit = GeographyUnit.DecimalDegree;

            WorldMapKitWmsWpfOverlay worldOverlay = new WorldMapKitWmsWpfOverlay();
            Map1.Overlays.Add(worldOverlay);

            PopupOverlay popupOverlay = new PopupOverlay();
            Map1.Overlays.Add(popupOverlay);

            ShapeFileFeatureLayer majorCitiesShapeLayer = new ShapeFileFeatureLayer(@"..\..\SampleData\Data\MajorCities.shp");
            majorCitiesShapeLayer.Open();
            Collection<Feature> features = majorCitiesShapeLayer.QueryTools.GetAllFeatures(ReturningColumnsType.AllColumns);
            foreach (Feature feature in features)
            {
                Popup popup = new Popup(feature.GetShape().GetCenterPoint());
                popup.Content = feature.ColumnValues["AREANAME"];
                popupOverlay.Popups.Add(popup);
            }
            majorCitiesShapeLayer.Close();

            Map1.CurrentExtent = popupOverlay.GetBoundingBox();
            Map1.Refresh();
        }
        private void MapView_Loaded(object sender, RoutedEventArgs e)
        {
            mapView.MapUnit       = GeographyUnit.Meter;
            mapView.ZoomLevelSet  = new ThinkGeoCloudMapsZoomLevelSet();
            mapView.CurrentExtent = new RectangleShape(-13629668, 6044916, -7913604, 2972807);

            // Create background world map with vector tile requested from ThinkGeo Cloud Service.
            ThinkGeoCloudVectorMapsOverlay thinkGeoCloudVectorMapsOverlay = new ThinkGeoCloudVectorMapsOverlay(SampleHelper.ThinkGeoCloudId, SampleHelper.ThinkGeoCloudSecret, ThinkGeoCloudVectorMapsMapType.Light);

            mapView.Overlays.Add(thinkGeoCloudVectorMapsOverlay);

            PopupOverlay popupOverlay = new PopupOverlay();

            mapView.Overlays.Add(popupOverlay);

            Popup popup = new Popup(-13177554, 4040376);

            popup.Content = "Los Angeles";
            popupOverlay.Popups.Add(popup);

            mapView.RotatedAngle = 30;

            mapView.Refresh();
        }
Ejemplo n.º 27
0
 /// <summary>
 /// Initialise a new DataProvider.
 /// </summary>
 /// <param name="overlay">
 ///		A PopupOverlay, legacy of the days when Silverlight did not have any kind of
 ///		popup window function buit in.
 ///	</param>
 public DataProvider(PopupOverlay overlay)
     : base(overlay)
 {
 }
        public void InitOverlay()
        {
            /**
             * 创建自定义overlay
             */
            mOverlay = new MyOverlay(this, Resources.GetDrawable(Resource.Drawable.icon_marka), mMapView);
            /**
             * 准备overlay 数据
             */
            GeoPoint p1 = new GeoPoint((int)(mLat1 * 1E6), (int)(mLon1 * 1E6));
            OverlayItem item1 = new OverlayItem(p1, "覆盖物1", "");
            /**
             * 设置overlay图标,如不设置,则使用创建ItemizedOverlay时的默认图标.
             */
            item1.Marker = Resources.GetDrawable(Resource.Drawable.icon_marka);

            GeoPoint p2 = new GeoPoint((int)(mLat2 * 1E6), (int)(mLon2 * 1E6));
            OverlayItem item2 = new OverlayItem(p2, "覆盖物2", "");
            item2.Marker = Resources.GetDrawable(Resource.Drawable.icon_markb);

            GeoPoint p3 = new GeoPoint((int)(mLat3 * 1E6), (int)(mLon3 * 1E6));
            OverlayItem item3 = new OverlayItem(p3, "覆盖物3", "");
            item3.Marker = Resources.GetDrawable(Resource.Drawable.icon_markc);

            GeoPoint p4 = new GeoPoint((int)(mLat4 * 1E6), (int)(mLon4 * 1E6));
            OverlayItem item4 = new OverlayItem(p4, "覆盖物4", "");
            item4.Marker = Resources.GetDrawable(Resource.Drawable.icon_gcoding);
            /**
             * 将item 添加到overlay中
             * 注意: 同一个itme只能add一次
             */
            mOverlay.AddItem(item1);
            mOverlay.AddItem(item2);
            mOverlay.AddItem(item3);
            mOverlay.AddItem(item4);
            /**
             * 保存所有item,以便overlay在reset后重新添加
             */
            mItems = new List<OverlayItem>();
            mItems.AddRange(mOverlay.AllItem);

            // 初始化 ground 图层
            mGroundOverlay = new GroundOverlay(mMapView);
            GeoPoint leftBottom = new GeoPoint((int)(mLat5 * 1E6),
                    (int)(mLon5 * 1E6));
            GeoPoint rightTop = new GeoPoint((int)(mLat6 * 1E6),
                    (int)(mLon6 * 1E6));
            Drawable d = Resources.GetDrawable(Resource.Drawable.ground_overlay);
            Bitmap bitmap = ((BitmapDrawable)d).Bitmap;
            mGround = new Ground(bitmap, leftBottom, rightTop);

            /**
             * 将overlay 添加至MapView中
             */
            mMapView.Overlays.Add(mOverlay);
            mMapView.Overlays.Add(mGroundOverlay);
            mGroundOverlay.AddGround(mGround);
            /**
             * 刷新地图
             */
            mMapView.Refresh();
            mResetBtn.Enabled = false;
            mClearBtn.Enabled = true;
            /**
             * 向地图添加自定义View.
             */
            viewCache = LayoutInflater.Inflate(Resource.Layout.custom_text_view, null);
            popupInfo = viewCache.FindViewById<View>(Resource.Id.popinfo);
            popupLeft = viewCache.FindViewById<View>(Resource.Id.popleft);
            popupRight = viewCache.FindViewById<View>(Resource.Id.popright);
            popupText = viewCache.FindViewById<TextView>(Resource.Id.textcache);

            button = new Button(this);
            button.SetBackgroundResource(Resource.Drawable.popup);

            /**
             * 创建一个popupoverlay
             */
            IPopupClickListener popListener = new IPopupClickListenerImpl(this);
            pop = new PopupOverlay(mMapView, popListener);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Use the TimezoneCloudClient to query for timezone information
        /// </summary>
        private async Task GetTimeZoneInfo(double lon, double lat)
        {
            CloudTimeZoneResult result;

            try
            {
                // Show a loading graphic to let users know the request is running
                loadingIndicator.IsRunning = true;
                loadingLayout.IsVisible    = true;

                // Get timezone info based on the lon, lat, and input projection (Spherical Mercator in this case)
                result = await timeZoneCloudClient.GetTimeZoneByCoordinateAsync(lon, lat, 3857);
            }
            catch (Exception ex)
            {
                await DisplayAlert("Error", ex.Message, "OK");

                return;
            }
            finally
            {
                loadingIndicator.IsRunning = false;
                loadingLayout.IsVisible    = false;
            }

            // Get the timezone info popup overlay from the mapview
            PopupOverlay timezoneInfoPopupOverlay = (PopupOverlay)mapView.Overlays["Timezone Info Popup Overlay"];

            // Clear the existing info popups from the map
            timezoneInfoPopupOverlay.Popups.Clear();

            // Build a string description of the timezone
            StringBuilder timezoneInfoString = new StringBuilder();

            timezoneInfoString.AppendLine($"Time Zone: {result.TimeZone}");
            timezoneInfoString.AppendLine($"Current Local Time: {result.CurrentLocalTime}");
            timezoneInfoString.AppendLine($"Daylight Savings Active: {result.DaylightSavingsActive}");

            // Display the timezone info on a popup on the map
            Popup popup = new Popup();

            popup.Content  = timezoneInfoString.ToString();
            popup.Position = new PointShape(lon, lat);
            timezoneInfoPopupOverlay.Popups.Add(popup);

            // Clear the timezone feature layer of previous features
            InMemoryFeatureLayer timezonesFeatureLayer = (InMemoryFeatureLayer)mapView.FindFeatureLayer("Timezone Feature Layer");

            timezonesFeatureLayer.Open();
            timezonesFeatureLayer.InternalFeatures.Clear();

            // Use a ProjectionConverter to convert the shape to Spherical Mercator
            ProjectionConverter converter = new ProjectionConverter(3857, 4326);

            converter.Open();

            // Add the new timezone polygon to the map
            timezonesFeatureLayer.InternalFeatures.Add(new Feature(converter.ConvertToInternalProjection(result.Shape)));
            converter.Close();
            timezonesFeatureLayer.Close();

            // Refresh and redraw the map
            mapView.Refresh();
        }
Ejemplo n.º 30
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.DisplayASimpleMap);

            ShapeFileFeatureLayer txwatFeatureLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath(@"Frisco/TXwat.shp"));

            txwatFeatureLayer.ZoomLevelSet.ZoomLevel12.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.FromArgb(255, 153, 179, 204);
            txwatFeatureLayer.ZoomLevelSet.ZoomLevel12.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("LandName", "Arial", 9, DrawingFontStyles.Italic, GeoColor.StandardColors.Navy);
            txwatFeatureLayer.ZoomLevelSet.ZoomLevel12.DefaultTextStyle.SuppressPartialLabels = true;
            txwatFeatureLayer.ZoomLevelSet.ZoomLevel12.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            ShapeFileFeatureLayer txlkaA40FeatureLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath(@"Frisco/TXlkaA40.shp"));

            txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel14.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.DarkGray, 1F, false);
            txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel15.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.White, 3F, GeoColor.StandardColors.DarkGray, 5F, true);
            txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.White, 8F, GeoColor.StandardColors.DarkGray, 10F, true);
            txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("[fedirp] [fename] [fetype] [fedirs]", "Arial", 10f, DrawingFontStyles.Regular, GeoColor.StandardColors.Black, 0, -1);
            txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultTextStyle.SuppressPartialLabels = true;
            txlkaA40FeatureLayer.ZoomLevelSet.ZoomLevel16.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            txlkaA40FeatureLayer.DrawingMarginPercentage = 80;

            ShapeFileFeatureLayer txlkaA20FeatureLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath(@"Frisco/TXlkaA20.shp"));

            txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel15.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.FromArgb(255, 255, 255, 128), 6, GeoColor.StandardColors.LightGray, 9, true);
            txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.FromArgb(255, 255, 255, 128), 9, GeoColor.StandardColors.LightGray, 12, true);
            txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("[fedirp] [fename] [fetype] [fedirs]", "Arial", 12, DrawingFontStyles.Regular, GeoColor.StandardColors.Black, 0, -1);
            txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel16.DefaultTextStyle.SuppressPartialLabels = true;
            txlkaA20FeatureLayer.ZoomLevelSet.ZoomLevel16.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            Marker thinkGeoMarker = new Marker(BaseContext);

            thinkGeoMarker.Position = new PointShape(-96.809523, 33.128675);
            thinkGeoMarker.SetImageBitmap(Android.Graphics.BitmapFactory.DecodeResource(ThinkGeo.MapSuite.Android.Resources, Resource.Drawable.Pin));
            thinkGeoMarker.YOffset = -(int)(22 * ThinkGeo.MapSuite.Android.Resources.DisplayMetrics.Density);

            MarkerOverlay markerOverlay = new MarkerOverlay();

            markerOverlay.Markers.Add(thinkGeoMarker);

            ImageView imageView = new ImageView(this);

            imageView.SetImageResource(Resource.Drawable.ThinkGeoLogo);

            TextView textView = new TextView(this);

            textView.Text = string.Format("Longitude : {0:N4}" + "\r\n" + "Latitude : {1:N4}", thinkGeoMarker.Position.X, thinkGeoMarker.Position.Y);
            textView.SetTextColor(Color.Black);
            textView.SetTextSize(ComplexUnitType.Px, 22);

            LinearLayout linearLayout = new LinearLayout(this);

            linearLayout.SetPadding(10, 10, 10, 10);
            linearLayout.Orientation = Orientation.Vertical;
            linearLayout.AddView(imageView);
            linearLayout.AddView(textView);

            Popup popup = new Popup(this);

            popup.Position = thinkGeoMarker.Position;
            popup.YOffset  = (int)(-44 * ThinkGeo.MapSuite.Android.Resources.DisplayMetrics.Density);
            popup.XOffset  = (int)(4 * ThinkGeo.MapSuite.Android.Resources.DisplayMetrics.Density);
            popup.AddView(linearLayout);

            PopupOverlay popupOverlay = new PopupOverlay();

            popupOverlay.Popups.Add(popup);

            LayerOverlay layerOverlay = new LayerOverlay();

            layerOverlay.Layers.Add(txwatFeatureLayer);
            layerOverlay.Layers.Add(txlkaA20FeatureLayer);
            layerOverlay.Layers.Add(txlkaA40FeatureLayer);

            androidMap               = FindViewById <MapView>(Resource.Id.androidmap);
            androidMap.MapUnit       = GeographyUnit.DecimalDegree;
            androidMap.CurrentExtent = new RectangleShape(-96.8172, 33.1299, -96.8050, 33.1226);
            androidMap.Overlays.Add(layerOverlay);
            androidMap.Overlays.Add(markerOverlay);
            androidMap.Overlays.Add(popupOverlay);

            SampleViewHelper.InitializeInstruction(this, FindViewById <RelativeLayout>(Resource.Id.MainLayout), GetType());
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Update the UI based on the search results from the reverse geocode
        /// </summary>
        private void DisplaySearchResults(PointShape searchPoint, int searchRadius, CloudReverseGeocodingResult searchResult)
        {
            // Get the 'Search Radius' layer from the MapView
            InMemoryFeatureLayer searchRadiusFeatureLayer = (InMemoryFeatureLayer)mapView.FindFeatureLayer("Search Radius");

            // Clear the existing features and add new features showing the area that was searched by the reverse geocode
            searchRadiusFeatureLayer.Clear();
            searchRadiusFeatureLayer.InternalFeatures.Add(new Feature(new EllipseShape(searchPoint, searchRadius)));
            searchRadiusFeatureLayer.InternalFeatures.Add(new Feature(searchPoint));

            // Get the 'Result Feature' layer and clear it
            InMemoryFeatureLayer selectedResultItemFeatureLayer = (InMemoryFeatureLayer)mapView.FindFeatureLayer("Result Feature Geometry");

            selectedResultItemFeatureLayer.Clear();

            // If a match was found for the geocode, update the UI
            if (searchResult?.BestMatchLocation != null)
            {
                // Get the 'Best Match' PopupOverlay from the MapView and clear it
                PopupOverlay bestMatchPopupOverlay = (PopupOverlay)mapView.Overlays["Best Match Popup Overlay"];
                bestMatchPopupOverlay.Popups.Clear();

                // Get the location of the 'Best Match' found within the search radius
                PointShape bestMatchLocation = searchResult.BestMatchLocation.LocationFeature.GetShape().GetClosestPointTo(searchPoint, GeographyUnit.Meter);
                if (bestMatchLocation == null)
                {
                    bestMatchLocation = searchResult.BestMatchLocation.LocationFeature.GetShape().GetCenterPoint();
                }

                // Create a popup to display the best match, and add it to the PopupOverlay
                Popup bestMatchPopup = new Popup();
                bestMatchPopup.Content  = "Best Match: " + searchResult.BestMatchLocation.LocationName;
                bestMatchPopup.Position = bestMatchLocation;
                bestMatchPopupOverlay.Popups.Add(bestMatchPopup);

                // Sort the locations found into three groups (Addresses, Places, Roads) based on their LocationCategory
                Collection <CloudReverseGeocodingLocation> nearbyLocations = new Collection <CloudReverseGeocodingLocation>(searchResult.NearbyLocations);
                Collection <CloudReverseGeocodingLocation> nearbyAddresses = new Collection <CloudReverseGeocodingLocation>();
                Collection <CloudReverseGeocodingLocation> nearbyPlaces    = new Collection <CloudReverseGeocodingLocation>();
                Collection <CloudReverseGeocodingLocation> nearbyRoads     = new Collection <CloudReverseGeocodingLocation>();
                foreach (CloudReverseGeocodingLocation foundLocation in nearbyLocations)
                {
                    if (foundLocation.LocationCategory.ToLower().Contains("addresspoint"))
                    {
                        nearbyAddresses.Add(foundLocation);
                    }
                    else if (nameof(CloudLocationCategories.Aeroway).Equals(foundLocation.LocationCategory) ||
                             nameof(CloudLocationCategories.Road).Equals(foundLocation.LocationCategory) ||
                             nameof(CloudLocationCategories.Rail).Equals(foundLocation.LocationCategory) ||
                             nameof(CloudLocationCategories.Waterway).Equals(foundLocation.LocationCategory))
                    {
                        nearbyRoads.Add(foundLocation);
                    }
                    else if (!nameof(CloudLocationCategories.Intersection).Equals(foundLocation.LocationCategory))
                    {
                        nearbyPlaces.Add(foundLocation);
                    }
                }

                // Set the data sources for the addresses, roads, and places list boxes
                lsbAddresses.ItemsSource = nearbyAddresses;
                lsbRoads.ItemsSource     = nearbyRoads;
                lsbPlaces.ItemsSource    = nearbyPlaces;

                lsbPlaces.IsVisible = true;

                txtSearchResultsBestMatch.Text = "Best Match: " + searchResult.BestMatchLocation.Address;
            }
            else
            {
                txtSearchResultsBestMatch.Text = "No address or place matches found for this location";
            }

            // Set the map extent to show the results of the search
            mapView.CurrentExtent = RectangleShape.ScaleUp(searchRadiusFeatureLayer.GetBoundingBox(), 20).GetBoundingBox();
            mapView.Refresh();
        }
        /**
         * 创建弹出泡泡图层
         */
        public void CreatePaopao()
        {
            viewCache = LayoutInflater.Inflate(Resource.Layout.custom_text_view, null);
            popupText = viewCache.FindViewById<TextView>(Resource.Id.textcache);

            //泡泡点击响应回调
            IPopupClickListener popListener = new PopListener(this);

            pop = new PopupOverlay(mMapView, popListener);
        }
        /**
     * 创建弹出泡泡图层
     */
        public void CreatePaopao()
        {

            ////泡泡点击响应回调
            IPopupClickListener popListener = new IPopupClickListenerImpl();
            pop = new PopupOverlay(mMapView, popListener);
        }
        public static PopupOverlay CreatePopupOverlay()
        {
            const string popupOverlayName = "Popup Overlay";

            PopupOverlay popupOverlay = new PopupOverlay();
            popupOverlay.Name = popupOverlayName;
            Popup popup = CreatePopup();
            popupOverlay.Popups.Add(popup);

            return popupOverlay;
        }