Update leaflet-control-geocoder to version 1.13.0

This commit is contained in:
David Molineus
2020-12-18 10:36:51 +01:00
parent 8045cdc07a
commit 996a3fb745
8 changed files with 1620 additions and 1101 deletions

View File

@@ -18,7 +18,7 @@ This package contains following packages:
- [Leaflet-omnivore 0.3.4](https://github.com/mapbox/leaflet-omnivore) - [Leaflet-omnivore 0.3.4](https://github.com/mapbox/leaflet-omnivore)
- [Leaflet.loading 0.1.24](https://github.com/ebrelsford/Leaflet.loading) - [Leaflet.loading 0.1.24](https://github.com/ebrelsford/Leaflet.loading)
- [Leaflet.Control.FullScreen 1.4.5](https://github.com/brunob/leaflet.fullscreen) - [Leaflet.Control.FullScreen 1.4.5](https://github.com/brunob/leaflet.fullscreen)
- [Leaflet Control Geocoder 1.6.0](https://github.com/perliedman/leaflet-control-geocoder) - [Leaflet Control Geocoder 1.13.0](https://github.com/perliedman/leaflet-control-geocoder)
- [Leaflet.ExtraMarkers 1.0.8](https://github.com/coryasilva/Leaflet.ExtraMarkers) - [Leaflet.ExtraMarkers 1.0.8](https://github.com/coryasilva/Leaflet.ExtraMarkers)
- [leaflet.pm 0.25.0](https://github.com/codeofsumit/leaflet.pm) - [leaflet.pm 0.25.0](https://github.com/codeofsumit/leaflet.pm)
- [osmtogeojson 2.2.12](https://github.com/tyrasd/osmtogeojson) - [osmtogeojson 2.2.12](https://github.com/tyrasd/osmtogeojson)

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -6,28 +6,35 @@ I strongly believe that it is my — and your — duty to make the open
While I can't force anyone to do anything, if you happen to disagree with this, I ask of you not to use any of the open source I have published. Nor am I interested in contributions from people who can't accept or act respectfully towards other humans regardless of gender identity, sexual orientation, disability, ethnicity, religion, age, physical appearance, body size, race, or similar personal characteristics. If you think feminism, anti-racism or the LGBT movement is somehow wrong, disturbing or irrelevant, I ask you to go elsewhere to find software. While I can't force anyone to do anything, if you happen to disagree with this, I ask of you not to use any of the open source I have published. Nor am I interested in contributions from people who can't accept or act respectfully towards other humans regardless of gender identity, sexual orientation, disability, ethnicity, religion, age, physical appearance, body size, race, or similar personal characteristics. If you think feminism, anti-racism or the LGBT movement is somehow wrong, disturbing or irrelevant, I ask you to go elsewhere to find software.
Leaflet Control Geocoder [![NPM version](https://img.shields.io/npm/v/leaflet-control-geocoder.svg)](https://www.npmjs.com/package/leaflet-control-geocoder) ![Leaflet 1.0.0 compatible!](https://img.shields.io/badge/Leaflet%201.0.0-%E2%9C%93-1EB300.svg?style=flat) # Leaflet Control Geocoder [![NPM version](https://img.shields.io/npm/v/leaflet-control-geocoder.svg)](https://www.npmjs.com/package/leaflet-control-geocoder) ![Leaflet 1.0.0 compatible!](https://img.shields.io/badge/Leaflet%201.0.0-%E2%9C%93-1EB300.svg?style=flat)
=============================
A simple geocoder for [Leaflet](http://leafletjs.com/) that by default uses [OSM](https://www.openstreetmap.org/)/[Nominatim](https://wiki.openstreetmap.org/wiki/Nominatim). A simple geocoder for [Leaflet](https://leafletjs.com/) that by default uses [OSM](https://www.openstreetmap.org/)/[Nominatim](https://wiki.openstreetmap.org/wiki/Nominatim).
The plugin supports many different data providers: The plugin supports many different data providers:
* [OSM](https://www.openstreetmap.org/)/[Nominatim](https://wiki.openstreetmap.org/wiki/Nominatim) - LatLng to parse basic latitude/longitude strings
* [Bing Locations API](http://msdn.microsoft.com/en-us/library/ff701715.aspx) - [OSM](https://www.openstreetmap.org/)/[Nominatim](https://wiki.openstreetmap.org/wiki/Nominatim)
* [Google Geocoding API](https://developers.google.com/maps/documentation/geocoding/) - [Bing Locations API](http://msdn.microsoft.com/en-us/library/ff701715.aspx)
* [Mapbox Geocoding](https://www.mapbox.com/developers/api/geocoding/) - [Google Geocoding API](https://developers.google.com/maps/documentation/geocoding/)
* [MapQuest Geocoding API](http://developer.mapquest.com/web/products/dev-services/geocoding-ws) - [Mapbox Geocoding](https://www.mapbox.com/api-documentation/#geocoding)
* [What3Words](http://what3words.com/) - [MapQuest Geocoding API](http://developer.mapquest.com/web/products/dev-services/geocoding-ws)
* [Photon](http://photon.komoot.de/) - [What3Words](http://what3words.com/)
* [Mapzen Search](https://mapzen.com/projects/search) - [Photon](http://photon.komoot.de/)
* [HERE Geocoder API](https://developer.here.com/documentation/geocoder/topics/introduction.html) - [Pelias](https://pelias.io/), [geocode.earth](https://geocode.earth/) (formerly Mapzen Search), [Openrouteservice](https://openrouteservice.org/dev/#/api-docs/geocode)
- [HERE Geocoder API](https://developer.here.com/documentation/geocoder/topics/introduction.html)
- [Neutrino API](https://www.neutrinoapi.com/api/geocode-address/)
- [Plus codes](https://plus.codes/) (formerly OpenLocationCode) (requires [open-location-code](https://www.npmjs.com/package/open-location-code))
The plugin can easily be extended to support other providers. Current extensions: The plugin can easily be extended to support other providers. Current extensions:
* [DAWA Geocoder](https://github.com/kjoller/leaflet-control-geocoder-dawa/tree/new) - support for Danish Address Web API by [Niels Kjøller Hansen](https://github.com/kjoller) - [DAWA Geocoder](https://github.com/kjoller/leaflet-control-geocoder-dawa/tree/new) - support for Danish Address Web API by [Niels Kjøller Hansen](https://github.com/kjoller)
See the [Leaflet Control Geocoder Demo](http://perliedman.github.com/leaflet-control-geocoder/). # Demos
- [Leaflet Control Geocoder Demo](https://www.liedman.net/leaflet-control-geocoder/) hosted on liedman.net
- See [demo/](https://github.com/perliedman/leaflet-control-geocoder/tree/master/demo)
- See [demo-rollup/](https://github.com/perliedman/leaflet-control-geocoder/tree/master/demo-rollup) using the [rollup.js](https://rollupjs.org/) bundler
- See [demo-webpack/](https://github.com/perliedman/leaflet-control-geocoder/tree/master/demo-rollup) using the [webpack](https://webpack.js.org/) bundler
# Usage # Usage
@@ -42,8 +49,8 @@ Add the control to a map instance:
```javascript ```javascript
var map = L.map('map').setView([0, 0], 2); var map = L.map('map').setView([0, 0], 2);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { L.tileLayer('https://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' attribution: '&copy; <a href="https://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map); }).addTo(map);
L.Control.geocoder().addTo(map); L.Control.geocoder().addTo(map);
``` ```
@@ -59,19 +66,19 @@ For example:
```javascript ```javascript
var geocoder = L.Control.geocoder({ var geocoder = L.Control.geocoder({
defaultMarkGeocode: false defaultMarkGeocode: false
}) })
.on('markgeocode', function(e) { .on('markgeocode', function(e) {
var bbox = e.geocode.bbox; var bbox = e.geocode.bbox;
var poly = L.polygon([ var poly = L.polygon([
bbox.getSouthEast(), bbox.getSouthEast(),
bbox.getNorthEast(), bbox.getNorthEast(),
bbox.getNorthWest(), bbox.getNorthWest(),
bbox.getSouthWest() bbox.getSouthWest()
]).addTo(map); ]).addTo(map);
map.fitBounds(poly.getBounds()); map.fitBounds(poly.getBounds());
}) })
.addTo(map); .addTo(map);
``` ```
This will add a polygon representing the result's boundingbox when a result is selected. This will add a polygon representing the result's boundingbox when a result is selected.
@@ -84,80 +91,129 @@ This is the geocoder control. It works like any other Leaflet control, and is ad
### Constructor ### Constructor
This plugin supports the standard JavaScript constructor (to be invoked using `new`) as well as the [class factory methods](http://leafletjs.com/reference.html#class-class-factories) known from Leaflet: This plugin supports the standard JavaScript constructor (to be invoked using `new`) as well as the [class factory methods](https://leafletjs.com/reference.html#class-class-factories) known from Leaflet:
```js ```js
new L.Control.Geocoder(options) new L.Control.Geocoder(options);
// or // or
L.Control.geocoder(options) L.Control.geocoder(options);
``` ```
### Options ### Options
| Option | Type | Default | Description | | Option | Type | Default | Description |
| ----------------- | ---------------- | ------------------- | ----------- | | ------------------ | --------- | ------------------------------------ | ------------------------------------------------------------------------------------------------------------- |
| `collapsed` | Boolean | `true` | Collapse control unless hovered/clicked | | `collapsed` | Boolean | `true` | Collapse control unless hovered/clicked |
| `expand` | String | `"touch"` | How to expand a collapsed control: `touch` or `click` or `hover` | | `expand` | String | `"touch"` | How to expand a collapsed control: `touch` or `click` or `hover` |
| `position` | String | `"topright"` | Control [position](http://leafletjs.com/reference.html#control-positions) | | `position` | String | `"topright"` | Control [position](https://leafletjs.com/reference.html#control-positions) |
| `placeholder` | String | `"Search..."` | Placeholder text for text input | `placeholder` | String | `"Search..."` | Placeholder text for text input |
| `errorMessage` | String | `"Nothing found."` | Message when no result found / geocoding error occurs | | `errorMessage` | String | `"Nothing found."` | Message when no result found / geocoding error occurs |
| `geocoder` | IGeocoder | `new L.Control.Geocoder.Nominatim()` | Object to perform the actual geocoding queries | | `iconLabel` | String | `"Initiate a new search"` | Accessibility label for the search icon used by screen readers |
| `showResultIcons` | Boolean | `false` | Show icons for geocoding results (if available); supported by Nominatim | | `geocoder` | IGeocoder | `new L.Control.Geocoder.Nominatim()` | Object to perform the actual geocoding queries |
| `showUniqueResult` | Boolean | `true` | Immediately show the unique result without prompting for alternatives |
| `showResultIcons` | Boolean | `false` | Show icons for geocoding results (if available); supported by Nominatim |
| `suggestMinLength` | Number | `3` | Minimum number characters before suggest functionality is used (if available from geocoder) |
| `suggestTimeout` | Number | `250` | Number of milliseconds after typing stopped before suggest functionality is used (if available from geocoder) |
| `query` | String | `""` | Initial query string for text input |
| `queryMinLength` | Number | `1` | Minimum number of characters in search text before performing a query |
### Methods ### Methods
| Method | Returns | Description | | Method | Returns | Description |
| ------------------------------------- | ------------------- | ----------------- | | --------------------------------------- | ------- | --------------------------------------- |
| `markGeocode(<GeocodingResult> result)` | `this` | Marks a geocoding result on the map | | `markGeocode(<GeocodingResult> result)` | `this` | Marks a geocoding result on the map |
| `setQuery(<String> query)` | `this` | Sets the query string on the text input |
## L.Control.Geocoder.Nominatim ## L.Control.Geocoder.Nominatim
Uses [Nominatim](https://wiki.openstreetmap.org/wiki/Nominatim) to respond to geocoding queries. This is the default Uses [Nominatim](https://wiki.openstreetmap.org/wiki/Nominatim) to respond to geocoding queries. This is the default
geocoding service used by the control, unless otherwise specified in the options. Implements ```IGeocoder```. geocoding service used by the control, unless otherwise specified in the options. Implements `IGeocoder`.
Unless using your own Nominatim installation, please refer to the [Nominatim usage policy](https://operations.osmfoundation.org/policies/nominatim/). Unless using your own Nominatim installation, please refer to the [Nominatim usage policy](https://operations.osmfoundation.org/policies/nominatim/).
### Constructor ### Constructor
```js ```js
new L.Control.Geocoder.Nominatim(options) new L.Control.Geocoder.Nominatim(options);
// or // or
L.Control.Geocoder.nominatim(options) L.Control.Geocoder.nominatim(options);
``` ```
## Options ### Options
| Option | Type | Default | Description | | Option | Type | Default | Description |
| --------------- | ---------------- | ----------------- | ----------- | | ---------------------- | -------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `serviceUrl` | String | `"https://nominatim.openstreetmap.org/"` | URL of the service | | `serviceUrl` | String | `"https://nominatim.openstreetmap.org/"` | URL of the service |
| `geocodingQueryParams` | Object | `{}` | Additional URL parameters (strings) that will be added to geocoding requests; can be used to restrict results to a specific country for example, by providing the [`countrycodes`](https://wiki.openstreetmap.org/wiki/Nominatim#Parameters) parameter to Nominatim | | `geocodingQueryParams` | Object | `{}` | Additional URL parameters (strings) that will be added to geocoding requests; can be used to restrict results to a specific country for example, by providing the [`countrycodes`](https://wiki.openstreetmap.org/wiki/Nominatim#Parameters) parameter to Nominatim |
| `reverseQueryParams` | Object | `{}` | Additional URL parameters (strings) that will be added to reverse geocoding requests | | `reverseQueryParams` | Object | `{}` | Additional URL parameters (strings) that will be added to reverse geocoding requests |
| `htmlTemplate` | function | special | A function that takes an GeocodingResult as argument and returns an HTML formatted string that represents the result. Default function breaks up address in parts from most to least specific, in attempt to increase readability compared to Nominatim's naming | `htmlTemplate` | function | special | A function that takes an GeocodingResult as argument and returns an HTML formatted string that represents the result. Default function breaks up address in parts from most to least specific, in attempt to increase readability compared to Nominatim's naming |
## L.Control.Geocoder.Bing ## L.Control.Geocoder.Bing
Uses [Bing Locations API](http://msdn.microsoft.com/en-us/library/ff701715.aspx) to respond to geocoding queries. Implements ```IGeocoder```. Uses [Bing Locations API](http://msdn.microsoft.com/en-us/library/ff701715.aspx) to respond to geocoding queries. Implements `IGeocoder`.
Note that you need an API key to use this service. Note that you need an API key to use this service.
### Constructor ### Constructor
```ts ```ts
new L.Control.Geocoder.Bing(<String> key) new L.Control.Geocoder.Bing(<String>key);
// or // or
L.Control.Geocoder.bing(<String> key) L.Control.Geocoder.bing(<String>key);
``` ```
## L.Control.Geocoder.OpenCage
Uses [OpenCage Data API](https://opencagedata.com/) to respond to geocoding queries. Implements `IGeocoder`.
Note that you need an API key to use this service.
### Constructor
```ts
new L.Control.Geocoder.OpenCage(<String>key, options);
// or
L.Control.Geocoder.opencage(<String>key, options);
```
### Options
| Option | Type | Default | Description |
| ---------------------- | ------ | ------------------------------------------------ | ------------------------------------------------------------------------------------ |
| `serviceUrl` | String | `"https://api.opencagedata.com/geocode/v1/json"` | URL of the service |
| `geocodingQueryParams` | Object | `{}` | Additional URL parameters (strings) that will be added to geocoding requests |
| `reverseQueryParams` | Object | `{}` | Additional URL parameters (strings) that will be added to reverse geocoding requests |
## L.Control.Geocoder.LatLng
Parses basic latitude/longitude strings such as `'50.06773 14.37742'`, `'N50.06773 W14.37742'`, `'S 50° 04.064 E 014° 22.645'`, or `'S 50° 4 03.828″, W 14° 22 38.712″'`.
### Constructor
```ts
new L.Control.Geocoder.LatLng(options);
// or
L.Control.Geocoder.latLng(options);
```
### Options
| Option | Type | Default | Description |
| -------------- | --------- | ------- | --------------------------------------------------------- |
| `next` | IGeocoder | | The next geocoder to use for non-supported queries. |
| `sizeInMeters` | Number | 10000 | The size in meters used for passing to `LatLng.toBounds`. |
## IGeocoder ## IGeocoder
An interface implemented to respond to geocoding queries. An interface implemented to respond to geocoding queries.
### Methods ### Methods
| Method | Returns | Description | | Method | Returns | Description |
| ------------------------------------- | ------------------- | ----------------- | | ----------------------------------------------------------------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `geocode(<String> query, callback, context)` | `GeocodingResult[]` | Performs a geocoding query and returns the results to the callback in the provided context | | `geocode(<String> query, callback, context)` | `GeocodingResult[]` | Performs a geocoding query and returns the results to the callback in the provided context |
| `reverse(<L.LatLng> location, <Number> scale, callback, context)` | `GeocodingResult[]` | Performs a reverse geocoding query and returns the results to the callback in the provided context | | `suggest(<String> query, callback, context)` | `GeocodingResult[]` | Performs a geocoding query suggestion (this happens while typing) and returns the results to the callback in the provided context |
| `reverse(<L.LatLng> location, <Number> scale, callback, context)` | `GeocodingResult[]` | Performs a reverse geocoding query and returns the results to the callback in the provided context |
## GeocodingResult ## GeocodingResult
@@ -165,10 +221,10 @@ An object that represents a result from a geocoding query.
### Properties ### Properties
| Property | Type | Description | | Property | Type | Description |
| ------------ | ---------------- | ------------------------------------- | | -------- | -------------- | ---------------------------------------------------- |
| `name` | String | Name of found location | | `name` | String | Name of found location |
| `bbox` | L.LatLngBounds | The bounds of the location | | `bbox` | L.LatLngBounds | The bounds of the location |
| `center` | L.LatLng | The center coordinate of the location | | `center` | L.LatLng | The center coordinate of the location |
| `icon` | String | URL for icon representing result; optional | | `icon` | String | URL for icon representing result; optional |
| `html` | String | (optional) HTML formatted representation of the name | | `html` | String | (optional) HTML formatted representation of the name |

View File

@@ -1,40 +1,63 @@
{ {
"name": "leaflet-control-geocoder", "name": "leaflet-control-geocoder",
"version": "1.6.0", "version": "1.13.0",
"description": "Extendable geocoder with builtin support for Nominatim, Bing, Google, Mapbox, Photon, What3Words, MapQuest, Mapzen, HERE", "description": "Extendable geocoder with builtin support for OpenStreetMap Nominatim, Bing, Google, Mapbox, MapQuest, What3Words, Photon, Pelias, HERE, Neutrino, Plus codes",
"main": "dist/Control.Geocoder.js", "main": "dist/Control.Geocoder.js",
"module": "src/index.js",
"scripts": { "scripts": {
"prepare": "npm run build", "prepare": "npm run build",
"build": "npm run build:js && npm run build:css && npm run build:img", "build": "npm run build:js && npm run build:css && npm run build:img && npm run build:demo-rollup && npm run build:demo-webpack",
"build:js": "rollup --output.format=iife --name=L.Control.Geocoder --globals=leaflet:L src/index.js --output.file=dist/Control.Geocoder.js --sourcemap", "build:js": "rollup -c",
"build:css": "cpr Control.Geocoder.css dist/ --overwrite", "build:css": "cpr Control.Geocoder.css dist/Control.Geocoder.css --overwrite",
"build:img": "cpr images/ dist/images/ --overwrite", "build:img": "cpr images/ dist/images/ --overwrite",
"test": "npm run lint", "build:demo-rollup": "cd demo-rollup && npm install && npm run build",
"lint": "npm run lint:js && npm run lint:css", "build:demo-webpack": "cd demo-rollup && npm install && npm run build",
"lint:js": "eslint 'src/**'", "test": "npm run test:karma -- --single-run && npm run lint",
"lint:css": "prettier --list-different '*.css'", "test:karma": "karma start spec/karma.conf.js",
"publish": "sh ./scripts/publish.sh", "lint": "npm run lint:js && npm run lint:style",
"postpublish": "sh ./scripts/postpublish.sh" "lint:js": "eslint .",
"lint:style": "prettier --check $(npm run ls-files)",
"fix:style": "prettier --write $(npm run ls-files)",
"ls-files": "git ls-files '*.js' '*.json' '*.css' '*.html' '*.yaml' '*.yml' '*.md'"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git://github.com/perliedman/leaflet-control-geocoder.git" "url": "git://github.com/perliedman/leaflet-control-geocoder.git"
}, },
"files": [
"LICENCE",
"dist/**",
"demo/**",
"images/**",
"src/**",
"*.css"
],
"keywords": [ "keywords": [
"leaflet", "leaflet",
"geocoder", "geocoder",
"locations", "locations",
"openstreetmap",
"nominatim", "nominatim",
"bing", "bing",
"google", "bingmaps",
"googlemaps",
"google-maps",
"mapbox", "mapbox",
"photon",
"what3words",
"mapquest", "mapquest",
"opencage",
"what3words",
"photon",
"mapzen", "mapzen",
"here" "pelias",
"here",
"neutrino",
"pluscodes",
"open location code"
], ],
"author": "Per Liedman <per@liedman.net>", "author": "Per Liedman <per@liedman.net>",
"contributors": [
"Simon Legner <Simon.Legner@gmail.com>"
],
"license": "BSD-2-Clause", "license": "BSD-2-Clause",
"bugs": { "bugs": {
"url": "https://github.com/perliedman/leaflet-control-geocoder/issues" "url": "https://github.com/perliedman/leaflet-control-geocoder/issues"
@@ -42,9 +65,23 @@
"dependencies": {}, "dependencies": {},
"devDependencies": { "devDependencies": {
"cpr": "^3.0.1", "cpr": "^3.0.1",
"eslint": "^4.15.0", "eslint": "^6.8.0",
"eslint-plugin-prettier": "^2.4.0", "eslint-plugin-prettier": "^3.1.2",
"prettier": "^1.9.2", "karma": "^4.4.1",
"rollup": "^0.53.2" "karma-expect": "^1.1.3",
"karma-mocha": "^1.3.0",
"karma-phantomjs-launcher": "^1.0.4",
"karma-sinon": "^1.0.5",
"leaflet": "^1.6.0",
"mocha": "^6.2.2",
"phantomjs-prebuilt": "^2.1.16",
"prettier": "^1.19.1",
"rollup": "^0.65.2",
"rollup-plugin-uglify": "^5.0.2",
"sinon": "^7.5.0",
"uglify-js": "^3.7.5"
},
"optionalDependencies": {
"open-location-code": "^1.0.0"
} }
} }

View File

@@ -75,7 +75,7 @@ $GLOBALS['LEAFLET_LIBRARIES']['leaflet-fullscreen'] = array
$GLOBALS['LEAFLET_LIBRARIES']['leaflet-control-geocoder'] = array $GLOBALS['LEAFLET_LIBRARIES']['leaflet-control-geocoder'] = array
( (
'name' => 'Leaflet Control Geocoder', 'name' => 'Leaflet Control Geocoder',
'version' => '1.6.0', 'version' => '1.13.0',
'license' => '<a href="https://github.com/perliedman/leaflet-control-geocoder/blob/master/LICENSE" target="_blank">BSD-2-Clause</a>', 'license' => '<a href="https://github.com/perliedman/leaflet-control-geocoder/blob/master/LICENSE" target="_blank">BSD-2-Clause</a>',
'homepage' => 'https://github.com/perliedman/leaflet-control-geocoder', 'homepage' => 'https://github.com/perliedman/leaflet-control-geocoder',
'css' => 'assets/leaflet/libs/control-geocoder/Control.Geocoder.min.css', 'css' => 'assets/leaflet/libs/control-geocoder/Control.Geocoder.min.css',