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

@openrunner/photon-geocoder

v1.2.6

Published

simple lib to integrate geocoding field in your app

Downloads

26

Readme

photon Geocoder

it's a simple library to let you integrate a geocoding input in your app.

building

install with : npm i @openrunner/photon-geocoder

build with : npm start

it will be builded in dist/ folder

how to use

include js and css in your page then create an instance with :

const test = new PhotonGeocoder({
        target: 'test',
      })
      test.on('select', (e) => {
        console.log('select : ', e.feature)
        console.log('select : ', e.latlng)
      })

options :

you can editor all or only some of thoses options :

  • url : the url of the backend
  • firstLineFields: the properties displayed in the result first line, separate by ', ' (unknown properties will be ignore)
  • secondLineFields: the feature properties displayed in the result second line, separate by ', ' (unknown properties will be ignore)
  • inputDisplayFields: the feature properties to use in displaying the selected feature in the input, separate by ', ' (unknown properties will be ignore)
  • textStrings: the text that the lib will display for some case (cf below for list)
  • rateLimit: time between query in ms
  • resultsHeightMargin: use for defining result block height
  • minimumInputLengthForAutocomplete: the minimum number of letter before querying the backend
  • bounds:
  • layers: not fonctionnal,
  • place: not fonctionnal,
  • limit: the number of result return by the backend
  • lang: the lang used by the backend
  • osm_tag: openStreetMap tag to filter the query result
  • target: the parent where the input will be added
  • value: use to set initial value of input
  • pointIcon: the icon class to use for the result of type venue or address
  • polygonIcon: the icon class to use for the other type of result
  • closeIcon: the icon class to use for the reset action
  • searchIcon: the icon class to use for the prepend icon will be replace with the loading icon when query the backend
  • loadIcon: the icon class to use for the loading animation (css animation)
  • allowGPSCoordinates: specify if the component must be compliant with GPS coordinates. If so the component will make GPS coordinates selectable

strings traduction :

you can passe to the library the different strings that will be used by editing the options textStrings that default to :

const TEXT_STRINGS = {
  'INPUT_PLACEHOLDER': 'Search',
  'INPUT_TITLE_ATTRIBUTE': 'Search',
  'RESET_TITLE_ATTRIBUTE': 'Reset',
  'NO_RESULTS': 'No results were found.',
  // Error codes.
  'ERROR_403': 'A valid API key is needed for this search feature.',
  'ERROR_404': 'The search service cannot be found. :-(',
  'ERROR_408': 'The search service took too long to respond. Try again in a second.',
  'ERROR_429': 'There were too many requests. Try again in a second.',
  'ERROR_500': 'The search service is not working right now. Please try again later.',
  'ERROR_502': 'Connection lost. Please try again later.',
  // Unhandled error code
  'ERROR_DEFAULT': 'The search service is having problems :-('
};

you can just edit one string or all, the missing strings will use the default value

events :

you can listen to multiple events, attaching listener to the object with

test.on('eventName', listener)

here is a list of available events and the parameters they have :

emit('results', {
    results: results,
    endpoint: endpoint,
    requestType: type,
    params: params
})
emit('select', {
    originalEvent: originalEvent,
    latlng: latlng,
    feature: feature
})
emit('reset')
emit('error', {
    results: results,
    endpoint: endpoint,
    requestType: type,
    params: params,
    errorCode: err.code,
    errorMessage: errorMessage
})
emit('highlight', {
    originalEvent: e,
    latlng: getFeatureLatLng(highlighted.feature),
    feature: highlighted.feature
})
emit('focus', { 
    originalEvent: e 
})
emit('blur', { 
    originalEvent: e 
})
emit('expand')
emit('collapse')

css

simplified css class for ease of used.

all classes are prefixed with photon-