Maps

Methods

ZingChart maps have their own custom methods. Use the maps property in the following format to access them.

zingcharts.maps.methodName(); Copy

getInfo()

This method returns information about the map.

zingchart.maps.getInfo('mapName'); Copy

It accepts the following parameters:

ParameterTypeDescription
mapNameStringThe name of the map.

getItems()

This method returns a list of the map items.

zingchart.maps.getItems('mapName'); Copy

It accepts the following parameters:

ParameterTypeDescription
mapNameStringThe name of the map.

getItemInfo()

This method returns information about the specified map item.

zingchart.maps.getItemInfo('mapName', 'itemName'); Copy

It accepts the following parameters:

ParameterTypeDescription
mapNameStringThe name of the map.
itemNameStringThe name of the map item.

getLonLat()

This method returns the corresponding longitude and latitude coordinates of the specified x and y positions.

zingchart.maps.getLonLat('mapName', [x, y]); Copy

It accepts the following parameters:

ParameterTypeDescription
mapNameStringThe name of the map.
[...]StringAn array that accepts two number values: the x and y positions, respectively.

getXY()

This method returns the corresponding x and y positions of the specified longitude and latitude coordinates.

zingchart.maps.getXY('mapName', [lon, lat]); Copy

It accepts the following parameters:

ParameterTypeDescription
mapNameStringThe name of the map.
[...]StringAn array that accepts two number values: the longitude and latitude coordinates, respectively.

loadGeoJSON()

This method allows you to create maps from outside GeoJSON files.

Note: It also requires you to explicitly load the module: maps-geojson.

zingchart.maps.loadGeoJSON({...}); Copy

It accepts an object with the following properties:

PropertyTypeDescription
idStringThe name of the custom map..
urlStringThe map file source.
mappingsObjectAllows you to map property names from the GeoJSON file to ZingChart.
stylingObjectAllows you to style the map.
callbackFunctionRepresents the function that renders the map.

viewAll()

This method allows you to view the entire map.

zingchart.maps.viewAll('mapName'); Copy

It accepts the following parameters:

ParameterTypeDescription
mapNameStringThe name of the map.

zoomIn()

This method allows you to zoom in on the map.

zingchart.maps.zoomIn('mapName'); Copy

It accepts the following parameters:

ParameterTypeDescription
mapNameStringThe name of the map.

zoomOut()

This method allows you to zoom out on the map.

zingchart.maps.zoomOut('mapName'); Copy

It accepts the following parameters:

ParameterTypeDescription
mapNameStringThe name of the map.

zoomTo()

This method allows you to zoom to a specified area on the map.

Note: As of Build 2.6.0, this method does not work on Windows.

zingchart.maps.zoomTo('mapName', {...}); Copy

It accepts the following parameters:

ParameterTypeDescription
mapNameStringThe name of the map.
{...}Object

An object that accepts the following properties:

  • zoom
  • offsetX
  • offsetY
zingchart.maps.zoomToItem('mapName', 'itemName');

It accepts the following parameters:

ParameterTypeDescription
mapNameStringThe name of the map.
itemNameStringThe name of the map item.