# 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 of `MapChart`, the map view is available as `chart.mapView`.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `chart` | Highcharts.MapChart | The MapChart 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 the given bounds.

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `bounds` | Highcharts.MapBounds |  |  | 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` | Highcharts.MapViewPaddingType | <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

#### lonLatToPixels(lonLat)

  Convert map coordinates in longitude/latitude to pixels

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `lonLat` | Highcharts.MapLonLatObject | The map coordinates

  Since:
    - 10.0.0

  ##### Returns:

  Highcharts.PositionObject | undefined .

  The pixel position

#### lonLatToProjectedUnits(lonLat)

  Get projected units from longitude/latitude. Insets are accounted for. Returns an object with x and y values corresponding to positions on the projected plane.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `lonLat` | Highcharts.MapLonLatObject | Coordinates.

  Since:
    - 10.0.0

  ##### Requires:

  - module:modules/map

  ##### Returns:

  Highcharts.ProjectedXY .

  X and Y coordinates in terms of projected values

  ##### Try it

  - Find a point from lon/lat.

#### pixelsToLonLat(pos)

  Convert pixel position to longitude and latitude.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pos` | Highcharts.PositionObject | The position in pixels

  Since:
    - 10.0.0

  ##### Returns:

  Highcharts.MapLonLatObject | undefined .

  The map coordinates

#### 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

#### projectedUnitsToLonLat(point)

  Calculate longitude/latitude values for a point or position. Returns an object with the numeric properties `lon` and `lat`.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `point` | Highcharts.Point | Highcharts.ProjectedXY | A `Point` instance or anything containing `x` and `y` properties with numeric values.

  Since:
    - 10.0.0

  ##### Requires:

  - module:modules/map

  ##### Returns:

  Highcharts.MapLonLatObject | undefined .

  An object with `lat` and `lon` properties.

  ##### Try it

  - Advanced lat/lon demo.

#### 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

#### recommendMapView(chart, mapDataArray [, update])

  Calculate and set the recommended map view based on provided map data from series.

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `chart` | Highcharts.Chart |  |  | Chart object
  `mapDataArray` | Array.<(MapDataType|undefined)> |  |  | Array of map data from all series.
  `update` | boolean | <optional> | false | Whether to update the chart with recommended map view.

  Since:
    - 11.4.0

  ##### Requires:

  - module:modules/map

  ##### Returns:

  Highcharts.MapViewOptions | undefined .

  Best suitable map view.

#### 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

  - Set the view programmatically.

#### 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