예제 #1
0
        private Task <Tuple <IDisposable, long> > AddFeatureToOverlay(MapViewMouseEventArgs e)
        {
            return(QueuedTask.Run(() => {
                double llx = e.ClientPoint.X - 3;
                double lly = e.ClientPoint.Y - 3;
                double urx = e.ClientPoint.X + 3;
                double ury = e.ClientPoint.Y + 3;

                EnvelopeBuilder envBuilder = new EnvelopeBuilder(ActiveMapView.ClientToMap(new Point(llx, lly)),
                                                                 ActiveMapView.ClientToMap(new Point(urx, ury)));

                MapPoint mp = ActiveMapView.ClientToMap(e.ClientPoint);
                var cursor = _trees.Search(new SpatialQueryFilter()
                {
                    FilterGeometry = envBuilder.ToGeometry(), SpatialRelationship = SpatialRelationship.Intersects
                });
                if (cursor.MoveNext())
                {
                    return new Tuple <IDisposable, long>(
                        ActiveMapView.AddOverlay(ActiveMapView.ClientToMap(e.ClientPoint),
                                                 _overlaySymbol.MakeSymbolReference()),
                        cursor.Current.GetObjectID());
                }

                //var select = _trees.Select(new SpatialQueryFilter() {
                //    FilterGeometry = envBuilder.ToGeometry(),
                //    SpatialRelationship = SpatialRelationship.Intersects
                //});
                //if (select.GetCount() > 0) {
                //    return ActiveMapView.AddOverlay(ActiveMapView.ClientToMap(e.ClientPoint), _overlaySymbol.MakeSymbolReference());
                //}

                return new Tuple <IDisposable, long>(null, -1);
            }));
        }