Code Monkey home page Code Monkey logo

leaflet-plugin's Introduction

A modular, open-source search engine for our world.

Pelias is a geocoder powered completely by open data, available freely to everyone.

Local Installation · Cloud Webservice · Documentation · Community Chat

What is Pelias?
Pelias is a search engine for places worldwide, powered by open data. It turns addresses and place names into geographic coordinates, and turns geographic coordinates into places and addresses. With Pelias, you’re able to turn your users’ place searches into actionable geodata and transform your geodata into real places.

We think open data, open source, and open strategy win over proprietary solutions at any part of the stack and we want to ensure the services we offer are in line with that vision. We believe that an open geocoder improves over the long-term only if the community can incorporate truly representative local knowledge.

Pelias

A modular, open-source geocoder built on top of Elasticsearch for fast and accurate global search.

What's a geocoder do anyway?

Geocoding is the process of taking input text, such as an address or the name of a place, and returning a latitude/longitude location on the Earth's surface for that place.

geocode

... and a reverse geocoder, what's that?

Reverse geocoding is the opposite: returning a list of places near a given latitude/longitude point.

reverse

What are the most interesting features of Pelias?

  • Completely open-source and MIT licensed
  • A powerful data import architecture: Pelias supports many open-data projects out of the box but also works great with private data
  • Support for searching and displaying results in many languages
  • Fast and accurate autocomplete for user-facing geocoding
  • Support for many result types: addresses, venues, cities, countries, and more
  • Modular design, so you don't need to be an expert in everything to make changes
  • Easy installation with minimal external dependencies

What are the main goals of the Pelias project?

  • Provide accurate search results
  • Work equally well for a small city and the entire planet
  • Be highly configurable, so different use cases can be handled easily and efficiently
  • Provide a friendly, welcoming, helpful community that takes input from people all over the world

Where did Pelias come from?

Pelias was created in 2014 as an early project at Mapzen. After Mapzen's shutdown in 2017, Pelias is now part of the Linux Foundation.

How does it work?

Magic! (Just kidding) Like any geocoder, Pelias combines full text search techniques with knowledge of geography to quickly search over many millions of records, each representing some sort of location on Earth.

The Pelias architecture has three main components and several smaller pieces.

A diagram of the Pelias architecture.

Data importers

The importers filter, normalize, and ingest geographic datasets into the Pelias database. Currently there are six officially supported importers:

We are always discussing supporting additional datasets. Pelias users can also write their own importers, for example to import proprietary data into your own instance of Pelias.

Database

The underlying datastore that does most of the query heavy-lifting and powers our search results. We use Elasticsearch. Currently versions 7 and 8 are supported.

We've built a tool called pelias-schema that sets up Elasticsearch indices properly for Pelias.

Frontend services

This is where the actual geocoding process happens, and includes the components that users interact with when performing geocoding queries. The services are:

  • API: The API service defines the Pelias API, and talks to Elasticsearch or other services as needed to perform queries.
  • Placeholder: A service built specifically to capture the relationship between administrative areas (a catch-all term meaning anything like a city, state, country, etc). Elasticsearch does not handle relational data very well, so we built Placeholder specifically to manage this piece.
  • PIP: For reverse geocoding, it's important to be able to perform point-in-polygon(PIP) calculations quickly. The PIP service is is very good at quickly determining which admin area polygons a given point lies in.
  • Libpostal: Pelias uses the libpostal project for parsing addresses using the power of machine learning. We use a Go service built by the Who's on First team to make this happen quickly and efficiently.
  • Interpolation: This service knows all about addresses and streets. With that knowledge, it is able to supplement the known addresses that are stored directly in Elasticsearch and return fairly accurate estimated address results for many more queries than would otherwise be possible.

Dependencies

These are software projects that are not used directly but are used by other components of Pelias.

There are lots of these, but here are some important ones:

  • model: provide a single library for creating documents that fit the Pelias Elasticsearch schema. This is a core component of our flexible importer architecture
  • wof-admin-lookup: A library for performing administrative lookup using point-in-polygon math. Previously included in each of the importers but now only used by the PIP service.
  • query: This is where most of our actual Elasticsearch query generation happens.
  • config: Pelias is very configurable, and all of it is driven from a single JSON file which we call pelias.json. This package provides a library for reading, validating, and working with this configuration. It is used by almost every other Pelias component
  • dbclient: A Node.js stream library for quickly and efficiently importing records into Elasticsearch

Helpful tools

Finally, while not part of Pelias proper, we have built several useful tools for working with and testing Pelias

