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
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
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(), thehandModeoption 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
Returns
object
An object containing the view coordinates.