protected Envelope CreateHitBox(MapView mapView, MapPoint location, double sizeInPoints, SpatialReference spatialRef) { var sizeInPixels = Drawing.PixelsFromPoints(sizeInPoints); var refPoint = mapView.MapToClient(location); var minPoint = mapView.ClientToMap(new System.Windows.Point(refPoint.X - sizeInPixels, refPoint.Y + sizeInPixels)); // remember, screen Y axis starts from top to bottom var maxPoint = mapView.ClientToMap(new System.Windows.Point(refPoint.X + sizeInPixels, refPoint.Y - sizeInPixels)); return(EnvelopeBuilder.CreateEnvelope(minPoint, maxPoint, spatialRef)); }
public void setCurrentCoordinate() { MapView activeMapView = MapView.Active; this.coordinateCameraX = activeMapView.Camera.X; this.coordinateCameraY = activeMapView.Camera.Y; Task t = QueuedTask.Run(() => { MapPoint topLeftPoint = activeMapView.ClientToMap(new Point(0, 0)); this.coordinateTopX = topLeftPoint.X; this.coordinateTopY = topLeftPoint.Y; }); t.Wait(); this.coordinateBottomX = coordinateCameraX + coordinateCameraX - coordinateTopX; this.coordinateBottomY = coordinateCameraY + coordinateCameraY - coordinateTopY; }