Xamarin Forms and maps - getting coordinates on a map, creating routes?

I am using the latest version of Xamarin Forms for my application. This application has tight integration with cards. Android and iOS are two supported platforms.

Now I can implement two things:

  • Centering the map at any position when I have coordinates
  • Adding custom markers (contacts)

The following functions are still required (in order of importance):

  • Getting coordinates by map display event
  • Getting coordinates in response to some search string with address
  • Routing between two points (making a route line)
  • Calculation of time / distance between two points

I am new to Xamarin, I checked the Xamarin Forms Maps API and since I donโ€™t see the possibility of implementing these 4 points with it.

? Xamarin Forms ? Xamarin Android/iOS?

! . API Google Java, , Xamarin. Xamarin, #, .

+4
1

iOS Android , SAP PCL, , .

* . - , , . , , .

-

interface IMapping
{
    public OpenMap(); 
    public Model<GeoPoint>GetLastTouchCoordinates();         
}

Android- -

//For use with Xamarin.Forms.DependencyService will not be necessary with other IoC containers if not using forms look up Tiny IoC, Unity or one of the other DI containers
[assembly: Xamarin.Forms.Dependency(typeof(YourNameSpace.Droid.YourClass))] 

public class GoogleMap : FragmentActivity, IMapping, IOnMapClickListener

{
 private GoogleMap mMap;
 private Point lastClickedPoint;

protected void OnCreate()
{
    base.OnCreate();
    setContentView(some map fragment layout)

    //set the map touch listener
}

private void handletouch()// implementation of IOnMapClickListener Interface
{
    //google how to get the coordinates in android on a map touch
    lastClickedPoint = new Point();
    lastClickedPoint.lat = args.lat;
    lastClickedPoint.long = args.long;
}

private Model<GeoPoint> GetLastTouchCoordinates()
{
    if(lastclickedPoint != null)
    {
    Model<Geopoint> gp = new Model<Geopoint>();
    gp.latitude = p.latitude;
    gp.longitude = p.longitude;
    return gp;
    }
    else
    {
      return Point with some indication that you have no point
    }

}
}

-

, , -

DependencyService.Get<IMapping>.OpenMap()
DependencyService.Get<IMapping>.GetLastTouchCoordinates()

- http://adventuresinxamarinforms.com/2014/11/17/creating-a-xamarin-forms-application-part-4-dependency-injection/

+4

All Articles