Click or drag to resize

MapPoint Constructor (Double, Double)

Initializes a new instance of the MapPoint class.

Namespace:  Esri.ArcGISRuntime.Geometry
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.11.0
public MapPoint(
	double x,
	double y


Type: SystemDouble
Type: SystemDouble


Example Name: ChangeViewpoint

Set the map view to a new viewpoint.

Code example screen shot.

// Copyright 2016 Esri.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an 
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 
// language governing permissions and limitations under the License.

using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Geometry;
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;

namespace ArcGISRuntime.WPF.Samples.ChangeViewpoint
        name: "Change viewpoint",
        category: "MapView",
        description: "Set the map view to a new viewpoint.",
        instructions: "The map view has several methods for setting its current viewpoint. Select a viewpoint from the UI to see the viewpoint changed using that method.",
        tags: new[] { "animate", "extent", "pan", "rotate", "scale", "view", "zoom" })]
    public partial class ChangeViewpoint
        // Coordinates for London
        private MapPoint _londonCoords = new MapPoint(
            -13881.7678417696, 6710726.57374296, SpatialReferences.WebMercator);

        private double _londonScale = 8762.7156655228955;

        // Coordinates for Redlands
        private Polygon _redlandsEnvelope = new Polygon(new List<MapPoint>
                new MapPoint(-13049785.1566222, 4032064.6003424),
                new MapPoint(-13049785.1566222, 4040202.42595729),
                new MapPoint(-13037033.5780234, 4032064.6003424),
                new MapPoint(-13037033.5780234, 4040202.42595729)

        // Coordinates for Edinburgh
        private Polygon _edinburghEnvelope = new Polygon(new List<MapPoint>
                new MapPoint(-354262.156621384, 7548092.94093301),
                new MapPoint(-354262.156621384, 7548901.50684376),
                new MapPoint(-353039.164455303, 7548092.94093301),
                new MapPoint(-353039.164455303, 7548901.50684376)

        public ChangeViewpoint()

        private async void OnButtonClick(object sender, RoutedEventArgs e)
                // Get content from the selected item
                Button myButton = (Button)sender;

                switch (myButton.Content.ToString())
                    case "Geometry":

                        // Set Viewpoint using Redlands envelope defined above and a padding of 20
                        await MyMapView.SetViewpointGeometryAsync(_redlandsEnvelope, 20);

                    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);

                    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
                        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));

            catch (Exception ex)
                MessageBox.Show(ex.ToString(), "Error");
        <Style TargetType="Button">
            <Setter Property="Padding" Value="5" />
            <Setter Property="Margin" Value="5,5,0,0" />
        <esri:MapView x:Name="MyMapView">
                    <mapping:ArcGISTiledLayer x:Name="Basemap"
                                       Source="" />
        <Border Style="{StaticResource BorderStyle}">
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                <TextBlock Text="Use the buttons to set the viewpoint."
                           Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3"
                           HorizontalAlignment="Center" TextWrapping="Wrap"
                <Button Content="Geometry"
                        Grid.Row="1" Grid.Column="0"
                        ToolTip="Sets Viewpoint to a predefined Polygon's extent"
                        Click="OnButtonClick" />
                <Button Content="Center and scale"
                        Grid.Row="1" Grid.Column="1"
                        ToolTip="Sets Viewpoint a predefined point and scale"
                        Click="OnButtonClick" />
                <Button Content="Animate"
                        Grid.Row="1" Grid.Column="2"
                        ToolTip="Sets Viewpoint and animate repositioning of view"
                        Click="OnButtonClick" />
See Also
Additional Examples
Hyperlink to ExampleDescription
AddGraphicsRendererA renderer allows you to change the style of all graphics in a graphics overlay by referencing a single symbol style.
AddGraphicsWithSymbolsUse a symbol style to display a graphic on a graphics overlay.
ChangeViewpointSet the map view to a new viewpoint.
ConvexHullListGenerate convex hull polygon(s) from multiple input geometries.
CutGeometryCut a geometry along a polyline.
IdentifyGraphicsDisplay an alert message when a graphic is clicked.
NearestVertexFind the closest vertex and coordinate of a geometry to a point.
SpatialOperationsFind the union, intersection, or difference of two geometries.
SpatialRelationshipsDetermine spatial relationships between two geometries.