Zoom to Street level from World level

541
6
10-25-2023 08:15 AM
VeenaHosur3
New Contributor II

HI All,

I am trying to zoom to feature from full extent to street level(5000 scale) but its not taking directly to street level . It is zooming to 5000 less scale from top level.

await Mapview.SetViewpointScaleAsync(new Viewpoint(Y,X,5000))

Any idea how to zoom to street level

0 Kudos
6 Replies
ThadTilton
Esri Contributor

Hi!

The SetViewpointScaleAsync() method takes a double to represent the scale (not a Viewpoint). It will zoom in to the current center point. Try it with just the value 5000 and see if that works. If you want to provide a specific point to zoom to (at a specified scale), try SetViewpointAsync() and provide a Viewpoint that defines a point and a scale (as you've done above).

I hope that helps! Thad

0 Kudos
VeenaHosur3
New Contributor II

sorry my bad . I am using same  SetViewpointAsync() with Viewpoint and scale 5000 only but its not working 

0 Kudos
ThadTilton
Esri Contributor

Also, you might find this useful for determining the relative scale value for various "zoom levels" (world, region, city, street, etc): Zoom level to scale converter

(it's a little hidden on the page, you need to expand the link that says "Zoom level to scale converter")

0 Kudos
dotMorten_esri
Esri Notable Contributor

One more thing to consider in addition to Thad's suggestions: The map you have loaded might default to a maximum scale that is higher than 5000. You can however easily check that if you try and zoom in with the mouse after: If you're not able to zoom in more, it's because reached the default scale limits of that specific map (you can override it by setting the max scale of the layer limiting it)

0 Kudos
VeenaHosur3
New Contributor II

below code used to zoom to feature at street level. it is taking 3 clicks to zoom to street level. And also viewModel_PropertyChanged is triggering twice.

async void viewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
 
 
     if (isMapVisible)
     {
 
         MgdControlListView agentryVMMgdControlListView = sender as MgdControlListView;
         //Action only when the Agentry item is selected
         if (agentryVMMgdControlListView.SelectedItem != null && e.PropertyName.Equals("AgentrySelectedIndex"))
             await RecenterSelectedWorkOrder();
     }
     else
     {
         isAutoRefreshNeeded = true;
     }
 
 
}
private async Task RecenterSelectedWorkOrder()
{
         if (mapControl != null)
         {
             orderNumber = viewModel.GetAgentryString(Globals.zIsSelected);
             ApplicationViewModel vm = mapControl.DataContext as ApplicationViewModel;
             MapView mapView = ((AgentryClientControls.EsriMap.EsriMapViewController)mapControl).mapView;
             if (vm != null)
             {
                 foreach (MapPointModel Point in vm.MapPoints)
                 {
                     if (!Point.IsAggregate && Point.Detail.Contains(orderNumber))
                     {
                         //if we are here then it is a match and hence assign it as selected map point
                         vm.SelectedMapPoint = Point;
                         MapPoint featureExtent = (MapPoint)((Esri.ArcGISRuntime.UI.Graphic)Point.GraphicIndicator).Geometry;
                         await mapView.SetViewpointAsync(new Viewpoint(featureExtent.Y,featureExtent.X,5000));
 
 
                     }
 
                 }
             }
         }
}

 

0 Kudos
VeenaHosur3
New Contributor II

below code using to zoom to feature at street level. When click feature its taking 3 clicks to zoom to street level . And also viewModel_PropertyChanged method triggering twice 

async void viewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
 
 
     if (isMapVisible)
     {
 
         MgdControlListView agentryVMMgdControlListView = sender as MgdControlListView;
         //Action only when the Agentry item is selected
         if (agentryVMMgdControlListView.SelectedItem != null && e.PropertyName.Equals("AgentrySelectedIndex"))
             await RecenterSelectedWorkOrder();
     }
     else
     {
         isAutoRefreshNeeded = true;
     }
 
 
}
private async Task RecenterSelectedWorkOrder()
{
         if (mapControl != null)
         {
             orderNumber = viewModel.GetAgentryString(Globals.zIsSelected);
             ApplicationViewModel vm = mapControl.DataContext as ApplicationViewModel;
             MapView mapView = ((AgentryClientControls.EsriMap.EsriMapViewController)mapControl).mapView;
             if (vm != null)
             {
                 foreach (MapPointModel Point in vm.MapPoints)
                 {
                     if (!Point.IsAggregate && Point.Detail.Contains(orderNumber))
                     {
                         //if we are here then it is a match and hence assign it as selected map point
                         vm.SelectedMapPoint = Point;
                         MapPoint featureExtent = (MapPoint)((Esri.ArcGISRuntime.UI.Graphic)Point.GraphicIndicator).Geometry;
                         await mapView.SetViewpointAsync(new Viewpoint(featureExtent.Y,featureExtent.X,5000));
 
 
                     }
 
                 }
             }
         }
}

 

0 Kudos