WorldMap

new WorldMap

Creates map, draws paths, binds events.
Parameters:
Name Type Description
params Object Parameters to initialize map with.
Properties
Name Type Description
map String Name of the map in the format territory_proj_lang where territory is a unique code or name of the territory which the map represents (ISO 3166 alpha 2 standard is used where possible), proj is a name of projection used to generate representation of the map on the plane (projections are named according to the conventions of proj4 utility) and lang is a code of the language, used for the names of regions.
backgroundColor String Background color of the map in CSS format.
zoomOnScroll Boolean When set to true map could be zoomed using mouse scroll. Default value is true.
zoomMax Number Indicates the maximum zoom ratio which could be reached zooming the map. Default value is 8.
zoomMin Number Indicates the minimum zoom ratio which could be reached zooming the map. Default value is 1.
zoomStep Number Indicates the multiplier used to zoom map with +/- buttons. Default value is 1.6.
regionsSelectable Boolean When set to true regions of the map could be selected. Default value is false.
regionsSelectableOne Boolean Allow only one region to be selected at the moment. Default value is false.
markersSelectable Boolean When set to true markers on the map could be selected. Default value is false.
markersSelectableOne Boolean Allow only one marker to be selected at the moment. Default value is false.
regionStyle Object Set the styles for the map's regions. Each region or marker has four states: initial (default state), hover (when the mouse cursor is over the region or marker), selected (when region or marker is selected), selectedHover (when the mouse cursor is over the region or marker and it's selected simultaneously). Styles could be set for each of this states. Default value for that parameter is:
{
  initial: {
    fill: 'white',
    "fill-opacity": 1,
    stroke: 'none',
    "stroke-width": 0,
    "stroke-opacity": 1
  },
  hover: {
    "fill-opacity": 0.8
  },
  selected: {
    fill: 'yellow'
  },
  selectedHover: {
  }
}
markerStyle Object Set the styles for the map's markers. Any parameter suitable for regionStyle could be used as well as numeric parameter r to set the marker's radius. Default value for that parameter is:
{
  initial: {
    fill: 'grey',
    stroke: '#505050',
    "fill-opacity": 1,
    "stroke-width": 1,
    "stroke-opacity": 1,
    r: 5
  },
  hover: {
    stroke: 'black',
    "stroke-width": 2
  },
  selected: {
    fill: 'blue'
  },
  selectedHover: {
  }
}
markers Object | Array Set of markers to add to the map during initialization. In case of array is provided, codes of markers will be set as string representations of array indexes. Each marker is represented by latLng (array of two numeric values), name (string which will be show on marker's label) and any marker styles.
series Object Object with two keys: markers and regions. Each of which is an array of series configs to be applied to the respective map elements. See DataSeries description for a list of parameters available.
focusOn Object | String This parameter sets the initial position and scale of the map viewport. It could be expressed as a string representing region which should be in focus or an object representing coordinates and scale to set. For example to focus on the center of the map at the double scale you can provide the following value:
{
  x: 0.5,
  y: 0.5,
  scale: 2
}
selectedRegions Array | Object | String Set initially selected regions.
selectedMarkers Array | Object | String Set initially selected markers.
onRegionLabelShow Function (Event e, Object label, String code) Will be called right before the region label is going to be shown.
onRegionOver Function (Event e, String code) Will be called on region mouse over event.
onRegionOut Function (Event e, String code) Will be called on region mouse out event.
onRegionClick Function (Event e, String code) Will be called on region click event.
onRegionSelected Function (Event e, String code, Boolean isSelected, Array selectedRegions) Will be called when region is (de)selected. isSelected parameter of the callback indicates whether region is selected or not. selectedRegions contains codes of all currently selected regions.
onMarkerLabelShow Function (Event e, Object label, String code) Will be called right before the marker label is going to be shown.
onMarkerOver Function (Event e, String code) Will be called on marker mouse over event.
onMarkerOut Function (Event e, String code) Will be called on marker mouse out event.
onMarkerClick Function (Event e, String code) Will be called on marker click event.
onMarkerSelected Function (Event e, String code, Boolean isSelected, Array selectedMarkers) Will be called when marker is (de)selected. isSelected parameter of the callback indicates whether marker is selected or not. selectedMarkers contains codes of all currently selected markers.
onViewportChange Function (Event e, Number scale) Triggered when the map's viewport is changed (map was panned or zoomed).

Methods

addMarker

Add one marker to the map.
Parameters:
Name Type Description
key String Marker unique code.
marker Object Marker configuration parameters.
seriesData Array Values to add to the data series.

addMarkers

Add set of marker to the map.
Parameters:
Name Type Description
markers Object | Array Markers to add to the map. In case of array is provided, codes of markers will be set as string representations of array indexes.
seriesData Array Values to add to the data series.

clearSelectedMarkers

Remove the selected state from all the currently selected markers.

clearSelectedRegions

Remove the selected state from all the currently selected regions.

getMapObject

Return the instance of WorldMap. Useful when instantiated as a jQuery plug-in.
Returns:
Type
WorldMap

getRegionName

Return the name of the region by region code.
Returns:
Type
String

getSelectedMarkers

Return the codes of currently selected markers.
Returns:
Type
Array

getSelectedRegions

Return the codes of currently selected regions.
Returns:
Type
Array

latLngToPoint

Converts coordinates expressed as latitude and longitude to the coordinates in pixels on the map.
Parameters:
Name Type Description
lat Number Latitide of point in degrees.
lng Number Longitude of point in degrees.

pointToLatLng

Converts cartesian coordinates into coordinates expressed as latitude and longitude.
Parameters:
Name Type Description
x Number X-axis of point on map in pixels.
y Number Y-axis of point on map in pixels.

remove

Gracefully remove the map and and all its accessories, unbind event handlers.

removeAllMarkers

Remove all markers from the map.

removeMarkers

Remove some markers from the map.
Parameters:
Name Type Description
markers Array Array of marker codes to be removed.

reset

Reset all the series and show the map with the initial zoom.

setBackgroundColor

Set background color of the map.
Parameters:
Name Type Description
backgroundColor String Background color in CSS format.

setFocus

Set the map's viewport to the specific point and set zoom of the map to the specific level. Point and zoom level could be defined in two ways: using the code of some region to focus on or a central point and zoom level as numbers.
Parameters:
Name Type Description
scale|regionCode|regionCodes Number | String | Array If the first parameter of this method is a string or array of strings and there are regions with the these codes, the viewport will be set to show all these regions. Otherwise if the first parameter is a number, the viewport will be set to show the map with provided scale.
centerX Number Number from 0 to 1 specifying the horizontal coordinate of the central point of the viewport.
centerY Number Number from 0 to 1 specifying the vertical coordinate of the central point of the viewport.

setSelectedMarkers

Set or remove selected state for the markers.
Parameters:
Name Type Description
keys String | Array | Object If String or Array the marker(s) with the corresponding code(s) will be selected. If Object was provided its keys are codes of markers, state of which should be changed. Selected state will be set if value is true, removed otherwise.

setSelectedRegions

Set or remove selected state for the regions.
Parameters:
Name Type Description
keys String | Array | Object If String or Array the region(s) with the corresponding code(s) will be selected. If Object was provided its keys are codes of regions, state of which should be changed. Selected state will be set if value is true, removed otherwise.

setSize

Synchronize the size of the map with the size of the container. Suitable in situations where the size of the container is changed programmatically or container is shown after it became visible.