Notable examples include:

  • acceptance-tests: A Node.js command line tool for testing a full planet build of Pelias and ensuring everything works. Familiarity with this tool is very important for ensuring Pelias is working. It supports all Pelias features and has special facilities for testing autocomplete queries.
  • compare: A web-based tool for comparing different instances of Pelias (for example a production and staging environment). We have a reference instance at pelias.github.io/compare/
  • dashboard: Another web-based tool for providing statistics about the contents of a Pelias Elasticsearch index such as import speed, number of total records, and a breakdown of records of various types.

Documentation

The main documentation lives in the pelias/documentation repository.

Additionally, the README file in each of the component repositories listed above provides more detail on that piece.

Here's an example API response for a reverse geocoding query
$ curl -s "search.mapzen.com/v1/reverse?size=1&point.lat=40.74358294846026&point.lon=-73.99047374725342&api_key={YOUR_API_KEY}" | json
{
    "geocoding": {
        "attribution": "https://search.mapzen.com/v1/attribution",
        "engine": {
            "author": "Mapzen",
            "name": "Pelias",
            "version": "1.0"
        },
        "query": {
            "boundary.circle.lat": 40.74358294846026,
            "boundary.circle.lon": -73.99047374725342,
            "boundary.circle.radius": 500,
            "point.lat": 40.74358294846026,
            "point.lon": -73.99047374725342,
            "private": false,
            "querySize": 1,
            "size": 1
        },
        "timestamp": 1460736907438,
        "version": "0.1"
    },
    "type": "FeatureCollection",
    "features": [
        {
            "geometry": {
                "coordinates": [
                    -73.99051,
                    40.74361
                ],
                "type": "Point"
            },
            "properties": {
                "borough": "Manhattan",
                "borough_gid": "whosonfirst:borough:421205771",
                "confidence": 0.9,
                "country": "United States",
                "country_a": "USA",
                "country_gid": "whosonfirst:country:85633793",
                "county": "New York County",
                "county_gid": "whosonfirst:county:102081863",
                "distance": 0.004,
                "gid": "geonames:venue:9851011",
                "id": "9851011",
                "label": "Arlington, Manhattan, NY, USA",
                "layer": "venue",
                "locality": "New York",
                "locality_gid": "whosonfirst:locality:85977539",
                "name": "Arlington",
                "neighbourhood": "Flatiron District",
                "neighbourhood_gid": "whosonfirst:neighbourhood:85869245",
                "region": "New York",
                "region_a": "NY",
                "region_gid": "whosonfirst:region:85688543",
                "source": "geonames"
            },
            "type": "Feature"
        }
    ],
    "bbox": [
        -73.99051,
        40.74361,
        -73.99051,
        40.74361
    ]
}

How can I install my own instance of Pelias?

To try out Pelias quickly, use our Docker setup. It uses Docker and docker-compose to allow you to quickly set up a Pelias instance for a small area (by default Portland, Oregon) in under 30 minutes.

Do you offer a free geocoding API?

You can sign up for a trial API key at Geocode Earth. A commercial service has been operated by the core development team behind Pelias since 2014 (previously at search.mapzen.com). Discounts and free plans are available for free and open-source software projects.

What's it built with?

Pelias itself (the import pipelines and API) is written in Node.js, which makes it highly accessible for other developers and performant under heavy I/O. It aims to be modular and is distributed across a number of Node packages, each with its own repository under the Pelias GitHub organization.

For a select few components that have performance requirements that Node.js cannot meet, we prefer to write things in Go. A good example of this is the pbf2json tool that quickly converts OSM PBF files to JSON for our OSM importer.

Elasticsearch is our datastore of choice because of its unparalleled full text search functionality, scalability, and sufficiently robust geospatial support.

Contributing

Gitter

We built Pelias as an open source project not just because we believe that users should be able to view and play with the source code of tools they use, but to get the community involved in the project itself.

Especially with a geocoder with global coverage, it's just not possible for a small team to do it alone. We need you.

Anything that we can do to make contributing easier, we want to know about. Feel free to reach out to us via Github, Gitter, email, or Twitter. We'd love to help people get started working on Pelias, especially if you're new to open source or programming in general.

We have a list of Good First Issues for new contributors.

Both this meta-repo and the API service repo are worth looking at, as they're where most issues live. We also welcome reporting issues or suggesting improvements to our documentation.

The current Pelias team can be found on Github as missinglink and orangejulius.

Members emeritus include:

leaflet-plugin's People

Contributors

alculquicondor avatar bcamper avatar bdon avatar dianashk avatar easherma avatar hanbyul-here avatar hkrishna avatar iandees avatar joaomosmann avatar louh avatar missinglink avatar nvkelso avatar orangejulius avatar peterdavehello avatar riordan avatar rmglennon avatar skorasaurus avatar tayllan avatar wocoburguesa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

