public MainPage { InitializeComponent(); MyMap.MouseLeftButtonDown +=new MouseButtonEventHandler(MapaImpressao_MouseLeftButtonDown); } /* This triggers when the the button is PRESSED! if you want it to Trigger when the user stops * holding the button, change Down to Up. * Also, if you want that if works if the Right button instead of the left, change Left to Right. */ private void MyMap_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { //This shows the coordinates relative to the Root of the application MessageBox.Show(string.Format("X: {0}, Y: {1}", e.GetPosition(LayoutRoot).X, e.GetPosition(LayoutRoot).Y)); //This shows the coordinates relative to the Map of the application MessageBox.Show(string.Format("X: {0}, Y: {1}", e.GetPosition(MyMap).X, e.GetPosition(MyMap).Y)); //changing "MyMap" to any other object on the screen (like an Grid, or Border) will change the Reference of the coordinates //This 2 lines bellow will center the point you clicked on the map. MapPoint coordinate = new MapPoint(e.GetPosition(MyMap).X, e.GetPosition(MyMap).Y); MyMap.PanTo(coordinate); }
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.