Ambita Map

ambita-map.js is a JavaScript API / library that is built as a Leaflet wrapper / plugin.

Please refer to Leaflet documentation for further questions regarding Leaflet. It is also advised to take a look at the great examples that are available on the Leaflet webpage and goes deeply into extending Leaflet and adding new exciting functionality. ambita-map.js provides the same extendability and functionality with various extra features added on top.

ambita-map.js uses Leaflet version 1.2.0 which is a stable release.

 

Get started

To get started include the ambita-map.js library’s CSS file and JavaScript file in your HTML:

  • Include ambita-map.css file from the library in the <head> section of the HTML:

    <link rel="stylesheet" href="https://static.ambita.com/ambita-map/latest/ambita-map.css">

  • Include ambita-map.js file from the library in the <head> or <body> section of the HTML:

    <script type="text/javascript" src="https://static.ambita.com/ambita-map/latest/ambita-map.js"></script>

  • Optionally include font-awesome.css file from the Font Awesome library in the <head> section of the HTML to be able to display the default icons used by the map properly (not a requirement since the default icons used by the map can be overridden, see the map options):

    <link rel="stylesheet" type="text/css" href="https://unpkg.com/font-awesome@4.7.0/css/font-awesome.css">

  • Add a <div> element with a given id in the <body> section of the HTML where the map should be displayed:

    <div id="map"></div>

  • Define height of the added <div> element to properly display the map:

    #map { height: 600px; }
  • Initialize the map using the added <div> element or its id, a valid Ambita authorization token string and map options that are completely optional. More about token handling and retrieving a valid Ambita authorization token is described in the next section of this documentation:

    L.ambita.map('map', 'VALID TOKEN', { center: [60, 10], zoom: 14 })ja

See the style guide below on how to style the individual elements on the map.

Token handling

To be able to use the map a valid Ambita authorization token is required. To retrieve a valid Ambita authorization token a POST method call against authentication API token service has to be made. Opening the authentication resource links in the browser will give an HTTP 401 Unauthorized error, unless a valid Ambita authorization token is set on the Authorization parameter using the request headers.

Valid Ambita authorization token can be generated using proper credentials and the following resource URL https://beta-api.ambita.com/authentication/v2/token or https://api.ambita.com/authentication/v2/token if the production API is being used (ambita-map.js uses beta-api by default, switching to production API is done through map options). Using JavaScript requires to do a simple POST method call passing the authorization parameters as the URL parameters to the authentication API’s token service https://beta-api.ambita.com/authentication/v2/token?grant_type=password&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&username=API_USERNAME&password=API_PASSWORD

Example of the request

Just for the sake of the example the POST method call is shown using jQuery. jQuery is not a requirement by any means.

