/// <summary> Handles the click on the map. </summary> /// <param name="sender"> The sender of the MouseDown event. </param> /// <param name="e"> The event parameters. </param> private void map_MouseDown(object sender, MouseButtonEventArgs e) { if (!(e.ChangedButton == MouseButton.Left && e.ButtonState == MouseButtonState.Pressed)) { return; } // get clicked coordinate and transform to PTV Mercator var canvasPoint = e.GetPosition(this); var mercatorPoint = CanvasToPtvMercator(canvasPoint); // ctrl-key adds the selected polygon if (!(Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))) { geometries.Clear(); } // query the items for a point (which is a rectangle of size 0) foreach (var geoItem in provider.QueryBBox(mercatorPoint.X, mercatorPoint.Y, mercatorPoint.X, mercatorPoint.Y, null)) { // parse the geometry from the wkb to a WPF path // transform to canvas coordinates var geometry = WkbToWpf.Parse(geoItem.Wkb, PtvMercatorToCanvas); // The result set conains all geometries whose *envelope* contains the point. // Check for exact containment if (geometry.FillContains(canvasPoint)) { geometries.Add(geometry); } } }