leaflet-plugin's Issues

Support real-world cases when image folder may not be in the same directory as the project page

For instance, in line 265 the plugin dynamically creates a close icon assuming that the image file is in a relative path from the page. This is probably the most egregious example; in lines 17-18 the same assumption is made, although these can be overridden easily by the developer. In many real-world use cases you can't expect that to be true and so we might not want to force the developer to dig through (and then edit) our code to figure out why images are broken.

For the non-customizable icons it may be best to use CSS. We have the same problem about relative images from CSS; I would recommend a build process that takes source images and converts them to data-URI so that the result is extremely portable. Developers who want to override these can do so in CSS but on their own terms, but in meantime when someone is testing the plugin for the first time the experience is not broken.

For customizable icons, we can use CSS defaults, overridden in JS when someone provides an icon to override with. (They can also override in CSS, same as other UI images, if they choose.)

[Browser Compatibility] Selecting a search result sets Search Box text to Undefined

While using Firefox Desktop, searching for a place then selecting it changes the content of the search field to "undefined". It is supposed to put the name of the selected place into the search box.

pelias-leaflet-firefox-undefined

To Reproduce:

  • Use Firefox Desktop (untested in mobile at this point)
  • Search for a place using typeahead search
  • Explicitly select a result either by using keyboard navigation (which is a nice add) or clicking the result with a mouse

Verified Does Not Occur in:

  • iOS MobileSafari
  • MacOS Safari
  • Chrome Desktop MacOS

Documentation!

Needs broad documentation plus several examples

  • Map + search in a button
  • Map + search in an expanded searchbox
  • Configuring a fullpage map to work at particular breakpoints for an expanded searchbox

Desktop UX

Closed state

[Customizable- can be defaulted to open or closed search box]

pelias_leaflet_flow1 1

Click state

  1. Box slides open [customizable- opens right or left]
  2. Search icon changes color
  3. Placeholder/Helper text [customizable]

pelias_leaflet_flow1 2

