Polyline encoding algorithm for encoding and decoding a list of coordinates

Related tags

Map dart_polyline_do
Overview

Polyline_do

Mapbox supported

Polyline encoding is a lossy compression algorithm that allows you to store a series of coordinates as a single string.

Polyline is a dart port of Google's Polyline Algorithm explained here. Inspired by Mapbox's polyline.js. Compatible with Dart 2.

Usage

A simple usage example:

Two named constructors are provided Polyline.Decode and Polyline.Encode.

Calling Polyline.Encode will compute the encodedString and set the passed in coordinates to decodedCoords on the instance of Polyline so that each instance of Polyline has access to the correct encoded string and subsequent decoded coordinates. Likewise, calling Polyline.Decode computes the list of coordinates from the encoded string and sets the passed in encoded string to the instance of Polyline.

Note that a precision of 6 is standard.

import 'package:polyline_do/polyline_do.dart';

import 'package:polyline_do/polyline_do.dart';

void main() {
  Polyline polyline;

  /// List
   
    
      coordinates;
  const coordinates = [
    [33.80119, -84.34788],
    [35.10566, -80.8762],
    [30.4526, -81.71116],
    [28.57888, -81.2717]
  ];
  const precision = 5;
  const encoded = 'mxhmEfeyaO}w}F_aeTrxk[nabDv}lJsytA';

  // Encode a list of coordinates with precision 5 to produce the encoded string
  polyline = Polyline.Encode(decodedCoords: coordinates, precision: 5);
  print('Encoded String: ${polyline.encodedString}, Coords: ${polyline.decodedCoords}');

  // Decode an encoded string to a list of coordinates
  polyline = Polyline.Decode(encodedString: encoded, precision: precision);
  print('Decoded Coords: ${polyline.decodedCoords}');
  print('String: ${polyline.encodedString}');

  // Calculate the distance of an encoded polyline, and decode the polyline
  polyline =  Polyline.Distance(encodedString: encoded,  unit: 'kilometers');
  // By calling  length the encodedString, decodedCoords, and distance variables
  // of the Polyline class are available
  print('Distance: ${polyline.distance!.floor()}km , Encoded String: ${polyline.encodedString} Decoded Coords: ${polyline.decodedCoords}');

}


    
   
You might also like...

Android and iOS Geolocation plugin for Flutter

Flutter geolocator plugin The Flutter geolocator plugin is build following the federated plugin architecture. A detailed explanation of the federated

Nov 14, 2021

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 a location on Android and iOS. It also provides callbacks when the location is changed

Dec 22, 2022

Localizator is a flutter application that provides your current/given position,and gives you weather Forecasts

Localizator is a flutter application that provides your current/given position,and gives you weather Forecasts

Locativity Locativity is a flutter application implements flutter_map and Geolocator plugins to provide your current/given position then render it on

Nov 6, 2022

A Flutter package for place search using MapBox Api and for Static map image

A Flutter package for place search using MapBox Api and for Static map image

About This package provides easy api calls to MapBox Search API. Also, it contains an static map image generator πŸ˜† . Maki Icons can be used now in ma

Dec 2, 2022

A map tour guide mobile app based on Flutter, an AI travel notes product integrating map tour guide and UGC.

A map tour guide mobile app based on Flutter, an AI travel notes product integrating map tour guide and UGC.

A map tour guide mobile app based on Flutter, an AI travel notes product integrating map tour guide and UGC. Through the combination of 5g + AI, colle

Jan 14, 2022

Get the dialing codes and the name of 250 countries for flutter

This package allows you to get the dialing codes and the name of 250 countries. Features This package contains all dialing codes of the 250 countries.

Feb 28, 2022

A car rental flutter application using firebase and google maps API

A car rental flutter application using firebase and google maps API

A car sharing & rental app using Flutter, Firebase & Google Maps APIs πŸ”₯ About the App 🚘 hopOn is flutter based application for car sharing and renta

Dec 30, 2022

πŸ‘‡ Easy Google Photos style multi-selection for RecyclerViews, powered by Kotlin and AndroidX.

πŸ‘‡ Easy Google Photos style multi-selection for RecyclerViews, powered by Kotlin and AndroidX.

Drag Select Recycler View This library allows you to implement Google Photos style multi-selection in your apps! You start by long pressing an item in

Jan 8, 2023

A Flutter example to use Google Maps in iOS and Android apps via the embedded Google Maps plugin Google Maps Plugin

A Flutter example to use Google Maps in iOS and Android apps via the embedded Google Maps plugin Google Maps Plugin

maps_demo A Flutter example to use Google Maps in iOS and Android apps via the embedded Google Maps plugin Google Maps Plugin Getting Started Get an A

Feb 14, 2022
Releases(v0.1.0)
Owner
Fernando
Un simple desarrollador :)
Fernando
A Flutter package for iOS and Android for picking location and images.

location and image picker package for Flutter A Flutter package for iOS and Android for picking location and images. Demo Installation First, add loca

sk shamimul islam 9 Sep 28, 2022
Interactive, thoroughly customizable maps in native Android, iOS, macOS, Node.js, and Qt applications, powered by vector tiles and OpenGL

Mapbox GL Native A C++ library that powers customizable vector maps in native applications on multiple platforms by taking stylesheets that conform to

Mapbox 4.2k Jan 6, 2023
Dart API that provides sunset and sunrise times for a given latitude and longitude

Sunrise Sunset Dart API that provides sunset and sunrise times for a given latit

Asjad 0 Dec 24, 2021
flutter_map plugin to request and display the users location and heading on the map

The plugin is discontinued. Feel free to fork it or checkout similar plugins. Flutter Map – Location plugin A flutter_map plugin to request and displa

Fabian Rosenthal 19 Oct 11, 2022
Flutter plugin for forward and reverse geocoding

geocoder Forward and reverse geocoding. Usage Import package:geocoder/geocoder.dart, and use the Geocoder.local to access geocoding services provided

AloΓ―s Deniel 177 Dec 31, 2022
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

Westdale Software Dev Club 1 Jun 30, 2022
Aplications with google maps and geolocation

Aplications with google maps and geolocation

Richardson Tsavo 4 Jul 26, 2022
Flutter geolocation plugin for Android and iOS.

geolocation Flutter geolocation plugin for Android API 16+ and iOS 9+. Features: Manual and automatic location permission management Current one-shot

Loup 222 Jan 2, 2023
This is a Flutter package that uses the Google Maps API to make a TextField that tries to autocomplete places as the user types, with simple smooth animations, making a nice UI and UX.

search_map_place This is a Flutter package that uses the Google Maps API to make a TextField that tries to autocomplete places as the user types, with

Lucas Bernardi 127 Oct 22, 2022
Android and iOS Geolocation plugin for Flutter

Flutter geolocator plugin The Flutter geolocator plugin is build following the federated plugin architecture. A detailed explanation of the federated

Baseflow 1k Jan 5, 2023