Sorting of locations ref. nearest location.

Overview

Locations

Sort locations with nearest distance

How it works?

  • Get user's current location
  • Compare with other destinations
  • Sort according the nearest

There are two ways to compare distance

Personally, I like Haversine Formula and have been using it.

Algorithm 1

Use Havesine Formula.

Haversine Formula

double getDistanceFromLatLonInKm(lat1,lon1,lat2,lon2) {
  var R = 6371; // Radius of the earth in km
  var dLat = deg2rad(lat2-lat1);  // deg2rad below
  var dLon = deg2rad(lon2-lon1);
  var a =
      Math.sin(dLat/2) * Math.sin(dLat/2) +
          Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
              Math.sin(dLon/2) * Math.sin(dLon/2)
  ;
  var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
  var d = R * c; // Distance in km
  return d;
}

double deg2rad(deg) {
  return deg * (Math.pi/180);
}

Algorithm 2

Use inbuilt distance comparision function provided by Geolocater.

Geolocator.distanceBetween(source.latitude,source.longitude, destination.latitude,destination.longitude);

Assumption"

  • You are in Google Plex (37.422,-122.084)

Destinations:

  • Destination(37.4274684,-122.1698161, "Standford University"),
  • Destination(37.4083327,-122.0776016, "Taco Bell"),
  • Destination(37.4259071,-122.1095606, "Ramos Park"),
  • Destination(37.8711583,-122.336457, "Bekerly"),
  • Destination(37.7586968,-122.3053474, "Oakland"),
  • Destination(37.4420794,-122.1432758, "Palo Alto"),
  • Destination(37.5206515,-122.064364, "New wark")

Output:

Haversine Algorithm Geolocator Algorithm
You might also like...

Small application where I worked with streams, firebase database, sorting, adding, modifying and deleting data.

messenger_app Small application where I worked with streams, firebase database, sorting, adding, modifying and deleting data. Features Provider: takin

Dec 19, 2021

a incremental list of books for random sorting.

tbr A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this is y

Oct 9, 2022

Spaced is an animated travel application UI that enables users to find locations and schedule trips.

Spaced is an animated travel application UI that enables users to find locations and schedule trips.

spaced_travel_app Spaced is an animated travel application UI that enables users to find locations and schedule trips. It is based on an amazing UI by

Nov 10, 2022

This is a project developed in flutter for displaying time of the available locations.

This is a project developed in flutter for displaying time of the available locations.

World Time This is a project developed in flutter for displaying time of the available locations. ## Getting Started This project is a starting point

Oct 15, 2021

RoadMovie is an application that allows people who are in Moscow to explore the filming locations of Moscow films.

RoadMovie is an application that allows people who are in Moscow to explore the filming locations of Moscow films.

RoadMovie is an application that allows people who are in Moscow to explore the filming locations of Moscow films. Motivation There are many film fans

Oct 13, 2022

Polymaker is an application that can create polygon locations dynamically in mobile apps and save the data into SQFlite to be permanent.

Polymaker is an application that can create polygon locations dynamically in mobile apps and save the data into SQFlite to be permanent.

Polymaker Polymaker is an application that can create polygon locations dynamically in mobile apps and save the data into SQFlite to be permanent. Ins

Apr 17, 2022

FormField to pick one or more locations from open streat map

FormField to pick one or more locations from open streat map Features Pick single location Pick multi locations display open street maps can work with

Dec 15, 2022

World-time - A simple application that tells time from different locations by using worldtime api

World-time - A simple application that tells time from different locations by using worldtime api

world_time A new Flutter project. Getting Started This project is a starting poi

Feb 6, 2022

A Flutter plugin to easily handle realtime location in iOS and Android. Provides settings for optimizing performance or battery.

A Flutter plugin to easily handle realtime location in iOS and Android. Provides settings for optimizing performance or battery.

Flutter Location Plugin This plugin for Flutter handles getting location on Android and iOS. It also provides callbacks when location is changed. Gett

Dec 22, 2022

:fire:GeoFlutterFire:fire: is an open-source library that allows you to store and query firestore documents based on their geographic location.

:fire:GeoFlutterFire:fire: is an open-source library that allows you to store and query firestore documents based on their geographic location.

GeoFlutterFire 🌍 GeoFlutterFire is an open-source library that allows you to store and query a set of keys based on their geographic location. At its

Dec 11, 2022

This project has the vision to assist the officials for Forest trees census and tagging each tree with proper location (latitude and longitude), tree type, and other arguments. and further had the plan to apply data analysis over-collected data.

