All Projects → ng-web-apis → Geolocation

ng-web-apis / Geolocation

Licence: mit
An Observable based abstraction to use Geolocation API with Angular

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Geolocation

React Native Geolocation Service
React native geolocation service for iOS and android
Stars: ✭ 934 (+1294.03%)
Mutual labels:  geolocation
Ionic 3 Google Maps Google Places Geolocation
This repository is part of an ionic tutorial about Maps! In this tutorial we merged Google maps, Geolocation and Google Places. This ionic tutorial includes a working example you can reuse for your needs!
Stars: ✭ 32 (-52.24%)
Mutual labels:  geolocation
Geo On Fire
A library to create high performance geolocation queries for Firebase. Checkout the demos: https://run.plnkr.co/plunks/AYaN8ABEDcMntgbJyLVW/ and https://run.plnkr.co/plunks/xJgstAvXYcp0w7MbOOjm/
Stars: ✭ 54 (-19.4%)
Mutual labels:  geolocation
Locator Tool
Tool to add {{Location}} or {{Object location}} to images on Wikimedia Commons
Stars: ✭ 11 (-83.58%)
Mutual labels:  geolocation
Pelias Android Sdk
Android sdk for pelias
Stars: ✭ 20 (-70.15%)
Mutual labels:  geolocation
Utm
Bidirectional UTM-WGS84 converter for golang 🌍 🌐
Stars: ✭ 36 (-46.27%)
Mutual labels:  geolocation
Geomate
GeoMate is a friend in need for all things geolocation. IP to geo lookup, automatic redirects (based on country, continent, language, etc), site switcher... You name it.
Stars: ✭ 19 (-71.64%)
Mutual labels:  geolocation
Ipdata
🌐 An IP lookup system utilizing open datasets
Stars: ✭ 58 (-13.43%)
Mutual labels:  geolocation
Craft Coordinates
A twig filter for Craft CMS that gets the latitude and longitude from an address
Stars: ✭ 27 (-59.7%)
Mutual labels:  geolocation
Geojs
Geo-location lookup API
Stars: ✭ 45 (-32.84%)
Mutual labels:  geolocation
Rgeo
Geospatial data library for Ruby
Stars: ✭ 875 (+1205.97%)
Mutual labels:  geolocation
Nanogenmo 2015
Around the World in X Wikipedia Articles
Stars: ✭ 20 (-70.15%)
Mutual labels:  geolocation
Location Tracker Nodejs
Demo web application which records a device's location and saves this information to IBM Cloudant
Stars: ✭ 39 (-41.79%)
Mutual labels:  geolocation
Android
OwnTracks Android App
Stars: ✭ 840 (+1153.73%)
Mutual labels:  geolocation
Geoip2 Golang
Unofficial MaxMind GeoIP2 Reader for Go
Stars: ✭ 1,074 (+1502.99%)
Mutual labels:  geolocation
Geo From Ip
Get geolocation 🌐 information about an IP 📲
Stars: ✭ 24 (-64.18%)
Mutual labels:  geolocation
Vue World Map
A Vue JS component for displaying dynamic data on a world map.
Stars: ✭ 33 (-50.75%)
Mutual labels:  geolocation
React Native Learning Resources
Collection of some good resources for react-native ✨ 🔥 💥
Stars: ✭ 61 (-8.96%)
Mutual labels:  geolocation
Django Places
A django app for store places with autocomplete
Stars: ✭ 55 (-17.91%)
Mutual labels:  geolocation
Vue.js With Asp.net Core Sample
This provides a sample code using vue.js running on ASP.NET Core
Stars: ✭ 44 (-34.33%)
Mutual labels:  geolocation

ng-web-apis logo Geolocation API for Angular

Part of Web APIs for Angular

npm version npm bundle size Travis (.com) Coveralls github angular-open-source-starter

This is an Observable based abstraction over Geolocation API to use with Angular

Install

If you do not have @ng-web-apis/common:

npm i @ng-web-apis/common

Now install the package:

npm i @ng-web-apis/geolocation

How to use

GeolocationService

GeolocationService is an Observable, that emits Position object

Import service in your component:

import {GeolocationService} from '@ng-web-apis/geolocation';

...
constructor(private readonly geolocation$: GeolocationService) {}

Now, to observe user position, you can subscribe to geolocation$:

geolocation$.subscribe(position => doSomethingWithPosition(position));

If you need to get position just once and stop observing user location, you can subscribe to geolocation$ and use take(1) RxJs operator:

geolocation$.pipe(take(1)).subscribe(position => doSomethingWithPosition(position));

Or you can use async pipe to get position directly in template:

<div *ngIf="geolocation$ | async as position">
    <span>{{position.coords.latitude}}</span>
</div>

Service is cold, meaning if there are no active subscriptions, it doesn't track position.

Tokens

The library also provides some tokens to simplify working with Geolocation API:

  • GEOLOCATION_SUPPORT returns true if user's browser supports Geolocation API
export class YourComponent {
    constructor(
        @Inject(GEOLOCATION_SUPPORT) private readonly geolocationSupport: boolean
    ) {}
    ...
  • You can provide PositionOptions through POSITION_OPTIONS token with optional properties named enableHighAccuracy, timeout and maximumAge. It uses {} by default.
@NgModule({
    ...
  providers: [
        {
            provide: POSITION_OPTIONS,
            useValue: {enableHighAccuracy: true, timeout: 3000, maximumAge: 1000},
        },
    ],
})
export class AppModule {}

Browser support

IE / Edge
Firefox
Chrome
Safari
iOS Safari
9+ 3.5+ 5+ 5+ 3.2+

Demo

You can try online demo here

See also

Other Web APIs for Angular by @ng-web-apis

Open-source

Do you also want to open-source something, but hate the collateral work? Check out this Angular Open-source Library Starter we’ve created for our projects. It got you covered on continuous integration, pre-commit checks, linting, versioning + changelog, code coverage and all that jazz.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].