Search

Map

Map functions allow you to show chart items on a map. To access the map namespace, use chart.map(). See also the map event which is triggered by the chart.

Hides the Leaflet map that was displayed with the show function. Chart nodes with lat and lng properties are repositioned as specified by the transition setting. The speed of the transition depends on settings made with the options function. The chart triggers a map event at the start and end of the hide operation.

Note:

  • If the map is already hidden, or a show or hide transition is underway, this call has no effect.
  • Cannot be used while the chart's container is set to null.

To show the Leaflet map again, call show().

Returns Promise

A Promise.

Discovers whether the Leaflet map is currently shown.

When a show() transition is underway, isShown returns false until it is complete. When a hide() transition is underway, isShown returns true until it is complete.

Returns boolean

True if the map is currently shown, false otherwise.

Gets direct access to the underlying Leaflet map object. This allows you to use the Leaflet API directly, for example to add new layers to the map. The Leaflet map object is only returned when the map is shown. When the map is hidden, the underlying Leaflet map object is removed and this function returns null.

Refer to the relevant release version of the Leaflet API Reference for details of the Leaflet API.

Returns object

The Leaflet map object.

Converts a set of view coordinates to the exact latitude and longitude.

Parameters

x
required
number

The x position in view coordinates.

y
required
number

The y position in view coordinates.

Returns object

The geospatial coordinates of the specified point.

lat

required
number

The latitude in degrees that this node is positioned at on a Leaflet map. Should be in the range -90 to 90, but larger values will be rounded to ±90 respectively.

lng

required
number

The longitude in degrees that this node is positioned at on a Leaflet map. Should be in the range -180 to 180 but larger values will wrap at the antimeridian.

Sets or gets options for the Leaflet map. See Map Options.

chart.map().options({
  tiles: {
    url: 'http://example.com/path/{z}/{x}/{y}.png',
    attribution: 'Attribution text',
    minZoom: 4,
    maxZoom: 12,
    noWrap: false
  }
}).then(() => {
  // do more after options
});

Note: If you reference a Leaflet map tile URL or object that's on a different domain to the KeyLines library, your browser will display it, but won’t let KeyLines examine it or render it to a data URL. For details of how to fix this, see Cross-Origin Images (CORS).

Parameters

val
required

The options to set for the Leaflet map.

Returns object | Promise


Getter: The current map options.


Setter: A Promise object.

Displays a Leaflet map behind the chart. Chart nodes with lat and lng properties are moved to the correct position on the map, see the Map Position Object. Nodes without valid lat and lng properties will be hidden.

The speed of the transition and the appearance of the Leaflet map depend on settings made with the options function. The chart triggers a map event at the start and end of the show operation.

Note:

  • If the map is already shown, or a show or hide transition is underway, this call has no effect.
  • Cannot be used while the chart's container is set to null.
  • When calling chart.map().show(), the handMode option is automatically set to true.

To hide the map again, call chart.map().hide().

Returns Promise

A Promise.

Converts a set of latitude and longitude coordinates to the exact point in the view.

Parameters

lat
required
number

The latitude position of the point.

lng
required
number

The longitude position of the point.

Returns object

An object containing the view coordinates.

x

required
number

The horizontal coordinate.

y

required
number

The vertical coordinate.

Terms of use

These terms do not alter or supersede any existing agreements between you (or your employer) and us.

By accessing or using any Content you agree to be bound by these Terms of Use. Please review these terms carefully before using the website.

The contents of this website, including but not limited to any text, code samples, API references, schemas, interactive tools, and other materials (collectively, the 'Content'), are made available for informational and internal evaluation purposes only. All intellectual property rights in the Content are reserved. No licence is granted to use the Content for any commercial purpose, or to copy, distribute, modify, reverse-engineer, or incorporate any part of the Content into any product or service, without our prior written consent.

This Content is provided “as is” and “as available,” without any representations, warranties, or guarantees of any kind, whether express or implied, including but not limited to implied warranties of merchantability, fitness for a particular purpose, non-infringement, or accuracy. To the fullest extent permitted by applicable law, we expressly exclude and disclaim all implied warranties, conditions, and other terms that might otherwise be implied.

We disclaim all liability for any loss or damage, whether direct, indirect, incidental, consequential, or otherwise, arising from any reliance placed on the Content or from your use of it, to the fullest extent permitted by applicable law. By continuing to access or use the Content, you acknowledge and agree to these terms.