Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

how can i find distance between lat and long of maps?

$
0
0

how can i find distance between lat and long of maps? my code displaying polyline like this now i want to find distance between each coordinate..

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.Maps;
using Xamarin.Forms.Xaml;
using CoreLocation;

namespace polyline
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MapPage : ContentPage
{
public MapPage()
{
InitializeComponent();
customMap.RouteCoordinates.Add(new Position(12.839939, 77.677003));
customMap.RouteCoordinates.Add(new Position(12.869582, 77.769525));
customMap.RouteCoordinates.Add(new Position(12.931541, 77.840302));
customMap.RouteCoordinates.Add(new Position(12.973947, 77.840302));
customMap.RouteCoordinates.Add(new Position(12.990840, 77.760781));
customMap.RouteCoordinates.Add(new Position(13.004017, 77.687776));
customMap.RouteCoordinates.Add(new Position(12.927923, 77.627108));
customMap.RouteCoordinates.Add(new Position(12.866189, 77.660413));

        var pin = new CustomPin
        {
          Type = PinType.Place,
            Position=new Position(12.839939, 77.677003),
            Label = "(Starting point)Electronic city",
            Address = "Electronic city,Banglore",
            Id = "1",

            //Url = "http://xamarin.com/about/"     
        };
        var pin1 = new CustomPin
        {
            Type = PinType.Place,
            Position = new Position(12.869582, 77.769525),
            Label = "Sompura",
            Address = "Sompura,Banglore",
            Id = "2",
           // Url = "http://xamarin.com/about/"
        };
        var pin2 = new CustomPin
        {
            Type = PinType.Place,
            Position = new Position(12.931541, 77.840302),
            Label = "kalkunte",
            Address = "kalkunte,Banglore",
            Id = "3",
            // Url = "http://xamarin.com/about/"
        };
        var pin3 = new CustomPin
        {
            Type = PinType.Place,
            Position = new Position(12.973947, 77.840302),
            Label = "Devanagonthi",
            Address = "Devanagonthi,Banglore",
            Id = "4",
            // Url = "http://xamarin.com/about/"
        };
        var pin4 = new CustomPin
        {
            Type = PinType.Place,
            Position = new Position(12.990840, 77.760781),
            Label = "Kadugodi",
            Address = "Kadugodi,Banglore",
            Id = "5",
            // Url = "http://xamarin.com/about/"
        };
        var pin5 = new CustomPin
        {
            Type = PinType.Place,
            Position = new Position(13.004017, 77.687776),
            Label = "krishnarajapuram",
            Address = "krishnarajapuram,Banglore",
            Id = "6",
            // Url = "http://xamarin.com/about/"
        };
        var pin6 = new CustomPin
        {
            Type = PinType.Place,
            Position = new Position(12.927923, 77.627108),
            Label = "Kormangala",
            Address = "Kormangala,Banglore",
            Id = "7",
            // Url = "http://xamarin.com/about/"
        };
        var pin7 = new CustomPin
        {
            Type = PinType.Place,
            Position = new Position(12.866189, 77.660413),
            Label = "(Ending point)beratana agrahara",
            Address = "beratana agrahara,Banglore",     
            Id = "7",
            // Url = "http://xamarin.com/about/"
        };

        //customMap.CustomPins = new List<CustomPin> { pin };
        customMap.Pins.Add(pin);
        customMap.Pins.Add(pin1);
        customMap.Pins.Add(pin2);
        customMap.Pins.Add(pin3);
        customMap.Pins.Add(pin4);
        customMap.Pins.Add(pin5);
        customMap.Pins.Add(pin6);
        customMap.Pins.Add(pin7);
        customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(12.912342, 77.752929), Distance.FromMiles(10.0)));
    }

}

}


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>