// ズームアウトボタンのイベント ハンドラー private async void OnZoomout(object sender, RoutedEventArgs e) { // 現在のマップのスケールを取得し、2 倍のスケールで表示する var currentScale = MyMapView.MapScale; var scale = currentScale * 2; await MyMapView.SetViewpointScaleAsync(scale); }
private void LoadWorkbench() { MyViewPoint p = ViewPointWork.LoadPoint(); MyMapView.SetViewpointCenterAsync(new MapPoint(p.X, p.Y, new Esri.ArcGISRuntime.Geometry.SpatialReference(p.Wkid))); MyMapView.SetViewpointScaleAsync(p.Scale); }
private async void OnViewpointsClicked(object sender, EventArgs e) { try { // Show sheet and get title from the selection string selectedMapTitle = await((Page)Parent).DisplayActionSheet("Select viewpoint", "Cancel", null, titles); // If selected cancel do nothing if (selectedMapTitle == "Cancel") { return; } switch (selectedMapTitle) { case "Geometry": // Set Viewpoint using Redlands envelope defined above and a padding of 20 await MyMapView.SetViewpointGeometryAsync(RedlandsEnvelope, 20); break; case "Center & Scale": // Set Viewpoint so that it is centered on the London coordinates defined above await MyMapView.SetViewpointCenterAsync(LondonCoords); // Set the Viewpoint scale to match the specified scale await MyMapView.SetViewpointScaleAsync(LondonScale); break; case "Animate": // Navigate to full extent of the first baselayer before animating to specified geometry await MyMapView.SetViewpointAsync( new Viewpoint(MyMapView.Map.Basemap.BaseLayers.First().FullExtent)); // Create a new Viewpoint using the specified geometry Viewpoint viewpoint = new Viewpoint(EdinburghEnvelope); // Set Viewpoint of MapView to the Viewpoint created above and animate to it using a timespan of 5 seconds await MyMapView.SetViewpointAsync(viewpoint, TimeSpan.FromSeconds(5)); break; default: break; } } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.ToString(), "OK"); } }
private async void LoadWMTSLayer(bool uriMode) { try { // Create a new map. Map myMap = new Map(); // Get the basemap from the map. Basemap myBasemap = myMap.Basemap; // Get the layer collection for the base layers. LayerCollection myLayerCollection = myBasemap.BaseLayers; // Create an instance for the WMTS layer. WmtsLayer myWmtsLayer; // Define the Uri to the WMTS service. Uri wmtsUri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/WMTS"); if (uriMode) { // Create a WMTS layer using a Uri and provide an Id value. myWmtsLayer = new WmtsLayer(wmtsUri, "WorldTimeZones"); } else { // Define a new instance of the WMTS service. WmtsService myWmtsService = new WmtsService(wmtsUri); // Load the WMTS service. await myWmtsService.LoadAsync(); // Get the service information (i.e. metadata) about the WMTS service. WmtsServiceInfo myWmtsServiceInfo = myWmtsService.ServiceInfo; // Obtain the read only list of WMTS layer info objects. IReadOnlyList <WmtsLayerInfo> myWmtsLayerInfos = myWmtsServiceInfo.LayerInfos; // Create a WMTS layer using the first item in the read only list of WMTS layer info objects. myWmtsLayer = new WmtsLayer(myWmtsLayerInfos[0]); } // Add the WMTS layer to the layer collection of the map. myLayerCollection.Add(myWmtsLayer); // Assign the map to the MapView. MyMapView.Map = myMap; // Zoom to appropriate level for iOS. await MyMapView.SetViewpointScaleAsync(300000000); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Sample error", ex.ToString(), "OK"); } }
private async void Initialize() { // Create new Map with basemap Map myMap = new Map(Basemap.CreateTopographic()); // Provide Map to the MapView MyMapView.Map = myMap; // Create geometry for the center of the map MapPoint centerGeometry = new MapPoint(-13549402.587055, 4397264.96879385, SpatialReference.Create(3857)); // Set the map's viewpoint to highlight the desired content await MyMapView.SetViewpointCenterAsync(centerGeometry); await MyMapView.SetViewpointScaleAsync(201555.279); // Get the path to the geodatabase string geodbFilePath = await GetPreparedFilePath(_geodatabaseName, _geodatabaseId); // Load the geodatabase from local storage Geodatabase baseGeodatabase = await Geodatabase.OpenAsync(geodbFilePath); // Get the path to the symbol dictionary string symbolFilepath = await GetPreparedFilePath(_symbolDefName, _symbolDefId); // Load the symbol dictionary from local storage // Note that the type of the symbol definition must be explicitly provided along with the file name DictionarySymbolStyle symbolStyle = await DictionarySymbolStyle.OpenAsync("mil2525d", symbolFilepath); // Add geodatabase features to the map, using the defined symbology foreach (FeatureTable table in baseGeodatabase.GeodatabaseFeatureTables) { // Load the table await table.LoadAsync(); // Create the feature layer from the table FeatureLayer myLayer = new FeatureLayer(table); // Load the layer await myLayer.LoadAsync(); // Create a Dictionary Renderer using the DictionarySymbolStyle DictionaryRenderer dictRenderer = new DictionaryRenderer(symbolStyle); // Apply the dictionary renderer to the layer myLayer.Renderer = dictRenderer; // Add the layer to the map myMap.OperationalLayers.Add(myLayer); } }
private async void OnButtonClick(object sender, RoutedEventArgs e) { try { // Get .Content from the selected item Button myButton = (Button)sender; string selectedMapTitle = myButton.Content.ToString(); switch (selectedMapTitle) { case "Geometry": // Set Viewpoint using Redlands envelope defined above and a padding of 20 await MyMapView.SetViewpointGeometryAsync(_redlandsEnvelope, 20); break; case "Center and Scale": // Set Viewpoint so that it is centered on the London coordinates defined above await MyMapView.SetViewpointCenterAsync(_londonCoords); // Set the Viewpoint scale to match the specified scale await MyMapView.SetViewpointScaleAsync(_londonScale); break; case "Animate": // Navigate to full extent of the first baselayer before animating to specified geometry await MyMapView.SetViewpointAsync( new Viewpoint(MyMapView.Map.Basemap.BaseLayers.First().FullExtent)); // Create a new Viewpoint using the specified geometry Viewpoint viewpoint = new Viewpoint(_edinburghEnvelope); // Set Viewpoint of MapView to the Viewpoint created above and animate to it using a timespan of 5 seconds await MyMapView.SetViewpointAsync(viewpoint, TimeSpan.FromSeconds(5)); break; default: break; } } catch (Exception ex) { await new MessageDialog2(ex.ToString(), "Error").ShowAsync(); } }
private async void Button_Click(object sender, RoutedEventArgs e) { ////await MyMapView.SetViewpointScaleAsync(2000); //bool btnClick = false; //double a = 15000; //btnClick = !btnClick; //if (btnClick == true) //{ // if(maxZoomIn > 12000 ) // { // await MyMapView.SetViewpointScaleAsync(maxZoomIn = maxZoomIn - a); // currentScale = maxZoomIn; // } //} //else //{ // return; //} var main = new MainWindow(); bool btnClick = false; double a = 15000; btnClick = !btnClick; if (btnClick == true) { if (currentScale > 12000) { await MyMapView.SetViewpointScaleAsync(maxZoomIn = maxZoomIn - a); currentScale = maxZoomIn; } } else { return; } }
private async void OnButtonClick(object sender, RoutedEventArgs e) { // Get content from the selected item Button myButton = sender as Button; switch (myButton.Content.ToString()) { case "Geometry": // Set Viewpoint using Redlands envelope defined above and a padding of 20 await MyMapView.SetViewpointGeometryAsync(_redlandsEnvelope, 20); break; case "Center and Scale": // Set Viewpoint so that it is centered on the London coordinates defined above await MyMapView.SetViewpointCenterAsync(_londonCoords); // Set the Viewpoint scale to match the specified scale await MyMapView.SetViewpointScaleAsync(_londonScale); break; case "Animate": // Navigate to full extent of the first baselayer before animating to specified geometry await MyMapView.SetViewpointAsync( new Viewpoint(Basemap.FullExtent)); // Create a new Viewpoint using the specified geometry var viewpoint = new Viewpoint(_edinburghEnvelope); // Set Viewpoint of MapView to the Viewpoint created above and animate to it using a timespan of 5 seconds await MyMapView.SetViewpointAsync(viewpoint, TimeSpan.FromSeconds(5)); break; default: break; } }
private async void ZoomOut_Click(object sender, RoutedEventArgs e) { bool btnOutClick = false; double a = 15000; btnOutClick = !btnOutClick; if (btnOutClick == true) { if (currentScale < 12000 && currentScale > 115000) { await MyMapView.SetViewpointScaleAsync(currentScale + a); currentScale = maxZoomIn; } } else { return; } }