Skip to content

Leaflet plugin for using the address search from Norkart. Requires an API-key.

License

Notifications You must be signed in to change notification settings

Norkart/L.Control.NorkartSearch

Repository files navigation

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

option Type Default Description
apiKey string none an api key from Norkart
position leaflet control position 'topright' position of the leaflet control
placeholder string Søk placeholder text for search box
showMarker boolean true Wether or not to show a marker in the map when a hit is selected
limits array undefined array of municipality id's (kommunenummer) to limit search to
targets array ['matrikkelenhet', 'gateadresse'] target names that determines what type of search the engine supports. Supported targets are: 'matrikkelenhet', 'gateadresse', 'stedsnavn' (and more, see fritektsook api).

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

About

Leaflet plugin for using the address search from Norkart. Requires an API-key.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published