Skip to main content
100%

Gist fadcc73c7137e3e731b2dc5a98894add

✓ Published0🌍 Public
Aackuser
Last edited Jul 27, 2017
Created on Nov 26, 2017

This example demonstrates a geolocation service that retrieves the user’s current position and exposes it as an observable stream. The code uses Angular’s `@Injectable` decorator and RxJS `Observable.create` to wrap the browser’s `window.navigator.geolocation.getCurrentPosition` API, converting the raw `Coordinates` object (latitude, longitude, and accuracy) into a typed `Coordinates` model. It handles browser support and user rejection errors via a predefined error-message array, completing the observable after a successful position fix. The visualization focuses on the service logic rather than rendering, with no charting or drawing libraries involved.

AI-generated description

Similar vizzes