Class: MapView

Highcharts. MapView

new MapView(chart, options)

The map view handles zooming and centering on the map, and various client-side projection capabilities.

On a chart instance, the map view is available as chart.mapView.

Parameters:
Name Type Description
chart Highcharts.Chart

The Chart instance

options Highcharts.MapViewOptions

MapView options

Members

<readonly> center :LonLatArray

The current center of the view in terms of [longitude, latitude].

Type:
  • LonLatArray

<readonly> zoom :number

The current zoom level of the view.

Type:
  • number

Methods

fitToBounds(bounds [, padding] [, redraw] [, animation])

Fit the view to given bounds

Parameters:
Name Type Argument Default Description
bounds Object

Bounds in terms of projected units given as { x1, y1, x2, y2 }. If not set, fit to the bounds of the current data set

padding number | string <optional>
0

Padding inside the bounds. A number signifies pixels, while a percentage string (like 5%) can be used as a fraction of the plot area size.

redraw boolean <optional>
true

Whether to redraw the chart immediately

animation boolean | Partial.<Highcharts.AnimationOptionsObject> <optional>

What animation to use for redraw

pixelsToProjectedUnits(pos)

Convert pixel position to projected units

Parameters:
Name Type Description
pos Highcharts.PositionObject

The position in pixels

Returns:
Highcharts.PositionObject .

The position in projected units

projectedUnitsToPixels(pos)

Convert projected units to pixel position

Parameters:
Name Type Description
pos Highcharts.PositionObject

The position in projected units

Returns:
Highcharts.PositionObject .

The position in pixels

setView(center, zoom [, redraw] [, animation])

Set the view to given center and zoom values.

Parameters:
Name Type Argument Default Description
center Highcharts.LonLatArray | undefined

The center point

zoom number

The zoom level

redraw boolean <optional>
true

Whether to redraw immediately

animation boolean | Partial.<Highcharts.AnimationOptionsObject> <optional>

Animation options for the redraw

Try it

update(options [, redraw] [, animation])

Update the view with given options

Parameters:
Name Type Argument Default Description
options Partial.<Highcharts.MapViewOptions>

The new map view options to apply

redraw boolean <optional>
true

Whether to redraw immediately

animation boolean | Partial.<Highcharts.AnimationOptionsObject> <optional>

The animation to apply to a the redraw

zoomBy( [howMuch] [, coords] [, chartCoords] [, animation])

Zoom the map view by a given number

Parameters:
Name Type Argument Description
howMuch number | undefined <optional>

The amount of zoom to apply. 1 zooms in on half the current view, -1 zooms out. Pass undefined to zoom to the full bounds of the map.

coords Highcharts.LonLatArray <optional>

Optional map coordinates to keep fixed

chartCoords Array.<number> <optional>

Optional chart coordinates to keep fixed, in pixels

animation boolean | Partial.<Highcharts.AnimationOptionsObject> <optional>

The animation to apply to a the redraw