public void Configure(string location)
        {
            var geoCoder = new CLGeocoder();

            Console.WriteLine(location);
            geoCoder.GeocodeAddress(location, AnnotationHandler);
        }
Example #2
0
		static Task<IEnumerable<Position>> GetPositionsForAddressAsync(string address)
		{
			var geocoder = new CLGeocoder();
			var source = new TaskCompletionSource<IEnumerable<Position>>();
			geocoder.GeocodeAddress(address, (placemarks, error) =>
			{
				if (placemarks == null)
					placemarks = new CLPlacemark[0];
				IEnumerable<Position> positions = placemarks.Select(p => new Position(p.Location.Coordinate.Latitude, p.Location.Coordinate.Longitude));
				source.SetResult(positions);
			});
			return source.Task;
		}
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///
        /// Member functions of the class
        ///
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////

        #region Member Functions

        /// <summary>
        /// Purpose: Gets the Person to get the data from -> Get the coordinate of the person -> call the Eventhandler to draw the annotation of the map
        /// Example: FillControls (person) -> HandleCLGeocodeCompletionHandler
        /// </summary>
        /// <param name="person">The person to fill the controlls with</param>
        public override void FillControls (BusinessLayer.Person person)
        {

            // Then fill the controls
            if (person == null || person.Name == null)
                return;

            _person = person;

            // Send the address infos of the person to the CLGeocoder to find the location
            CLGeocoder clg = new CLGeocoder(); 
            string location = person.Strasse + "," + person.Ort + "," + person.PLZ ;
            clg.GeocodeAddress(location, HandleCLGeocodeCompletionHandler);

        }
        static Task <IEnumerable <Position> > GetPositionsForAddressAsync(string address)
        {
            var geocoder = new CLGeocoder();
            var source   = new TaskCompletionSource <IEnumerable <Position> >();

            geocoder.GeocodeAddress(address, (placemarks, error) =>
            {
                if (placemarks == null)
                {
                    placemarks = new CLPlacemark[0];
                }
                IEnumerable <Position> positions = placemarks.Select(p => new Position(p.Location.Coordinate.Latitude, p.Location.Coordinate.Longitude));
                source.SetResult(positions);
            });
            return(source.Task);
        }
        public void GeoCodeAddress(string address, Action <double, double, Exception> action)
        {
            var GeoCoder = new CLGeocoder();

            GeoCoder.GeocodeAddress(address, (placemarks, error) =>
            {
                if (error == null)
                {
                    var placemark = placemarks[0];
                    action(placemark.Location.Coordinate.Latitude, placemark.Location.Coordinate.Longitude, null);
                }
                else
                {
                    action(0, 0, new Exception());
                }
            });
        }
Example #6
0
        public void SetAnnotation()
        {
            var geoCoder = new CLGeocoder();

            geoCoder.GeocodeAddress(RestaurantMO.Location, AnnotationHandler);
        }