2.0.0 • Published 6 years ago

leaflet-norkartsearch v2.0.0

Weekly downloads
-
License
BSD-2-Clause
Repository
-
Last release
6 years ago

L.Control.NorkartSearch

L.Control.NorkartSearch is a Leaflet plugin for using the address search from Norkart. Requires an API-key.

Usage

L.control.norkartSearch({
    apiKey: 'MY_API_KEY'
}).addTo(map);

Options

optionTypeDefaultDescription
apiKeystringnonean api key from Norkart
positionleaflet control position'topright'position of the leaflet control
placeholderstringSøkplaceholder text for search box
showMarkerbooleantrueWether or not to show a marker in the map when a hit is selected
limitsarrayundefinedarray of municipality id's (kommunenummer) to limit search to
targetsarray'matrikkelenhet', 'gateadresse'target names that determines what type of search the engine supports. Supported targets are: 'matrikkelenhet', 'gateadresse', 'stedsnavn' (and more, see fritektsook api).
<!--onFocusbooleanfalseWether or not the searchbox should be automatically selected (focused) when the page is loaded -->

Events

the plugin triggers a ```search:select``` event on the map when a hit is selected.

map.on('search:select', function(event) {
    var position = event.position; // a L.latLng
    var element = event.element; // The raw data from the search API
});

As a standalone component

Make sure to have the following components available on your page

And include the L.Control.NorkartSearch.js and L.Control.NorkartSearch.css from /build/.

See demo/index.html for an example.

As an npm-module

Install:

npm install @norkart/leaflet-norkartsearch --save

In code:

require('leaflet-norkartsearch');

Demo

See https://norkart.github.io/L.Control.NorkartSearch/demo/ for a simple example

Contribute

Install dependencies:

npm install

Run code:

Run the demo code by running: npm start and go to localhost:8080