npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-ez-maps

v0.3.0

Published

A relatively easy to use google maps

Downloads

10

Readme

RxJS Powered Google Maps for Angular

A relatively easy to use google maps

Installation

$ npm install ngx-ez-maps --save

Work in progress

This library is under heavy development and has only basic GoogleMap's functionality, feel free to contribute :)

To do list

Basic Usage

This basic app instantiates the google maps ( centered on Manila, Philippines in this case :) ) with a marker and an InfoWindow. When the marker is clicked, set the animation to BOUNCE and when you click anywhere on the Map, Animation on the Marker will be removed

Import EzMapModule to your root module:

...
@NgModule(
    ...,
    imports: [
        EzMapModule.forRoot({
            apiKey: "API_KEY_HERE",
            libraries?: [
                'lib1',
                'lib2'
            ]
        })
    ]
    ...
)

For FeatureModule, just import without the .forRoot static method call.

...on your component:

...
import { EzMap, EzMarker, EzInfoWindow }
@Component({
    selector: "app-root"
})
export class AppComponent implements OnInit {
    selectedMarker: EzMarker;

    pos = {
        longitude: 121.1924108,
        latitude: 14.5964957
    }

    onMapReady(map: EzMap) {
        // do something with the map instance :D
    }

    // Marker click returns an instance of EzMarker
    onMarkerClicked(marker: EzMarker){
        this.selectedMarker = marker;
        this.selectedMarker.setAnimation('BOUNCE');
    }

    
    onMapClicked(){
        this.selectedMarker.setAnimation(null);
    }

}
<ez-map
    [latitude]="pos.latitude"
    [longitude]="pos.longitude"
    [zoom]="12"
    [gestureHandling]="'greedy'"
    [streetViewControl]="false"
    [zoomControl]="false"
    (mapReady)="onMapReady($event)"
    (mapClicked)="onMapClicked($event)"
    #map>

    <ez-marker
        [longitude]="pos.longitude"
        [latitude]="pos.latitude"
        (markerClicked)="onMarkerClicked($event)">

        <ez-info-window
            [isOpen]="true"
            [closeOnMapClicked]="false"
            [closeWhenOthersOpened]="false">

            <!-- Required, put your templates inside #infoWindow Template Ref -->
            <div #infoWindow>
                You are here!
            </div>

        </ez-info-window>

    </ez-marker>

</ez-map>

LocationService

EzMaps is shipped with helper libraries like LocationService

LocationService encapsulates navigator.geolocation's methods with RxJS (because we all love observables)

Methods

  • getCurrentLocation
  • watchPosition

Usage

Just provide the service:


@NgModule({
    ...
    ...
    providers: [LocationService]
})
export class CoreModule {}

And on your component you'll do, for example, you want to get the current location:


@Component(...)
export class AppComponent {
    constructor(private _locationService: LocationService) {}

    ngOnInit(){
        // getCurrentLocation returns a Position object. https://developer.mozilla.org/en-US/docs/Web/API/Position
        this._locationService.getCurrentLocation()
            .subscribe((pos: Position) => {
                // do something cool with the output
            })
    }
}

PlacesService

PlacesService encapsulates GoogleMaps' Places Library.

Methods

  • nearbySearch
  • textSearch
  • getDetails

For more information about the parameters for these methods, check out the awesome GoogleMaps docs

Start by providing the service:

Usage


@NgModule({
    ...
    ...
    providers: [PlacesService]
})
export class CoreModule {}

Use its methods within onMapReady only because each method within the PlacesService would need map instance


@Component({
    ...
    template: `
        <ez-map (mapReady)="onMapReady($event)"></ez-map>
    `
})
export class AppComponent {

    pos = {
        lng: 121.1924108,
        lat: 14.5964957
    };

    constructor(private _placesService: PlacesService) {}

    onMapReady(map: google.maps.Map){

        this._places.nearbySearch(map, {
            keyword: "store",
            radius: 5000,
            location: this.pos
        }).subscribe((data) => {
            // do something with the data
        });

    }
}