title: Angular 2 - Get the name of the current location using geolocation using TypeScript
body: <p>I am working on a project where I want to get my current location (<code>City Name</code>) using <code>Typescript</code>. I want to create a service which would do this for me. I have written the code below:</p>
  
  <pre><code>import { Injectable} from '@angular/core';
  import { Observable } from 'rxjs/Observable';
  import {Http} from '@angular/http';
  import 'rxjs/Rx';
  
  @Injectable()
  export class CurrentLocationService {
  
      constructor(private _http: Http) {}
  
      getCurrentLocation(): Observable&lt;any&gt; {
          return this._http.get('http://ipinfo.io/json?callback=JSON_CALLBACK')
          .map(response =&gt; response.json())
          .catch(error =&gt; {
              console.log(error);
              return Observable.throw(error.json());
          });
      }
  }
  </code></pre>
  
  <p>But, this <code>Service</code> returns the wrong values to me. When i execute <code>http://ipinfo.io/json?callback=JSON_CALLBACK</code> on the browser URL the values i get back are:</p>
  
  <pre><code>  "city": "Munich",
    "region": "Bavaria",
    "country": "DE",
  </code></pre>
  
  <p>which are true in my case, but the Service above would return as value <code>Connaught Place, IN</code> which are wrong.<br>
  Is there a more precise way to get the current location using a service in <code>Typescript</code>.</p>