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

@langateam/leaflet-geojson-autocomplete

v1.0.1

Published

Leaflet Autocomplete For Remote Searching with GeoJSON Services.

Downloads

13

Readme

Leaflet.GeoJSONAutocomplete

Leaflet Autocomplete For Remote Searching with GeoJSON Services.

Demo

This plug-in runs with classical autocomplete logic. Users type in search box and plug-in sends ajax request to your geojson service.

It requires Leafletjs and JQuery. It has beeen tested with Leaflet 0.7.3 and JQuery 1.11.3

#Example Request and Response

When users type 'Ankara' in search box. Plug-in sends a ajax request with 3 parameters like the following.

http://yourGeoJsonSearchAddress?search=Ankara&limit=10&offset=0 (Parameters is explained in Options Section)

Your response should be valid GeoJson like the following

{
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    32.84,
                    39.92
                ]
            },
            "properties": {
                "popupContent": "Content seen in Popup",
                "title": "Title seen in Autocomplete",
                "description": "Additional information seen in Autocomplete",
                "image": "example.png"
            }
        }
    ]
}

#Test your service response

Test it!

Your geojson features must have 4 properties

  • title: Main title seen in autocomplete results
  • description: More details seen in autocomplete results
  • popupContent: Content seen in popups.
  • image: Images seen in autocomplete results (read from image folder)

#Usage

Just add

<div id="searchContainer"></div> 

tag to your html and

var options = {
  geojsonServiceAddress: "http://yourgeojsonsearchaddress"
};
$("#searchContainer").GeoJsonAutocomplete(options);

to your window.onload function.

#Options

  • geojsonServiceAddress: Address of your geojson service.
    • Ajax request sends 3 parameter to your service.
      • search query parameter
      • offset starting index (If pagingActive parameter is true)
      • limit maximum result count
  • placeholderMessage: Placeholder message for search box.
  • searchButtonTitle: Title of search button.
  • clearButtonTitle: Title of Clear button.
  • foundRecordsMessage: Found message
  • limit: Maximum record count for every search
  • notFoundMessage: Not found message
  • notFoundHint: Nof found hint
  • drawColor: Color for Linestring and polygon geometries.
  • pointGeometryZoomLevel: Zoom level for point geometries. -1 means use leaflet default.
  • pagingActive: If your geojson service supports paging (accepts offset parameter) change this to true.

#Paging Mode If your geojson service supports paging (accepts offset parameter), you can activate paging with pagingActive parameter in options. When you type any text and press Enter(or click Search Button), Autocomplete runs with paging mode. In paging mode Autocomplete draw all geometries on map in a page.

#License

Leaflet.GeoJSONAutocomplete is free software, and may be redistributed under the MIT License.

Please let me know your comments and usage.

Thanks to CitySurf to inspire and support this plugin.