Пример #1
0
        public void findAddress(string address)
        {
            MapPoint.Map map = mainFrm.frmMapPoint.Map.ActiveMap;

            //Call the ShowFindDialog to show the find (modal) dialog
            object result = map.ShowFindDialog(address, MapPoint.GeoFindState.geoFindDefault, (int)mainFrm.Handle, false);

            //See if the result is null
            if (result != null)
            {
                //If the result is a Location type get the
                //Location directly
                if (result is MapPoint.Location)
                {
                    currentLocation = result as MapPoint.Location;
                }
                else if (result is MapPoint.Pushpin)
                {
                    //If this is a Pushpin type, first get the Pushpin
                    MapPoint.Pushpin pushpin = result as MapPoint.Pushpin;
                    //Then get the location
                    currentLocation = pushpin.Location;
                }
                txtDestination.Text = currentLocation.Name;
            }
            else
            {
                MessageBox.Show("No locations found. Please verify the input.");
            }
        }
        public void findAddress(string Address)
        {
            string[] POS = Address.Split('|');

            MapPoint.Map map = mainFrm.frmMapPoint.Map.ActiveMap;

            object result = null;

            //if(POS[0]=="" || POS[1] == "")
            if (POS.Length == 1)
            {
                result = map.ShowFindDialog(POS[0], MapPoint.GeoFindState.geoFindAddress, (int)mainFrm.Handle, false);
            }
            else if (POS.Length > 1)
            {
                result = map.ShowFindDialog(POS[1] + ";" + POS[2], MapPoint.GeoFindState.geoFindLatLong, (int)mainFrm.Handle, false);
            }

            //See if the result is null
            if (result != null)
            {
                //If the result is a Location type get the
                //Location directly
                if (result is MapPoint.Location)
                {
                    currentLocation = result as MapPoint.Location;
                }
                else if (result is MapPoint.Pushpin)
                {
                    //If this is a Pushpin type, first get the Pushpin
                    MapPoint.Pushpin pushpin = result as MapPoint.Pushpin;
                    //Then get the location
                    currentLocation = pushpin.Location;
                }
                txtDestination.Text = currentLocation.Name;
                addNewPOI(currentLocation.Name, Math.Round(currentLocation.Latitude, 6).ToString(), Math.Round(currentLocation.Longitude, 6).ToString());
            }
            else
            {
                MessageBox.Show("No locations found. Please verify the input.");
            }
        }