🌳 Trees 🌳 🔖 Tagger 🔖 App & Analysis Software The vision of this project is to assist forest officials for tree census by tagging each tree with pr

Sep 29, 2022

Flow is a water source location app that helps students of the University of Bamenda, Bambili to find/locate clean water sources.

Flow is a water source location app that helps students of the University of Bamenda, Bambili to find/locate clean water sources.

Flow is a water source location mobile app that helps students of the University of Bamenda, Cameroon to find/locate clean water sources.

Oct 21, 2022

Flutter Tutorial - Google Map with Live Location Tracking

 Flutter Tutorial - Google Map with Live Location Tracking

Flutter Tutorial - Google Map with Live Location Tracking Build Google Map app with Live Location Tracking in Flutter. ✌   App Preview Android Preview

Dec 22, 2022

A Flutter package which can be used to make polylines(route) from a source to a destination, and also handle a driver's realtime location (if any) on the map.

A Flutter package which can be used to make polylines(route) from a source to a destination, and also handle a driver's realtime location (if any) on the map.

GoogleMapsWidget For Flutter A widget for flutter developers to easily integrate google maps in their apps. It can be used to make polylines from a so

Nov 30, 2022

DinoRide allows you to book a trip and have dinosaurs deliver you to your desired location!

DinoRide allows you to book a trip and have dinosaurs deliver you to your desired location!

DinoRide 💡 Inspiration We wanted to reimagine a modern app in a prehistoric context. We thought a taxi service but with dinosaurs would have been fun

Jun 30, 2022

A mobile image uploader in which you can upload image to your personal gallery from either your camera or mobile gallery and it can detect your current geographic location and address using firebase firestore and storage.

Image Uploader In Flutter About It is an Image Uploader gallery which tracks your address from which you're uploading using Flutter and Image picker.

Dec 20, 2022

Android app created to monitor location, gyroscope readings, pedometer measurements, and acceleration in different directions.

Blue Locator A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if

Apr 6, 2022

A sophisticated weather app, works with your location or name of any place. Gives detailed summary of weather condition.

clima_app A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if thi

Sep 7, 2022

A flutter app that brings the weather according to the entered location name

A flutter app that brings the weather according to the entered location name

An application that brings the weather according to the entered location name and displays it dynamically on the screen. It also includes weekly forec

Oct 31, 2021
Owner
Frantic
Open Source developer
Frantic
RoadMovie is an application that allows people who are in Moscow to explore the filming locations of Moscow films.

RoadMovie is an application that allows people who are in Moscow to explore the filming locations of Moscow films. Motivation There are many film fans

null 16 Oct 13, 2022
A Flutter package which can be used to make polylines(route) from a source to a destination, and also handle a driver's realtime location (if any) on the map.

GoogleMapsWidget For Flutter A widget for flutter developers to easily integrate google maps in their apps. It can be used to make polylines from a so

Rithik Bhandari 14 Nov 30, 2022
Flutter Chat Application with location integration using GetStream

Chat Location Generated by the Very Good CLI ?? A chat application built with Flutter using the Stream Chat SDK. Check out the full tutorial. Getting

Very Good Ventures 77 Jan 4, 2023
An app to get you the latest and the trending news based on your location.

An app to get you the latest and the trending news based on your location.

Ayush Shekhar 19 Nov 11, 2022
Vineet Kalghatgi 32 May 13, 2022
A weather application that show the current weather for your location and forecast for 6 days, and favorite city and other locations

Weather Application App concept created with Flutter using Dart programming language ad it's a demanded task in my internship at Algoriza About An app

Mohamed Mohamedy 4 Nov 13, 2022
Flutter package to enable clustering of location markers on Google Maps using widgets specific to each location.

flutter_google_maps_widget_cluster_markers This widget implements a very specific adaptation of google_maps_cluster_manager, allowing different ,marke

Kek Tech 2 Jan 6, 2023
A flutter project that helps you visualise the sorting algorithms.

SortViz A flutter project that helps you visualise various sorting algorithms. Description A sorting visualizer that visualises different sorting algo

Mahima Goyal 3 Sep 7, 2021
Sorting Visualizer using Flutter followed MVVM Pattern and used Stacked Services. Hope you like it 😋

Sortlizer An App to visualize various sorting algorithms...Developed using Flutter, followed MVVM pattern, and used stacked services. Play Store Link

Roshan Kumar 17 Dec 28, 2022
Sorting algorithms visualizer in Flutter.

Sorting Algorithms Visualizer in Flutter Algorithms implemented Insertion Sort Selection Sort Bubble Sort Plugins used fl_chart To run this app run fl

Bibek Timsina 55 Aug 27, 2022