Class

Map

kiss.ux.Map(config)

The Map derives from Component.

Encapsulates original OpenLayers inside a KissJS UI component: https://openlayers.org/

Current version of local OpenLayers: 10.0.0

Constructor

# new Map(config)

Its a Custom Web Component. Do not use the constructor directly with the new keyword. Instead, use one of the 3 following methods:

Create the Web Component and call its init method:

const myMap = document.createElement("a-map").init(config)

Or use the shorthand for it:

const myMap = createMap({
 width: 300,
 height: 200,
 longitude: 2.3483915,
 latitude: 48.8534951,
 zoom: 15
})

myMap.render()

Or directly declare the config inside a container component:

const myPanel = createPanel({
  title: "My panel",
  items: [
      {
         type: "map",
         width: 300,
         height: 200,
         longitude: 2.3483915,
         latitude: 48.8534951,
         zoom: 15
      }
  ]
})
myPanel.render()

You can define a map from a geolocation or an address:

const myMapFromGeoloc = createMap({
 longitude: 2.3483915,
 latitude: 48.8534951,
})

const myMapFromAddress = createMap({
 address: "10 Downing Street, London",
})

For now, the geoencoding is done with Nominatim, which is a free service but has limitations when it comes to the accuracy of the address street number.

Parameters:
Name Type Attributes Description
config object
longitude float <optional>

Longitude

latitude float <optional>

Latitude

address string <optional>

Address

zoom integer <optional>

Zoom level (default 10)

width integer <optional>

Width in pixels

height integer <optional>

Height in pixels

showMarker boolean <optional>

Set false to hide the marker. Default is true.

useCDN boolean <optional>

Set to false to use the local version of OpenLayers. Default is true.

View Source client/ux/map/map.js, line 28

this

Generated markup

<a-map class="a-map">
 <div class="ol-viewport"></div>
</a-map>

Methods

# addGeoMarker()

Add a marker on the map at the current geolocation

View Source client/ux/map/map.js, line 256

this

# async setAddress(address) → {object}

Set a new address on the map

IMPORTANT: this methods uses Nominatim for geocoding, which is a free service but has limitations when it comes to the accuracy address street number.

Parameters:
Name Type Description
address string

View Source client/ux/map/map.js, line 207

The geolocation object: {longitude, latitude}

object
Example
myMap.setAddress("10 Downing Street, London")

# setGeolocation(geoloc) → {object}

Set a new geolocation on the map

Parameters:
Name Type Description
geoloc object
longitude number
latitude number

View Source client/ux/map/map.js, line 239

The geolocation object

object
Example
myMap.setGeolocation({
 longitude: 2.3483915,
 latitude: 48.8534951
})

# setHeight(height)

Set the height of the map

Parameters:
Name Type Description
height number

View Source client/ux/map/map.js, line 317

this

# setWidth(width)

Set the width of the map

Parameters:
Name Type Description
width number

View Source client/ux/map/map.js, line 306

this

# setZoom(zoom)

Set a new zoom level on the map

Parameters:
Name Type Description
zoom number

View Source client/ux/map/map.js, line 294

this

Example
myMap.setZoom(15)