title: how to set zoom level dynamic in xamarin form map
body: <p>I want to set zoom level in map dynamically in <code>Xamarin Form Map</code> when its loading. I am trying to use the <a href="https://developer.xamarin.com/samples/xamarin-forms/WorkingWithMaps/" rel="nofollow noreferrer">Working with Maps</a>. The zoom level is working in the code on slider value change.</p>
  
  <pre><code>slider.ValueChanged += (sender, e) =&gt; {
              var zoomLevel = e.NewValue; // between 1 and 18
            var latlongdegrees = 360 / (Math.Pow(2, zoomLevel));
            // // Debug.WriteLine(zoomLevel + " -&gt; " + latlongdegrees);
              if (map.VisibleRegion != null)
                  map.MoveToRegion(new MapSpan(map.VisibleRegion.Center, latlongdegrees, latlongdegrees));
          };
  </code></pre>
  
  <p>but i want to remove the slider and set zoom level 16.71 when map load on device and do not want to use the slider. How can i do this </p>
  
  <p><strong>Complete Code i used</strong></p>
  
  <pre><code> map = new Map
          {
              //IsShowingUser = true,
              HeightRequest = 100,
              WidthRequest = 960,
              VerticalOptions = LayoutOptions.FillAndExpand,
              MapType=MapType.Street,
  
          };
         // map.MoveToRegion(new MapSpan(new Position(28.6587067, 77.14514),360,360));
          map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(28.6587067, 77.14514), Distance.FromMiles(3)));
          var position = new Position(28.6587067, 77.14514);
          var pin = new Pin
          {
              Type = PinType.Place,
              Position = position,
              Label = "xx"
              //,
              //Address = "We are here"
          };
          map.Pins.Add(pin);
         // var latlongdegrees = 360 / (Math.Pow(2, 17.51));
          //if (map.VisibleRegion != null)
           //   map.MoveToRegion(new MapSpan(map.VisibleRegion.Center, latlongdegrees, latlongdegrees));
  
          // add the slider
          var slider = new Slider(16, 18, 1);
          slider.ValueChanged += (sender, e) =&gt; {
              var zoomLevel = e.NewValue; // between 1 and 18
            var latlongdegrees = 360 / (Math.Pow(2, zoomLevel));
            // // Debug.WriteLine(zoomLevel + " -&gt; " + latlongdegrees);
              if (map.VisibleRegion != null)
                  map.MoveToRegion(new MapSpan(map.VisibleRegion.Center, latlongdegrees, latlongdegrees));
          };
  
  
          // create map style buttons
          var street = new Button { Text = "Street" };
          var hybrid = new Button { Text = "Hybrid" };
          var satellite = new Button { Text = "Satellite" };
          street.Clicked += HandleClicked;
          hybrid.Clicked += HandleClicked;
          satellite.Clicked += HandleClicked;
          var segments = new StackLayout
          {
              Spacing = 30,
              HorizontalOptions = LayoutOptions.CenterAndExpand,
              Orientation = StackOrientation.Horizontal,
              Children = { street, hybrid, satellite }
          };
  
  
          // put the page together
          var stack = new StackLayout { Spacing = 0 };
          stack.Children.Add(map);
          stack.Children.Add(slider);
          stack.Children.Add(segments);
          Content = stack;
  
  
          // for debugging output only
          map.PropertyChanged += (sender, e) =&gt; {
              Debug.WriteLine(e.PropertyName + " just changed!");
              if (e.PropertyName == "VisibleRegion" &amp;&amp; map.VisibleRegion != null)
                  CalculateBoundingCoordinates(map.VisibleRegion);
          };
  </code></pre>