GithubHelp home page GithubHelp logo

leaflet.photon's Introduction

leaflet.photon

This is leaflet plugin for photon.

Sample Usage

Use the map options to create a Photon search control when the map is created:

function myHandler(geojson) {
    console.debug(geojson);
};

var map = L.map('map', {
  photonControl: true,
  photonControlOptions: {
      resultsHandler: myHandler,
      placeholder: 'Try me …',
      position: 'topleft'}
  }
);

Or create a control afterwards:

var searchControl = L.control.photon(photonControlOptions);
searchControl.addTo(map);

Options

  • url URL of the Photon API to use. Default: 'http://photon.komoot.de/api/?'
  • placeholder Placeholder of the search input. Default: "Start typing..."
  • noResultLabel Message to display when no result has been found. Default: "No result"
  • minChar Min char to be typed before actually searching (can be a function that takes the val as parameter and must return a boolean). Default: 3
  • limit Number of results max to return from API. Default: 5
  • submitDelay Min time buffer between to sent request, to avoid too much requests when typing fast (in milliseconds). Default: 300
  • includePosition Whether to include or not the map center as location bias for the search. Default: true
  • feedbackEmail Email to use as feedback link. Set to null to disable the feedback box. Default: "[email protected]"
  • feedbackLabel Message for feedback link. Default: "Feedback"
  • lang land code (en, it, fr…) to send to Photon API. Default: null
  • onSelected Action to run when user select a search result. Default: center map on selected result's latlng
  • formatResult Optional function to control the way geojson features are displayed in the results box.
  • formatType Optional function to control the way features types (amenity, school, etc.) are displayed in the default formatResult function.
  • resultsHandler Optional function that will be called when a geojson is retrieved from the API. You way want to use this to display points in the map for instance.

Events

  • focus sent on input focus
  • blur sent on input blur
  • hide sent on result box hide
  • selected sent on result select. Event: {choice: }
  • ajax:send sent when an ajax call is made
  • ajax:return sent when an ajax call is returned

leaflet.photon's People

Contributors

yohanboniface avatar christophlingg avatar julien-noblet avatar ivansanchez avatar

Watchers

James Cloos avatar Riccardo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.