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 boundsHighcharts.MapBounds Bounds in terms of projected units given as
{ x1, y1, x2, y2 }. If not set, fit to the bounds of the current data setpaddingHighcharts.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.redrawboolean <optional>
true Whether to redraw the chart immediately
animationboolean | Partial.<Highcharts.AnimationOptionsObject> <optional>
What animation to use for redraw
-
lonLatToPixels(lonLat)
-
Convert map coordinates in longitude/latitude to pixels
Parameters:
Name Type Description lonLatHighcharts.MapLonLatObject The map coordinates
- Since:
-
- 10.0.0
Returns:
-
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 lonLatHighcharts.MapLonLatObject Coordinates.
- Since:
-
- 10.0.0
Requires:
- module:modules/map
Returns:
Highcharts.ProjectedXY .X and Y coordinates in terms of projected values
Try it
-
pixelsToLonLat(pos)
-
Convert pixel position to longitude and latitude.
Parameters:
Name Type Description posHighcharts.PositionObject The position in pixels
- Since:
-
- 10.0.0
Returns:
-
pixelsToProjectedUnits(pos)
-
Convert pixel position to projected units
Parameters:
Name Type Description posHighcharts.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
lonandlat.Parameters:
Name Type Description pointHighcharts.Point | Highcharts.ProjectedXY A
Pointinstance or anything containingxandyproperties with numeric values.- Since:
-
- 10.0.0
Requires:
- module:modules/map
Returns:
Try it
-
projectedUnitsToPixels(pos)
-
Convert projected units to pixel position
Parameters:
Name Type Description posHighcharts.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 chartHighcharts.Chart Chart object
mapDataArrayArray.<(MapDataType|undefined)> Array of map data from all series.
updateboolean <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 centerHighcharts.LonLatArray | undefined The center point
zoomnumber The zoom level
redrawboolean <optional>
true Whether to redraw immediately
animationboolean | 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 optionsPartial.<Highcharts.MapViewOptions> The new map view options to apply
redrawboolean <optional>
true Whether to redraw immediately
animationboolean | 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 howMuchnumber | undefined <optional>
The amount of zoom to apply. 1 zooms in on half the current view, -1 zooms out. Pass
undefinedto zoom to the full bounds of the map.coordsHighcharts.LonLatArray <optional>
Optional map coordinates to keep fixed
chartCoordsArray.<number> <optional>
Optional chart coordinates to keep fixed, in pixels
animationboolean | Partial.<Highcharts.AnimationOptionsObject> <optional>
The animation to apply to a the redraw