void targetMap_ManipulationDelta(object sender, ManipulationDeltaEventArgs e) { e.Handled = true; if (this.targetMap == null) { return; } if (this.targetMap.Extent == null) { return; } if ((e.DeltaManipulation.Translation.X == 0) && (e.DeltaManipulation.Translation.Y == 0) && (e.DeltaManipulation.Scale.X == 1)) { return; } Matrix transformationMatrix = new Matrix(); if ((e.DeltaManipulation.Translation.X != 0) || (e.DeltaManipulation.Translation.Y != 0)) { transformationMatrix.Translate(-e.DeltaManipulation.Translation.X, -e.DeltaManipulation.Translation.Y); } if (!e.IsInertial) { if (e.DeltaManipulation.Scale.X != 1) { if (targetMap.TouchesCaptured.Count() > 1) { transformationMatrix.ScaleAt(1/e.DeltaManipulation.Scale.X, 1/e.DeltaManipulation.Scale.Y, e.ManipulationOrigin.X, e.ManipulationOrigin.Y); } } } Envelope en = this.targetMap.Extent; Point screenTopLeft = this.targetMap.MapToScreen(new MapPoint(en.Extent.XMin, en.Extent.YMin)); Point screenBottomRight = this.targetMap.MapToScreen(new MapPoint(en.Extent.XMax, en.Extent.YMax)); Point newScreenTopLeft = transformationMatrix.Transform(screenTopLeft); Point newScreenBottomRight = transformationMatrix.Transform(screenBottomRight); MapPoint newMapTopLeft = this.targetMap.ScreenToMap(newScreenTopLeft); MapPoint newMapBottomRight = this.targetMap.ScreenToMap(newScreenBottomRight); this.targetMap.Extent = new Envelope(newMapTopLeft, newMapBottomRight); }
void targetMap_ManipulationDelta(object sender, ManipulationDeltaEventArgs e) { e.Handled = true; if (this.targetMap == null) { return; } if (this.targetMap.Extent == null) { return; } if ((e.DeltaManipulation.Translation.X == 0) && (e.DeltaManipulation.Translation.Y == 0) && (e.DeltaManipulation.Scale.X == 1)) { return; } if ((e.DeltaManipulation.Translation.X != 0) || (e.DeltaManipulation.Translation.Y != 0)) { //Get map center coord MapPoint mapCenter = this.targetMap.Extent.GetCenter(); //convert to screen coord Point screenCenter = this.targetMap.MapToScreen(mapCenter); Point newScreenCenter; newScreenCenter = Point.Subtract(screenCenter, e.DeltaManipulation.Translation); MapPoint newMapCenter = this.targetMap.ScreenToMap(newScreenCenter); this.targetMap.PanTo(newMapCenter); } if (!e.IsInertial) { if (e.DeltaManipulation.Scale.X != 1) { if (targetMap.TouchesCaptured.Count() > 1) { Point currentManipulationOriginScreen = e.ManipulationOrigin; MapPoint zoomCenter = this.targetMap.ScreenToMap(currentManipulationOriginScreen); targetMap.ZoomToResolution(this.targetMap.Resolution / Math.Round(e.DeltaManipulation.Scale.X, 2), zoomCenter); } } } }
Another issue is i'm using the GeoRssLayer to display USGS earthquake data in the Web Mercator projection. I'm using the CollectionChanged event in the GeoRssLayer's Layer property to change the MapPoint geometry. However, my UI freezes a while when i'm adding this layer. I believe it is becaused the CollectionChanged event fires a hundred times which causes the slight freeze...
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.