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

@mralexandernickel/location-search

v0.8.7

Published

Pull this Repository and run this command from your terminal (after you cd'ed into your project)

Downloads

2

Readme

Extendable Location-Search

An Angular Directive to easily generate location-search. The complete Application is working inside the Client (including distance-calculation).

If you enter something inside the searchform, the application will first loop through the given data. If there are no matches, we try to geocode the given searchterm using Google maps Geocoder, and then search for entries in data nearby the geocoded searchterm. This way we are able to show entries near "La Tour Eifel", or even "eifleturm" (Yes...the typo is wanted).

Install

The easiest way is to install via bower:

bower install nickel.locationSearch

How to use

Load Google-Maps APIv3 and this Module inside your DOM, set this Module as dependency in your AngularJS-App, and you're ready to go.

Data

Just give an array with objects containing latitude and longitude and optional fields you want to search for. Could for example look like

[
  {
    "latitude": 49.000012,
    "longitude": 8.12323524,
    "name": "Example Name",
    "services": [
      "Autoreparatur",
      "Audio Tuning"
    ],
    "anything": "as dasd asd asd asd ad asd as dasd ad"
  },
  ...
]

Customize

The directive is easily customizable, you create an own angular directive that just needs to require this locationSearch-directive.

Behaviour

You can easily extend or change the behaviour of the directive, by simply overwriting methods of the controller. To make our methods accessible from the view, we are referencing the controller-methods to the $scope inside our link-function.

An example with just another getData-method using hardcoded locations could look like this:

ExtendedLocationsearch = function() {
  restrict: "E",
  priority: 1,
  require: "locationSearch",
  link: function($scope, elem, attr, ctrl) {
    ctrl.getData = function() {
      $scope.places = []
      $scope.updateMap()
    }
  }
}

angular
  .module("demo", ["nickel.locationSearch"])
  .directive("extendedLocationsearch", ExtendedLocationsearch)

If you have done this, you would use your new directive inside the view like this:

<extended-locationsearch
  field-name="name"
  field-street="address"
  field-zip="zip"
  field-city="city"
  fallback-center="Eifelturm"
  map-style="style3"
  max-results="5"
  initial-filters="name zip address city">
</extended-locationsearch>

Markup

If you would like to change the markup of the directive, you just need to overwrite the directives controller's getTemplate-method. The only thing you really need is a container with a fixed id for the google-map itself, the id needs to be gmapSearchContainer. A really minimal template with just the map and a searchform to filter the results could look like this:

ExtendedLocationsearch = function() {
  restrict: "E",
  priority: 1,
  require: "locationSearch",
  link: function($scope, elem, attr, ctrl) {
    ctrl.getTemplate = function() {
      return \`
        <input
          type="text"
          ng-model="search"
          ng-model-options="{debounce: 700}"
          ng-change="filterPlaces()"
          placeholder="Search">
        <div
          id="gmapSearchContainer"
          style="height:600;width:600;"></div>
        \`;
    }
  }
}

angular
  .module("demo", ["nickel.locationSearch"])
  .directive("extendedLocationsearch", ExtendedLocationsearch)

Map Styling

It is also possible to change the Style of the google-map itself. To use this feature you just need to add a window.gmapStyles object before you boot your angular-app (or just set it before you include angular.js), and register your templates there.

window.gmapStyles = {
  "yourGreatMapStyle": [
    {
      'featureType': 'water'
      'elementType': 'geometry'
      'stylers': [
        { 'color': '#e9e9e9' }
        { 'lightness': 17 }
      ]
    }
  ]
}

You can then use the keys you used, inside the map-styles attribute of your html-element.

<location-search
  field-name="name"
  field-street="address"
  field-zip="zip"
  field-city="city"
  fallback-center="Eifelturm"
  map-style="yourGreatMapStyle"
  max-results="5"
  initial-filters="name zip address city">
</location-search>

There is a great web-application with predefined google-map styles you could use, called snazzymaps.