Ejemplo n.º 1
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.º 2
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.º 3
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();
        }
Ejemplo n.º 4
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();
            }
        }
Ejemplo n.º 5
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();
            }
        }
        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;
                    }
                }
            }
        }