Пример #1
0
        private async void AssociatedObject_MapViewTapped(object sender, MapViewInputEventArgs e)
        {
            MapView                mapView    = sender as MapView;
            OverlayItemsControl    overlays   = mapView.Overlays;
            OverlayItemsCollection collection = overlays.Items;

            System.Windows.Controls.Border overlayControl = (System.Windows.Controls.Border)collection[0];

            // get the location tapped on the map
            var mapPoint = e.Location;

            // Get possible features and if none found, move to next layer
            FeatureLayer featureLayer = (FeatureLayer)mapView.Map.Layers[1];

            // Get possible features and if none found, move to next layer
            var foundFeatures = await featureLayer.HitTestAsync(mapView, new Rect(e.Position, new Size(10, 10)), 1);

            if (foundFeatures.Count() == 0)
            {
                return;
            }

            var feature = await featureLayer.FeatureTable.QueryAsync(foundFeatures[0]);

            overlayControl.DataContext = feature.Attributes;

            Esri.ArcGISRuntime.Controls.MapView.SetViewOverlayAnchor(overlayControl, mapPoint);
            overlayControl.Visibility = Visibility.Visible;
        }
Пример #2
0
        public MainWindow()
        {
            InitializeComponent();

            MapPoint overlayLocation = null;

            //var ferneyTip = this.mapView.FindName("ferneyOverlay") as FrameworkElement;
            //// if the overlay element is found, set its position and make it visible
            //if (ferneyTip != null)
            //{
            //    overlayLocation = new Esri.ArcGISRuntime.Geometry.MapPoint(6.1081, 46.2558, Esri.ArcGISRuntime.Geometry.SpatialReferences.Wgs84);
            //    Esri.ArcGISRuntime.Controls.MapView.SetViewOverlayAnchor(ferneyTip, overlayLocation);
            // //   ferneyTip.Visibility = Visibility.Visible;
            //}

            //return;

            Callout c = new Callout();

            c.CalloutTitle   = "标题";
            c.CalloutContent = "内容";
            OverlayItemsControl f = new OverlayItemsControl();

            f.Items.Add(c);

            mapView.Overlays.Items.Add(c);
            // if the overlay element is found, set its position and make it visible
            if (f != null)
            {
                overlayLocation = new Esri.ArcGISRuntime.Geometry.MapPoint(6.1081, 46.2558, Esri.ArcGISRuntime.Geometry.SpatialReferences.Wgs84);
                Esri.ArcGISRuntime.Controls.MapView.SetViewOverlayAnchor(c, overlayLocation);
                c.Visibility = Visibility.Visible;
            }
        }
Пример #3
0
        private void ShowCallout(string title, string content, MapPoint location)
        {
            foreach (var item in MapObj.toolBar.Tools.Children.OfType <ToolItem>())
            {
                if (item.Active == true)
                {
                    return;
                }
            }

            IntPtr windowHandle = Process.GetCurrentProcess().MainWindowHandle;

            InfoStruct info_struct = new InfoStruct(1);

            info_struct.ID = string.Copy(title).ToCharArray();
            Array.Resize(ref info_struct.ID, 64);
            IntPtr pnt = Marshal.AllocHGlobal(Marshal.SizeOf(info_struct));

            Marshal.StructureToPtr(info_struct, pnt, false);
            if (windowHandle == IntPtr.Zero || pnt == IntPtr.Zero)
            {
                return;
            }
            SendMessage((int)windowHandle, WM_USER + 58, 8, pnt);
            return;

            var c = new Callout
            {
                CalloutTitle   = title,
                CalloutContent = content
            };
            OverlayItemsControl f = new OverlayItemsControl();

            f.Items.Add(c);

            MapObj.MapView.Overlays.Items.Add(c);
            ViewBase.SetViewOverlayAnchor(c, location);
        }