var url = 'https://beta-api.ambita.com/authentication/v2/token?grant_type=password&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&username=API_USERNAME&password=API_PASSWORD'; $.post(url, function (data, status) { // work with the JSON response here });

After a request to generate a token is made a JSON response will be returned containing the access_token.

Example of the response

The map authorization token consists of token_type and access_token combined and separated with a whitespace. The response from the authentication API also consists of the expiration time of the access_token in seconds, a refresh_token that could be used to generate a new access_token once it has expired and an array of scopes the retrieved access_token has access to. Using the example response, the authorization token would look like this Bearer b8e7f3c5-f8c6-4011-9bd6-0282a1894df7. The authorization token needs to be passed to the map initialization function and by default expires after an hour. When the token has expired the map fires a tokenrequired event. To continue to use all the map features a new authorization token needs to be generated and passed to the map using map.authenticate(token) function.

To retrieve a new Ambita authorization token the refresh_token can be used. Using JavaScript requires to do a simple POST method call passing the authorization parameters as the URL parameters to the authentication API’s token service https://beta-api.ambita.com/authentication/v2/token?grant_type=refresh_token&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&refresh_token=REFRESH_TOKEN

Example of the request can be found above.

Token example code

Full example with a valid token

Live demo of the example can be found here JSFiddle

Example of working with the map after initialization

To work with the newly created map object it should be properly initialized. Every action or function call on the map object should be done after ambitamap:loaded is fired.

Demo

To be able to work with the demo a valid Ambita authorization token is needed and more information regarding token handling is provided above. A complete demo of the ambita-map.js library and its different features can be found and tested out here ambita-map.html.

API

Creates and returns the map object and configures the map using the passed in map options.

ExtendsL.Map

Factory

Option

Type

Description

Option

Type

Description

id or element

String or HTMLElement

required The id of a <div> element or an instance of a <div> HTML element

token

String

required Ambita authorization token in the form of Bearer + access_token, for example, Bearer b8e7f3c5-f8c6-4011-9bd6-0282a1894df7. If empty, tokenrequired event will be fired

options

Object

Map options, see below for more details

Options

Since ambita-map.js is built on top of the Leaflet library it inherits the map options from the library and adds ambita-map.js specific map options as well. Default Leaflet map options can be found in the Leaflet documentation.

Option

Type

Default

Description

Option

Type

Default

Description

restApi

String

https://beta-api.ambita.com

REST API address, for production use https://api.ambita.com

crs

CRS Object

L.ambita.CRS[‘EPSG:25833’]

Map CRS used to show the base and other layers on the map in a different coordinate system than WGS84

zoom

Number

10

Initial map zoom level, a number between 1 and 17

center

Number[]

[60, 10]

Initial center of the map, an array of two coordinates in WGS84 coordinate system [latitude‎, longitude‎]

keyboard

Boolean

true

Enable keyboard controlled movement of the map

inertia

Boolean

true

Enable inertia when panning the map using mouse

attributionControl

Boolean

false

Show attribution control on the map

attributionControlOptions

Object

undefined

Options to customize the attribution control, see below for options

minZoom

Number

3

Minimum zoom level of the map

maxZoom

Number

17

Maximum zoom level of the map

ambitaToken

String

undefined

Authorization token from the Ambita authentication API (must set token to undefined on map initialization to use this option)

geoToken

String

undefined

GeoData token (fetched automatically on map initialization if not specified)

maxRetries

Number

3

Number of times tokenrequired is fired before ignoring new tokenrequired events. If the tokenrequired event is fired 3 consecutive times without getting a valid authorization token, then tokenfailed event is fired.

svgPathClassName

String

‘selection-cadastre’

Default SVG path class name for geometries added to the map

detailedHeightLegendControl

Boolean

true

Enable the detailed height legend control

fitBuffer

Number

10

The default buffer for fitBounds calls of points in pixels

zoomControl

Boolean

false

Show the default Leaflet zoom control

showPropertyLayer

Boolean

true

Show the property layer on the map

fullscreenControl

Boolean

undefined

Show the default Leaflet fullscreen control

layerControl

Boolean

true

Show the layer control button

layerControlPosition

String

‘topleft’

Position of the layer control button

layerControlHtml

String

L.ambita.Statics.SVG_BUTTONS.layers

HTML for the layer control button

scaleControl

Boolean

false

Show the scale control at the bottom left corner of the map

poweredByControl

Boolean

true

Show the Powered by Ambita control at the bottom right corner of the map

editable

Boolean

true

Enable the editing of geometries functionality on the map

editOptions.lineGuideOptions.className

String

‘selection-lineguide’

Class name of the selection tools line guide

editOptions.middleMarkerClass

Class

middleMarkerCustom

Custom class of the selection tools middle markers

selectionToolsOptions

Object

{ show: false }

Options to customize the selection tools, see below for options

pocLayer

Object

undefined

Options to customize the POC layer, see below for options

pobLayer

Object

undefined

Options to customize the POB layer, see below for options

restrictToMunicipality

String

undefined

Municipality code of the Norway municipality to fetch and draw a border of

addZoomControl

Boolean

true

Show the zoom control buttons

animateTools

Boolean

false

Animate the display of zoom, layer, selection tools controls

tokenUrl

String

‘/authentication/v2/token’

Path to authorization token resource

geoTokenUrl

String

‘/authentication/v2/geodatatoken’

Path to GeoData token resource

url

String

‘arcgis/rest/services/’

Path to ArcGIS REST services

utmCache

String

‘Geocache_UTM33_EUREF89/’

Path to UTM Cache service

utmDynamic

String

‘Geomap_UTM33_EUREF89/’

Path to UTM Dynamic service

mapServer

String

‘/MapServer/’

Path to map server

cache

String

‘Geocache’

Name of UTM Cache service

dynamic

String

‘Geomap’

Name of UTM Dynamic service

base

String

‘Basis’

Name of the base map layer

orto

String

‘Bilder’

Name of the map orto layer

property

String

‘Eiendom3’

Name of the map property layer

cacheServer

String

https://services.geodataonline.no/

UTM Cache server address

dynamicServer

String

https://services.geodataonline.no/

UTM Dynamic server address

static

Boolean

false

Enable static map (no interactivity)

nopan

Boolean

false

Disable panning of the map

maxHeight

Number

200

Maximum height of the feature popup

maxWidth

Number

300

Maximum width of the feature popup

minWidth

Number

100

Minimum width of the feature popup

offset

Point

L.point(0, 0)

Offset of the feature popup

tokenExpiration

Number

60

GeoData token expiration time in minutes

ambitaControls

Object[]

undefined

Array of customizable Ambita controls, see below for options

fullscreenControlOptions

Object

undefined

Options to customize the fullscreen control, see below for options

scaleControlOptions

Object

undefined

Options to customize the scale control, see below for options

Attribution control options

Option

Type

Default

Description

Option

Type

Default

Description

position

String

‘bottomright’

Position of the attribution control

prefix

String

’’

Prefix text to the attribution control

Selection tools options

Selection tools can be used to draw different geometries on the map.

Option

Type

Default

Description

Option

Type

Default

Description

show

Boolean

Show the selection tools on the map, map option editable should be true as well

 

position

String

‘bottomleft’

Position of the selection tools control

identifyLayerId

String

‘3’

GeoData identify layer Id

fitToFeatureOwnerList

Boolean

false

Enable fitBounds for owner list

fitToFeatureNeighborList

Boolean

true

Enable fitBounds for neighbor list

filterSectionOwnerList

Boolean

true

Enable filtering on sections in owner list

filterSectionNeighborList

Boolean

true

Enable filtering on sections in neighbor list

mainCadastreNameNeighborList

String

‘selection-main-cadastre’

Neighbor list main cadastre CSS class name

maxOwnerListCount

Number

500

Maximum owners count returned from the service for owner list

maxNeighborListCount

Number

35

Maximum neighbors count returned from service for neighbor list

minPolygonAreaSize

Number

100

Minimum area size of polygon selection

minRectangleAreaSize

Number

100

Minimum area size of rectangle selection

maxArea

Number

NaN

Maximum area size of selection

intersectingPolygonErrorTooltip

String

‘Linjene kan ikke krysses’

Tooltip for the intersecting polygon error

polygonCrossingMunicipalityBorder

String

‘Utvalget krysser kommunegrenser’

Tooltip for the polygon selection crossing municipality border

maxOwnerListCountErrorTooltip

String

‘Ingen flere matrikkler kan legges til utvalget’

Tooltip for the maximum owners count error

maxOwnerListSelectionCountErrorTooltip

String

‘Valgt område er for stort, for mange eiendommer returnert’

Tooltip for the maximum owners count error when doing single property selections

maxNeighborListCountErrorTooltip

String

‘Ingen flere matrikkler kan legges til utvalget’

Tooltip for the maximum neighbors count error

mainCadastreNeighborListErrorTooltip

String

‘Hoved matrikkelen finnes ikke, så det er ingen nabo listen tilgjengelig’

Tooltip for the main cadastre error

minPolygonAreaSizeErrorTooltip

String

‘Valgt område er for lite’

Tooltip for the minimum area size error for polygon selection

minRectangleAreaSizeErrorTooltip

String

‘Valgt område er for lite’

Tooltip for the minimum area size error for rectangle selection

maxPolygonAreaSizeErrorTooltip

String

‘Valgt område er for stort’

Tooltip for the maximum area size error for polygon selection

maxRectangleAreaSizeErrorTooltip

String

‘Valgt område er for stort’

Tooltip for the maximum area size error for rectangle selection

outsideNorwayErrorTooltip

String

‘Utvalget har gjort må være helt inne Norge’

Tooltip for the selection outside of Norway error

intersectionWithOsloErrorTooltip

String

‘Utvalget må være enten helt innenfor eller utenfor Oslo’

Tooltip for the selection intersecting with Oslo error

restrictToPolygonErrorTooltip

String

‘Utvalget er utenfor kommunen’

Tooltip for the selection crossing restricted municipality polygon error

cadastreToggleButtonIcon

String

‘fa-mouse-pointer’

Font Awesome icon for the cadastre toggle button

cadastreToggleButtonTitle

String

‘Legg til eller fjern matrikkel fra utvalget’

Title of the cadastre toggle button

cadastreToggleTooltip

String

‘Klikk på kartet for å legge til en matrikkel, klikk på en matrikkel for å fjerne den’

Tooltip for the cadastre toggle button

polylineButtonIcon

String

‘fa-expand’

Font Awesome icon for the polyline button

polylineButtonHtml

String

L.ambita.Statics.SVG_BUTTONS.polyline

HTML for the polyline button, supersedes the icon option

polylineButtonTitle

String

‘Tegn en linje’

Title of the polyline button

polylineStartTooltip

String

‘Klikk i kartet for å starte en linje’

Tooltip for the polyline selection start point

polylineContinueTooltip

String

‘Klikk i kartet for å skifte retning’

Tooltip for the polyline selection continue point

polylineFinishTooltip

String

‘Klikk på det siste punktet for å avslutte linjen’

Tooltip for the polyline selection finish point

polygonButtonIcon

String

‘fa-map’

Font Awesome icon for the polygon button

polygonButtonHtml

String

L.ambita.Statics.SVG_BUTTONS.polygon

HTML for the polygon button, supersedes the icon option

polygonButtonTitle

String

‘Tegn et polygon’

Title of the polygon button

polygonStartTooltip

String

‘Klikk i kartet for å starte polygonet’

Tooltip for the polygon selection start point

polygonContinueTooltip

String

‘Klikk i kartet for å fortsette polygonet’

Tooltip for the polygon selection continue point

polygonFinishTooltip

String

‘Klikk på det siste punktet for å avslutte polygonet’

Tooltip for the polygon selection finish point

rectangleButtonIcon

String

‘fa-stop’

Font Awesome icon for the rectangle button

rectangleButtonHtml

String

L.ambita.Statics.SVG_BUTTONS.rectangle

HTML for the rectangle button, supersedes the icon option

rectangleButtonTitle

String

‘Tegn et rektangel’

Title of the rectangle button

rectangleStartTooltip

String

‘Trykk og dra i kartet for å starte rektangelet’

Tooltip for the rectangle selection start point

rectangleFinishTooltip

String

‘Dra i hjørnet eller klikk på det for å fullføre rektangelet’

Tooltip for the rectangle selection finish point

deleteButtonIcon

String

‘fa-trash’

Font Awesome icon for the delete button

deleteButtonTitle

String

‘Slett utvalget’

Title of the delete button

dragVertexTooltip

String

‘Dra i et punkt for å endre’

Tooltip for the vertex drag for rectangle selection

dragClickVertexTooltip

String

‘Dra i et punkt for å endre eller klikk for å slette det’

Tooltip for the vertex drag or click for polyline and polygon selections

chooseCadastrePlotTooltip

String

‘Velg eiendom på kartet’

Tooltip for choosing cadastre plot

POC / POB layer options

POC and POB layers work with the Realty REST API to display various data on the map.

Option

Type

Default

Description

Option

Type

Default

Description

options

Object

undefined

Object containing all the POC / POB layer options

options.on

Boolean

true

Enable the POC / POB layer

options.restApi

String

https://beta-api.ambita.com

REST API address, for production use https://api.ambita.com

options.minZoom

Number

14

Minimum zoom level when the layer is visible

options.maxZoom

Number

17

Maximum zoom level when the layer is visible

options.freeMarketOnly

Boolean

true

Show free market data only

options.fromDate

Number

2010

Date from which the data should be displayed

options.toDate

Number

2020

Date to which the data should be displayed

options.groundUsage

String

’’

Show ground usage data

options.dateFormat

String

‘DD/MM-YYYY’

Date format

options.maxHeight

Number

200

Maximum height of the feature popup

options.maxWidth

Number

300

Maximum width of the feature popup

options.minWidth

Number

100

Minimum width of the feature popup

options.offset

Point

L.point(0, 0)

Offset of the feature popup

options.ambitaToken

String

undefined

Authorization token from the Ambita authentication API (if a different authorization token than the one used by the map is needed)

Ambita controls options

Option

Type

Default

Description

Option

Type

Default

Description

position

String

‘topleft’

Position of the custom Ambita control

active

Boolean

false

Enable the control on initialization

title

String

undefined

Title of the custom Ambita control

icon

String

undefined

Icon of the custom Ambita control

fn

Function

undefined

Function to be called on control click event

oneTime

Boolean

undefined

Enable one time click functionality

callback

Function

undefined

Function to be called on map click event

Fullscreen control options

Option

Type

Default

Description

Option

Type

Default

Description

position

String

‘topleft’

Position of the fullscreen control

text

String

<i class="fa-arrows-alt fa fa-lg"></i>

HTML for the fullscreen control button

title

String

‘Fullskjerm’

Title of the fullscreen control button

forceSeparateButton

Boolean

false

Forces fullscreen control as a separate button, otherwise a part of zoom control

forcePseudoFullscreen

Boolean

false

Forces pseudo fullscreen, true by default if displayed in an iframe

fullscreenContainer

HTMLElement

Map Container

Container to display the pseudo fullscreen in

Scale control options

Option

Type

Default

Description

Option

Type

Default

Description

position

String

‘bottomleft’

Position of the scale control, cannot be modified

maxWidth

Number

100

Maximum width of the scale control in pixels

metric

Boolean

true

Show the metric scale

imperial

Boolean

true

Show the imperial scale, if no scale control options passed this is false

updateWhenIdle

Boolean

false

Update on moveend

Feature layer options

Option

Type

Default

Description

Option

Type

Default

Description

svgPathClassName

String

‘selection-cadastre’

Default SVG path class name for features added to the map

layerTitle

String

undefined

Adds the feature layer to the layer control using title provided, not used by fitBoundsToGeoJSON

layerShownEvent

String

undefined

Name of the event to be fired when the layer is shown on the map, not used by fitBoundsToGeoJSON

animateFitBounds

Boolean

undefined

Enable animation of fitBounds calls, only used by fitBoundsToGeoJSON and other methods when fitToFeature option is true

clearLayer

Boolean

undefined

Clears the previously added feature layer by the same name, not used by fitBoundsToGeoJSON

clearLayers

Boolean

undefined

Clears all previously added feature layers, not used by fitBoundsToGeoJSON

fitToFeature

Boolean

undefined

Zooms the map to the added feature layer

fitBuffer

Number

undefined

Sets the padding of the map container that should not be accounted for when zooming the map to the added feature layer

showLabel

Boolean

undefined

Shows an HTML label in the center of the feature layer, only works if labelHtml option is defined

labelHtml

Function

undefined

Function that receives feature as a parameter and returns an HTML to display on the feature layer

featureGroupLayer

Layer

undefined

Layer group on which the newly added feature layer would be added on, not used by fitBoundsToGeoJSON

Neighbor list options

Option

Type

Default

Description

Option

Type

Default

Description

title

String

‘neighborlist’

Name of the neighbor list layer

filterSection

Boolean

true

Should the cadastre sections be filtered out

hideProperty

Boolean

undefined

Should the main cadastre be shown on the map

showBuffer

Boolean

undefined

Should the buffer around the main cadastre be shown on the map

showLabel

Boolean

undefined

Same description as in FeatureLayerOptions

labelHtml

Function

undefined

Same description as in FeatureLayerOptions

clearLayer

Boolean

undefined

Same description as in FeatureLayerOptions

fitToPlot

Boolean

undefined

Zooms the map to the main cadastre layer

fitBuffer

Number

undefined

Same description as in FeatureLayerOptions

Events

ambita-map.js library fires different events based on the actions done using the map. These events can be used to implement further interactability with the map.

Example usage of events fired by the map

Selection tools fire events when they are used so it is possible to act on the different actions done using line, polygon or rectangle selection tools on the map based on the event fired.

Example JavaScript code using selection tools events on an already created map instance is shown below:

Map events

In addition to all of the custom ambita-map.js map events that are listed below the map also fires the default map events provided by the Leaflet library that can be found here.

Event

Description

Returned value

Event

Description

Returned value

ambitamap:loaded

Fired when initialization of the map is done

 

tokenrequired

Fired when authorization with Ambita authentication API has failed

 

tokenfailed

Fired when authorization with Ambita authentication API has failed 3 consecutive times

 

featureLayerShown

Fired when a feature layer is shown on the map using the showFeatureLayer method and layerShownEvent option has not been specified

Layer just added to the map

featureLayersShown

Fired when feature layers are shown on the map using the showFeatureLayers method and layerShownEvent option has not been specified

Layer just added to the map

markerClusterLayerShown

Fired when a marker cluster layer is shown on the map using the showMarkerClusterLayer method and layerShownEvent option has not been specified

Layer just added to the map

ambitaTaskDone

Fired when any of the Ambita tasks have been executed

Object containing retrieved feature collection

featureClick

Fired when default layer options are used and a feature is clicked that has a type option

Object containing clicked feature

cadastre

Fired when propertyClick method is used from Ambita custom control

Object containing retrieved feature collection

boundary

Fired when boundaryClick method is used from Ambita custom control

Object containing retrieved feature collection

exitFullscreen

Fired when the map exits fullscreen mode

 

enterFullscreen

Fired when the map enters fullscreen mode

 

queryCadastreEmpty

Fired when the input cadastre is defined incorrectly for neighbor list

 

identifyFeatureEmpty

Fired when the identifyFeature method returns empty data from GeoData

 

queryTaskDone

Fired when the query task to return owners is done for owner list

Object containing retrieved feature collection

countTaskError

Fired when the count task returns owner count that exceeds the maximum owners count for owner list

 

neighborListLayerLoaded

Fired when the neighbor list layer has been loaded

 

Selection tools events

Event

Description

Returned value

Event

Description

Returned value

selection:started

Fired when a new selection is started

Type of selection editor that is started

selection:ended

Fired when the selection is ended using mouse double click

GeoJSON of the selection made on the map

selection:updated

Fired when the selection is modified using mouse

GeoJSON of the selection made on the map

selection:updating

Fired when the selection is started to be modified using mouse

GeoJSON of the selection made on the map

selection:deleted

Fired when the selection is deleted

 

selection:invalid

Fired when the selection is invalid

 

ownerlist:started

Fired when the owner list is being started to retrieve

 

ownerlist:cleared

Fired when the owner list is cleared

 

ownerlist:updated

Fired when the owner list is updated

Object containing the GeoJSON of the selection made on the map and selected cadastres

ownerlist:deleted

Fired when the owner list is deleted

 

neighborlist:cleared

Fired when the neighbor list is cleared

 

neighborlist:updated

Fired when the neighbor list is updated

Object containing the GeoJSON of the selection made on the map, selected cadastres and neighbor list selected plot

neighborlist:deleted

Fired when the neighbor list is deleted

 

neighborlist:maincadastreplotchosen

Fired when the main cadastre plot has been chosen for the neighbor list

Object containing the cadastre number

neighborlist:mainplotselected

Fired when the main plot is selected for the neighbor list

Object containing feature layer of the selected plot

neighborlist:mainplotsreset

Fired when the main plot is reset for the neighbor list

 

neighborlist:mainplotsshown

Fired when the main plots are shown for the neighbor list

Object containing feature layers of the shown plots

Methods

Method

Returns

Description

Method

Returns

Description

authenticate(<String> ambitaToken)

AmbitaMap

Tries to authenticate all the layers using the Ambita authorization token passed in and get GeoData token to be able to work with the map features. Fires tokenrequired if the passed in Ambita authorization token is not valid

showCadastre(<String> cadastreNumber, <Object> options?)

AmbitaMap

Calls GeoData query service using the cadastre number string (knr/gnr/bnr) passed in and shows the retrieved cadastre on the map, example: map.showCadastre('0301/1/1'). Specifying the callback option allows to work with the retrieved feature collection, but does not show the cadastre on the map

showMarkerLayer(<GeoJSON> feature, <Object> options?)

AmbitaMap

Uses the GeoJSON feature or feature collection passed in. The GeoJSON can be of any valid GeoJSON geometry. For custom markers on icons use feature.properties.icon = icon, icon can be a Font Awesome icon. To set a handler on clicking a feature use feature.properties.callback = callback where the specified callback is a function

enableSelectionControls()

void

Adds the selection controls to the map, only works if editable option is true

disableSelectionControls()

void

Removes the selection controls from the map, only works if editable option is true

clearAmbitaControls()

void

Removes the Ambita custom controls from the map

showFeatureLayer(<GeoJSON> feature, <String> layerName, <FeatureLayerOptions> options?)

AmbitaMap

Shows the passed in feature on the map

showFeatureLayers(<GeoJSON> featureCollection, <String> layerName, <FeatureLayerOptions> options?)

AmbitaMap

Shows the passed in feature collection on the map

showCadastreLayer(<GeoJSON> feature, <Object> options?)

AmbitaMap

Shows the passed in cadastre feature on the map

showCadastrePlotsLayer(<GeoJSON> feature, <Object> options?)

void

Shows cadastre plots layer using the cadastre number from the feature passed in

showMunicipalityLayer(<GeoJSON> featureCollection, <Boolean> fitBounds?)

void

Shows municipality layer using the municipality feature passed in

showMarkerClusterLayer(<GeoJSON> featureCollection, <String> layerName, <FeatureLayerOptions> options?)

AmbitaMap

Shows the passed in feature collection of markers as a marker cluster layer

showNeighborList(<String> cadastreNumber, <NeighborListOptions> options?)

void

Shows the neighbor list using the cadastre number passed in

showIcon(<GeoJSON> feature, <Object> options?)

AmbitaMap

Shows the passed in marker feature on the map

highlightFeatureLayer(<Object> featureLayer)

void

Adds the CSS class selection-hover-cadastre to the feature layer passed in

unhighlightFeatureLayer(<Object> featureLayer)

void

Removes the CSS class selection-hover-cadastre from the feature layer passed in

fitBoundsToGeoJSON(<GeoJSON> feature, <FeatureLayerOptions> options?)

void

Zooms the map to the feature layer passed in

clearFeatureLayer(<String> featureLayer)

void

Clears a feature layer added to the map by the name passed in

clearFeatureLayers()

void

Clears all feature layers added to the map

identifyFeature(<GeoJSON> feature, <Object> options)

AmbitaMap

Calls GeoData identify service using the feature passed in and shows the retrieved cadastre on the map. Specifying the callback option allows to work with the retrieved feature collection, but does not show the cadastre on the map

getRestApiForAuthentication()

String

Gets the currently used REST API address

fireTokenRequired()

void

Fires the tokenrequired event if number of unsuccessful retries has not exceeded maxRetries option, otherwise fires tokenfailed event

isFullscreen()

Boolean

Checks if the map is currently in fullscreen mode

geohashCenter()

String

Gets the geohash string for the current map center

geohashMoveTo(<String> geohash)

void

Zooms the map to the geohash string passed in

showNeighborListUsingPlotIds(<Number> mainPlotId, <Number[]> neighborPlotsIds, <Object> options?)

void

Calls the GeoData query service using the parameters passed in and shows the retrieved neighbor list on the map. Specifying the callback option allows to work with the retrieved feature collection, but does not show the neighbor list on the map

fetchMunicipalityPolygon(<String> municipalityCode, <Boolean> fitBounds?)

void

Calls GeoData query service using the municipality code passed in and shows the retrieved municipality on the map

getMunicipalityFromCenter()

Promise<Municipality[]>

Calls GeoData query service and gets the municipalities from the current map center

getMunicipalityFromPolygonFeature(<GeoJSON> feature)

Promise<Municipality[]>

Calls GeoData query service using the feature passed in and gets the municipalities containing the feature

Example usage of map.showMarkerLayer

To display markers on the map map.showMarkerLayer(features) should be called.

It is possible to do different types of actions when a feature is clicked on the map:

  • run a callback function

  • fire an event

  • show a popup

Run a callback function

The callback parameter should be set in feature properties.

Fire an event

The type parameter should be set in feature properties. This will fire a featureClick event which will contain the clicked feature

Show a popup

The popup and text parameters should be set in feature properties. Text can be any valid text or HTML.

Styling the map elements

Style the different elements (buttons, controls, etc.) shown on the map using plain CSS.

Identifier

Description

Identifier

Description

.leaflet-bar a

Style for buttons and other controls

.leaflet-bar a:hover

Style for buttons and other controls on hovering

.leaflet-bar .leaflet-control-zoom-in

Style for zoom in control

.leaflet-bar .leaflet-control-zoom-out

Style for zoom out control

CSS identifier

Style for the element using CSS identifier

Example stylesheet

Versioning

Stable releases are available here: https://static.ambita.com/ambita-map/

Beta releases are available here: https://beta-static.ambita.com/ambita-map/

The latest stable release is available here: https://static.ambita.com/ambita-map/latest/

Be aware of caching in the browser when using: https://static.ambita.com/ambita-map/latest/

To break the caching put a random query after the library path: https://static.ambita.com/ambita-map/latest/ambita-map.js?randomText