private void AreaResizeMenuItem_Click(object sender, RoutedEventArgs e) { MenuItem item = (MenuItem)sender; Feature feature = (Feature)item.Tag; AreaBaseShape areaShape = (AreaBaseShape)feature.GetShape(); AreaResizeWindow window = new AreaResizeWindow(areaShape); window.Owner = Application.Current.MainWindow; window.WindowStartupLocation = WindowStartupLocation.CenterOwner; if (window.ShowDialog().GetValueOrDefault()) { double orignalAcreage = window.OriginalAcreage; double acreage = window.ResultAcreage; double difference = 1; while (difference > 0.05) { if (acreage > orignalAcreage) { double percentage = (Math.Sqrt(acreage) / Math.Sqrt(orignalAcreage) * 100) % 100; areaShape.ScaleUp(percentage); } else if (acreage == orignalAcreage) { } else { double percentage = (Math.Sqrt(orignalAcreage) / Math.Sqrt(acreage) * 100) % 100; areaShape.ScaleDown(percentage); } orignalAcreage = areaShape.GetArea(GisEditor.ActiveMap.MapUnit, AreaResizeWindow.DefaultAreaUnit); difference = Math.Abs(orignalAcreage - acreage) / acreage; } Feature tempfeature = GisEditor.ActiveMap.FeatureLayerEditOverlay.EditShapesLayer.InternalFeatures.FirstOrDefault(f => f.Id.Equals(feature.Id)); if (tempfeature != null) { GisEditor.ActiveMap.FeatureLayerEditOverlay.EditShapesLayer.InternalFeatures.Remove(tempfeature); GisEditor.ActiveMap.FeatureLayerEditOverlay.EditShapesLayer.InternalFeatures.Add(tempfeature.Id, new Feature(areaShape, tempfeature.ColumnValues)); GisEditor.ActiveMap.FeatureLayerEditOverlay.TakeSnapshot(); GisEditor.ActiveMap.FeatureLayerEditOverlay.Refresh(); } } }
/// <summary> /// Setup the map with the ThinkGeo Cloud Maps overlay to show a basic map /// </summary> protected override void OnAppearing() { base.OnAppearing(); // It is important to set the map unit first to either feet, meters or decimal degrees. mapView.MapUnit = GeographyUnit.DecimalDegree; // Create the background world maps using vector tiles requested from the ThinkGeo Cloud Service and add it to the map. ThinkGeoCloudVectorMapsOverlay thinkGeoCloudVectorMapsOverlay = new ThinkGeoCloudVectorMapsOverlay("itZGOI8oafZwmtxP-XGiMvfWJPPc-dX35DmESmLlQIU~", "bcaCzPpmOG6le2pUz5EAaEKYI-KSMny_WxEAe7gMNQgGeN9sqL12OA~~", ThinkGeoCloudVectorMapsMapType.Light); mapView.Overlays.Add(thinkGeoCloudVectorMapsOverlay); // Creating a rectangle area we will use to generate the polygons and also start the map there. RectangleShape currentExtent = new RectangleShape(-10810995.245624, 3939081.90719325, -10747552.5124997, 3884429.43227297); //Do all the things we need to setup the polygon layer and overlay such as creating all the polygons etc. AddPolygonOverlay(AreaBaseShape.ScaleDown(currentExtent.GetBoundingBox(), 80).GetBoundingBox()); //Set the maps current extent so we start there mapView.CurrentExtent = currentExtent; }