<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to move map using custom map tool just like Pro explore tool in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-move-map-using-custom-map-tool-just-like/m-p/1346517#M10658</link>
    <description>&lt;P&gt;I am trying to create Custom map tool like Explore tool. i have create custom UI like Explore tool. the tool should be able to move the map and zoom in and zoom out.&amp;nbsp;zoom in and zoom out&amp;nbsp; are working by default. but move map is not working for custom tool. can some one help me&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/12882"&gt;@Wolf&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Nov 2023 07:21:12 GMT</pubDate>
    <dc:creator>Hemant_Chitte</dc:creator>
    <dc:date>2023-11-07T07:21:12Z</dc:date>
    <item>
      <title>How to move map using custom map tool just like Pro explore tool</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-move-map-using-custom-map-tool-just-like/m-p/1346517#M10658</link>
      <description>&lt;P&gt;I am trying to create Custom map tool like Explore tool. i have create custom UI like Explore tool. the tool should be able to move the map and zoom in and zoom out.&amp;nbsp;zoom in and zoom out&amp;nbsp; are working by default. but move map is not working for custom tool. can some one help me&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/12882"&gt;@Wolf&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 07:21:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-move-map-using-custom-map-tool-just-like/m-p/1346517#M10658</guid>
      <dc:creator>Hemant_Chitte</dc:creator>
      <dc:date>2023-11-07T07:21:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to move map using custom map tool just like Pro explore tool</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-move-map-using-custom-map-tool-just-like/m-p/1347990#M10669</link>
      <description>&lt;P&gt;Hi you can do so by using&amp;nbsp;ZoomToAsync method. You can find the documentation here:&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic12017.html," target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic12017.html, &lt;/A&gt;and a sample code here:&lt;BR /&gt;&lt;A href="https://github.com/ArcGIS/arcgis-pro-sdk-community-samples/tree/master/Map-Exploration/BasicMapTool" target="_blank"&gt;https://github.com/ArcGIS/arcgis-pro-sdk-community-samples/tree/master/Map-Exploration/BasicMapTool&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 21:36:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-move-map-using-custom-map-tool-just-like/m-p/1347990#M10669</guid>
      <dc:creator>VedantBajaj</dc:creator>
      <dc:date>2023-11-09T21:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to move map using custom map tool just like Pro explore tool</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-move-map-using-custom-map-tool-just-like/m-p/1349685#M10700</link>
      <description>&lt;P&gt;This custom tool did the pan of the map for me:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;internal class MousePanTool : MapTool
{
    [DllImport("user32.dll")]
    public static extern short GetAsyncKeyState(UInt16 virtualKeyCode);
    public const int VK_LBUTTON = 0x01;
    private short _lastMouseButtonState = -1;

    private System.Windows.Point _fromMousePoint = new() { X = double.NaN, Y = double.NaN };
    private System.Windows.Point _toMousePoint = new() { X = double.NaN, Y = double.NaN };

    public MousePanTool()
    {
        SketchOutputMode = SketchOutputMode.Map;
    }

    /// &amp;lt;summary&amp;gt;
    /// Called when the mouse button is clicked in the view.
    /// &amp;lt;/summary&amp;gt;
    protected override void OnToolMouseDown(MapViewMouseButtonEventArgs e)
    {
        if (e.ChangedButton == System.Windows.Input.MouseButton.Left)
        {
            _fromMousePoint = e.ClientPoint;
            e.Handled = true;
            System.Diagnostics.Trace.WriteLine("!!! OnToolMouseDown");
        }                
        base.OnToolMouseDown(e);
    }

    /// &amp;lt;summary&amp;gt;
    /// Called when the mouse button is released in the view.
    /// &amp;lt;/summary&amp;gt;
    protected override void OnToolMouseUp(MapViewMouseButtonEventArgs e)
    {
        if (e.ChangedButton == System.Windows.Input.MouseButton.Left)
        {
            e.Handled = true;
            _fromMousePoint = new() { X = double.NaN, Y = double.NaN };
            System.Diagnostics.Trace.WriteLine("!!! OnToolMouseUp");
        }
        base.OnToolMouseUp(e);
    }

    private bool _isPanning = false;
    protected override async void OnToolMouseMove(MapViewMouseEventArgs e)
    {
        var mapView = MapView.Active;
        if (mapView == null || _isPanning)
            return;
        var mouseButtonState = GetAsyncKeyState(VK_LBUTTON);
        if ((mouseButtonState &amp;amp; 0x8000) == 0x0)
        {
            // the physical left button is not down anymore - stop panning
            _fromMousePoint = new() { X = double.NaN, Y = double.NaN };
            if (_lastMouseButtonState != mouseButtonState)
            {
                System.Diagnostics.Trace.WriteLine("!!! MouseUp during mouse move");
                _lastMouseButtonState = mouseButtonState;
            }
            return;
        }
        _lastMouseButtonState = mouseButtonState;
        if (_fromMousePoint.X != double.NaN)
        {
            _toMousePoint = e.ClientPoint;
            _isPanning = true;
            try
            {
                await QueuedTask.Run(() =&amp;gt;
                {
                    var fromPoint = mapView.ClientToMap(_fromMousePoint);
                    var toPoint = mapView.ClientToMap(_toMousePoint);
                    var deltaX = toPoint.X - fromPoint.X;
                    var deltaY = toPoint.Y - fromPoint.Y;
                    var camera = mapView.Camera;
                    camera.X -= deltaX;
                    camera.Y -= deltaY;
                    mapView.PanTo(camera);
                    _fromMousePoint = _toMousePoint;
                });
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex);
            }
            finally
            {
                _isPanning = false;
            }
            _isPanning = false;
            e.Handled = true;
        }
    }

    protected override Task OnToolActivateAsync(bool active)
    {
        _fromMousePoint = new() { X = double.NaN, Y = double.NaN };
        return base.OnToolActivateAsync(active);
    }

    protected override Task OnToolDeactivateAsync(bool active)
    {
        _fromMousePoint = new() { X = double.NaN, Y = double.NaN };
        return base.OnToolActivateAsync(active);
    }
}&lt;/LI-CODE&gt;&lt;P&gt;This sample only works for 'right-handed' mouse configurations, meaning the left mouse button is the 'physical' left mouse button.&amp;nbsp; To consider a 'left-handed' mouse configuration you can determine the system's current mapping of physical mouse buttons to logical mouse buttons by calling GetSystemMetrics(SM_SWAPBUTTON)&amp;nbsp;&lt;SPAN&gt;which returns TRUE if the mouse buttons were swapped.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Instead of writing your own custom navigation you can also reuse the map navigation functionality that's built into ArcGIS Pro:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var command = FrameworkApplication.GetPlugInWrapper("esri_mapping_exploreTool") as ICommand;
if (command.CanExecute(null))
    command.Execute(null);&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2023 14:55:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-move-map-using-custom-map-tool-just-like/m-p/1349685#M10700</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2023-11-15T14:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to move map using custom map tool just like Pro explore tool</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-move-map-using-custom-map-tool-just-like/m-p/1349694#M10701</link>
      <description>&lt;P&gt;In order to consider left-handedness, you can use this code snippet (i didn't test this one):&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;    [DllImport("user32.dll")]
    public static extern short GetAsyncKeyState(UInt16 virtualKeyCode);
    public const int VK_LBUTTON = 0x01;
    public const int VK_RBUTTON = 0x02;
    private short _lastMouseButtonState = -1;

    [DllImport("user32.dll")]
    public static extern Int32 GetSystemMetrics(Int32 bSwap);
    public const int SM_SWAPBUTTON = 23;

...
var logicalLeftButton = Convert.ToUInt16(GetSystemMetrics(SM_SWAPBUTTON) != 0 ? VK_RBUTTON : VK_LBUTTON);
var mouseButtonState = GetAsyncKeyState(logicalLeftButton);&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 15 Nov 2023 15:12:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-move-map-using-custom-map-tool-just-like/m-p/1349694#M10701</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2023-11-15T15:12:16Z</dc:date>
    </item>
  </channel>
</rss>