User starts typing

  1. Drop down appears with x auto-complete results
  2. 'x' (cancel) button appears as soon as the first letter is typed.
  3. Embolden the letters in the results that are part of the user input
  4. A 'pin' icon appears for points (poi's, addresses) and a 'globe' icon appears for polygons (cities, neighborhoods) [customizable icons]

pelias_leaflet_flow1 3

Browsing results

  1. Browsing with mouse hover or arrow keys, as user views results one by one, fades the map to that result [customizable?]
  2. Selected result gets a background color highlight and the icon also changes color [customizable- background color and icons]
  3. Results that are points get a pin on the map with a tooltip (tooltip can be closed by clicking the 'x')
  4. Results that are polygons just zoom that map to include the polygon in the viewport and no pin is dropped (nice to have- label for the polygon is highlighted)

pelias_leaflet_flow1 4

Panning the map/ Pressing enter or return on a result

  1. Panning the map with a highlighted result, collapses the dropdown under the search box and populates the search box with the result highlighted/selected

pelias_leaflet_flow1 5

Clearing results

  1. Clicking the 'x' in the search box, it clears the text in the box and the pins on the map (if any)
    pelias_leaflet_flow1 4a
  2. (Future) Show recently search results in the dropdown when user first clicks in the search box or clears the search box
    pelias_leaflet_flow1 5a

Deal with errors better

Most commonly 429s (when you hit the API limit) but also in case of server failure, wrong server endpoint setting, etc

Reintroduce zoom buttons for desktop?

I know we had decided to simplify the mobile UX (#7) during out last discussion by removing the zoom buttons while keeping the search bar visible at all times (by default, with the option to re-enable still in the codebase).

That said, I don't remember if we were going to also remove the zoom buttons for the desktop.

pelias_demo

Right now, the user can zoom into a target by clicking, allowing them to increase zoom levels, but they are left without the ability to zoom out.

What do we think about reintroducing the zoom buttons when it's on desktop mode?

deleting all input quickly results in empty dropdown rendered

when rapidly deleting the input I experience a dropdown rendered with no labels, this does not happen when deleting more slowly.

deleting slowly:
1

deleting quickly:
1

$ grep src example.html

    <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.5/leaflet.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-hash/0.2.1/leaflet-hash.min.js"></script>
    <script src="https://mapzen.com/tangram/tangram.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-geocoder-mapzen/1.4.1/leaflet-geocoder-mapzen.js"></script>

Verify browser compatability w/ Leaflet Core

Leaflet supports

  • Chrome
  • Firefox
  • Safari 5+
  • Opera 12+
  • IE 7-11

We've got to go back and check all of them.

  • Chrome
  • Firefox
  • Safari
    • Safari 5
    • Safari 6
    • Safari 7
    • Safari 8
  • Internet Explorer
    • IE 7
    • IE 8
    • IE 9
    • IE 10
    • IE 11

Overlapping of two geocoder

Hi!
I have added two different geocoders in the same map (I need them to create a travel planner, from point A - the first geocoder - to point B - the second geocoder).
They are one below the other.

The problem is that the list of results that appears below the first geocoder is hidden by the second geocoder. Is there a way to create a sort of order like layers?

Autocomplete results should filter by layer.

Currently, the layers option for the geocoder doesn't affect autocomplete queries:

NOTE: layers is not available for the autocomplete query.

This provides a really strange experience because neither the application developer nor the end user expects results that are not in the layers that are set. However, the autocomplete endpoint does not do layer filtering because it slows down the cache.

Since layers is just sugar for the actual search parameter, and the autocomplete response also includes layers in the feature collection for results, what if we were to filter autocomplete responses on the client-side before rendering the results to UI (or sending to events, etc.)?

Feature Request: zoom on select result

An option - integer - corresponding to Leaflets zoom levels. Allows user to set a default zoom level when selecting a geocoding result.

Use Case: When a user is zoomed out to the state level, but searches for a small town within the state. (In this case, simply panning to the result does not bring the user to a useful map extent).

Non-obvious navigation between matches for mobile

In the current design, a user is left to figure it out for herself that she may tap the search bar again to return to her result list. We can do more to make this more obvious.

pelias-leaflet-mobile-confuzzling

But perhaps not yet... We'll revisit.

Support custom result marker popups via callback

It should be easy to customize the marker popup content by passing a function to the Geocoder options that takes a Pelias result as an argument and returns an html string or DOM element to be used as the marker popup.

L.control.geocoder( <api_key>, {
    ...
    markersPopup: function( result ) {
        // Create popup content here
        return result.properties.label;
    }
    ...
});

Displaying point and polygon results

  • points get a pin on the map with a tooltip (tooltip can be closed by clicking the 'x')
  • polygons just zoom that map to include the polygon in the viewport with a highlighted boundary and no pin is dropped (nice to have- label for the polygon is highlighted)

UX: Browsing auto complete results

(Could be an option to customize)
As user scrolls through the auto-complete results (without pressing enter), center the map (maybe drop a pin) for each result

Rename/clarify terminology

Lots of colloquial terms

  • drop pin
    -pan to point
  • full_width
  • expanded
  • hide_other_controls

How might we make these (and other) terms clearer?

Styles should match Leaflet default styles.

Including icons, relative sizing, drop shadows, and mobile styling. A basic out of the box implementation of the plugin on vanilla Leaflet should appear as if it were part of Leaflet itself.

If we want to improve on any of the Leaflet defaults and add Mapzen-opinionated UI/ UX on top of it, that should be added as a progressively enhanced demo implementation, not part of plugin core behavior.

Mobile UX

Closed state

[Customizable- can be defaulted to open or closed search box]

pelias_leaflet_flow-m1 1

pelias_leaflet_flow-m1 1a

Tap state/ Active state

  1. Keyboard slides up with cursor in the box
  2. Search icon changes color
  3. Placeholder/Helper text [customizable]
  4. Deactivate and dim the map background

pelias_leaflet_flow-m1 2

(Future) Show recently search results in the dropdown when user taps and activates search or clears the search box

pelias_leaflet_flow-m1 2a

User starts typing

  1. Drop down appears with x auto-complete results
  2. 'x' (cancel) button appears as soon as the first letter is typed.
  3. Embolden the letters in the results that are part of the user input
  4. A 'pin' icon appears for points (poi's, addresses) and a 'globe' icon appears for polygons (cities, neighborhoods) [customizable icons]

pelias_leaflet_flow-m1 3

When user collapses keyboard, show the remaining results

pelias_leaflet_flow-m1 3a

User selects a result

  1. Result text populates the search box
  2. Results that are points get a pin on the map with a tooltip (tooltip can be closed by clicking the 'x')
  3. Results that are polygons just zoom that map to include the polygon in the viewport and no pin is dropped (nice to have- label for the polygon is highlighted)
  4. Tapping 'x' in the search box clears the search box and the pin (if any) on the map

pelias_leaflet_flow-m1 4

TESTS!

Automate the process of improvements in the future without a lot of overhead of manual testing

Return lat.long

How can I get latitude and longitude from the Geocoder?
I want to pass them as var.

Demo site not loading over HTTPS

When loading the site over https, many browsers block content that mix script embeds over http when the main request was in https.

pelias_demo

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.