Skip to content
This repository has been archived by the owner on May 7, 2023. It is now read-only.

synw/geopoint_location

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Geopoint location

pub package

Get Geopoint data from Geolocator Position updates

Simple position

import 'package:geopoint/geopoint.dart';
import 'package:geopoint_location/geopoint_location.dart';

GeoPoint geoPoint = await geoPointFromLocation(
   name: "Current position", withAddress: true);

Positions stream

import 'package:geopoint/geopoint.dart';
import 'package:geopoint_location/geopoint_location.dart';

StreamSubscription<GeoPoint> _sub;
final _loc = LocationStream().initGeoPointStream();
_sub = _loc.geoPointStream.listen((pos) => print("Position update $pos"));
//_sub.cancel();

Convert a geolocator Position to a GeoPoint

import 'package:geopoint/geopoint.dart';
import 'package:geopoint_location/geopoint_location.dart';

final position = await Geolocator().getCurrentPosition();
final GeoPoint geoPoint = await geoPointFromPosition(
   position: position,
   name: "Current position");

Same but sync, address not available:

final GeoPoint geoPoint = geoPointFromPositionSync(
   position: position,
   name: "Current position");