@justbe-angular/jb-google-location-api
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Justbe Google Location Api

Wrapper for google api services for justbe

Installation

Use the node package manager npm to install @justbe-angular/jb-google-location-api.

npm install @justbe-angular/jb-google-location-api --save

Usage

import JBGoogleLocationApiModule into your root module/app.module

import { NgModule } from '@angular/core';
import { JBGoogleLocationApiModule } from '@justbe-angular/jb-google-location-api';
@NgModule({
    declarations: [
        ..
    ],
    imports: [
        ..,
        JBGoogleLocationApiModule,
        ..,
    ]
})
export class AppModule { }

configure JBGoogleLocationApiModule at entry point of your application

import { Component } from '@angular/core';
import { GoogleLocationApiService } from '@justbe-angular/jb-google-location-api';
@Component({
    templateUrl: 'root.component.html'
})
export class RootComponent {
    ..
    constructor(
        ..,
        private googleLocationApiService: GoogleLocationApiService,
        ..
    ){}
    this.googleLocationApiService.setConfigurations({
        GOOGLE_API_KEY: 'your api key'
    })
}

Search Places Around Your Location;

this method returns places arount you according to your search string it takes three argugments searchString Latitude Longitude and returns observable which resolve into list of places

import { GoogleLocationApiService } from '@justbe-angular/jb-google-location-api';
export class YourClass{
    constructor(
        ..,
        private googleLocationApiService: GoogleLocationApiService,
        ..,
    ){}
    searchPlaces(){
        this.googleLocationApiService.searchPlaces('janak baba', lat, lng).subscribe(res => {
            if (res.status === 'OK') {
                console.log(res.predictions);
            }
        })
    }
}

Geocode;

this method will return latitude longitude from location. it takes one argugment adreessString.

import { GoogleLocationApiService } from '@justbe-angular/jb-google-location-api';
export class YourClass{
    constructor(
        ..,
        private googleLocationApiService: GoogleLocationApiService,
        ..,
    ){}
    searchPlaces(){
        this.googleLocationApiService.geocode(locationString).subscribe(res => {
            if (res.status === 'OK') {
                console.log(res.results);
            }
        })
    }
}

Reverse Geocode;

this method will return location from latitude longitude. it takes two argugments Latitude Longitude.

import { GoogleLocationApiService } from '@justbe-angular/jb-google-location-api';
export class YourClass{
    constructor(
        ..,
        private googleLocationApiService: GoogleLocationApiService,
        ..,
    ){}
    searchPlaces(){
        this.googleLocationApiService.reverseGeocode(lat, lng).subscribe(res => {
            if (res.status === 'OK') {
                console.log(res.results);
            }
        })
    }
}

License

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    0
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i @justbe-angular/jb-google-location-api

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

17.4 kB

Total Files

18

Last publish

Collaborators

  • beyoutech