Create a div to attach the map to. Pass in the div id and width size (in pixels) when creating a map in your JavaScript. Create the map by creating a MapConnections
object.
To get the CSS filter to change the maps image to any color, use this tool: https://codepen.io/sosuke/pen/Pjoqqp
new MapConnections({
divId: string,
width: int,
whiteMap: bool? = false,
mapType: string? = "outline" : "outline" | "outlineFilled" | "filled",
imgFilter: string? = "" : CSS Filter,
})
divId
: The div's ID from HTML to attach the map to.
width
: The width of the map (in pixels). The height will automatically be sized based on the ratio of the map.
whiteMap
: The color of the map image to white, if set to true.
mapType
: The type of map to use for the image. There are 3 different maps: "outline" | "outlineFilled" | "filled"
imgFilter
: The CSS filter to apply to the map image. Useful for changing the maps color. To get the CSS filter to change the maps image to any color, use this tool: https://codepen.io/sosuke/pen/Pjoqqp.
All the functions available to use, called on the instance of the map class.
addMarker
MapConnections.addMarker({
top: double,
left: double,
title: string?,
description: string?,
color: string? (color),
})
top
: The distance relative from the top of the map image to place the marker.
left
: The distance relative from the left of the map image to place the marker.
title
: The title to show when the user hovers over the marker, and to show in the legend.
description
: The description to show when the user hovers over the marker.
color
: The color to set the marker line to. Follows CSS standards.
addMarkerApproxLongLat
MapConnections.addMarkerApproxLongLat({
longitude: double,
latitude: double,
title: string?,
description: string?,
color: string? (color),
})
longitude
: The latitude measurement for the marker point.
latitude
: The longitude measurement for the marker point.
title
: The title to show when the user hovers over the marker, and to show in the legend.
description
: The description to show when the user hovers over the marker.
color
: The color to set the marker line to. Follows CSS standards.
setMarkerInfo
MapConnections.setMarkerInfo({
markerIndex: int,
title: string?,
description: string?,
})
markerIndex
: The index of the marker in the marker
list of marker objects.
title
: The title to show when the user hovers over the marker, and to show in the legend.
description
: The description to show when the user hovers over the marker.
setMarkerColor
MapConnections.setMarkerColor({
markerIndex: int,
color: string (color),
})
markerIndex
: The index of the marker in the marker
list of marker objects.
color
: The color to set the marker line to. Follows CSS standards.
addConnection
MapConnections.addConnection({
markerIndexStart: int,
markerIndexEnd: int,
animation: bool? = true,
iconId: string? : div ID for custom icon,
animationDuration: int? = 2500,
rotateIcon: bool? = false,
width: int? = 5,
title: string?,
description: string?,
color: string? (color),
iconColor: string? (color),
})
markerIndexStart
: The first index as the starting point for the connection. The index of the marker in the markers
list of marker objects.
markerIndexEnd
: The last index as the ending point for the connection. The index of the marker in the markers
list of marker objects.
animation
: Determines if a dot or icon should be animated along the connection line.
iconId
: The custom icon div's ID from HTML.
animationDuration
: The length of the icons animation along the connection path in milliseconds.
rotateIcon
: Determines if the icon should be rotated to face along the direction of the connection line.
width
: How thick the connection line should be.
title
: The title to show when the user hovers over the connection, and to show in the legend.
description
: The description to show when the user hovers over the connection.
color
: The color to set the connection line to. Follows CSS standards.
iconColor
: The color to set the connection line's animated dot icon to. Follows CSS standards.
setConnectionInfo
MapConnections.setConnectionInfo({
connectionIndex: int,
title: string?,
description: string?,
})
connectionIndex
: The index of the connection in the connections
list of connection objects.
title
: The title to show when the user hovers over the connection, and to show in the legend.
description
: The description to show when the user hovers over the connection.
setConnectionColor
MapConnections.setConnectionColor({
connectionIndex: int,
color: string (color),
})
connectionIndex
: The index of the connection in the connections
list of connection objects.
color
: The color to set the connection line to. Follows CSS standards.
setConnectionIconColor
MapConnections.setConnectionIconColor({
connectionIndex: int,
color: string (color),
})
connectionIndex
: The index of the connection in the connections
list of connection objects.
color
: The color to set the icon to. Follows CSS standards.
Show a legend underneath the map. The labels are based off the titles specified for markers and connections. The colors are based off the colors specified for markers and connections.
showLegend
MapConnections.showLegend()
startAnimation
MapConnections.startAnimation({
connectionIndex: int,
})
connectionIndex
: The index of the connection in the connections
list of connection objects.
stopAnimation
MapConnections.stopAnimation({
connectionIndex: int,
})
connectionIndex
: The index of the connection in the connections
list of connection objects.
Map customizations should be set before any markers or connections are added.
setBackgroundColor
MapConnections.setBackgroundColor({
color: string (color),
})
color
: The color to set the background to. Follows CSS standards.
setCropSize
MapConnections.setCropSize({
width: int,
height: int,
})
width
: The width to set the crop size to, of the map.
height
: The height to set the crop size to, of the map.
setMapShift
MapConnections.setMapShift({
x: int,
y: int,
})
x
: The amount to shift by to the right.
y
: The amount to shift by to the bottom.
setMapZoom
MapConnections.setMapZoom({
zoom: double,
})
zoom
: The amount to zoom the map image in.
These styles can be changed using CSS and the respective selector in HTML.
.map-marker-icon
The default styles are listed below, and can be changed by overwriting the respective CSS selector to style according to preferences.
.map-marker-icon{
transform: translateY(-14px) rotate(-45deg);
border-radius: 50% 50% 50% 0;
background-color: white;
width: 19px;
height: 19px;
box-shadow: 3px 2px 7px 2px #46464773;
text-align: center;
font-weight: 600;
text-indent: 0;
}
.map-marker-icon
The default styles are listed below, and can be changed by overwriting the respective CSS selector to style according to preferences.
.map-connection{
height:5px;
background-color: #ffffff;
z-index: 1;
border-radius: 10px;
box-shadow: 3px 1px 7px 2px #46464773;
transition: transform 0.5s;
cursor: pointer;
text-indent: 0;
text-align: center;
font-weight: 600;
text-shadow: 0px 0px 4px white;
font-size: 20px;
}
.map-marker-label
The default styles are listed below, and can be changed by overwriting the respective CSS selector to style according to preferences.
.map-marker-label{
pointer-events: none;
background-color: #ffffff;
color: black;
text-align: center;
border-radius: 7px;
font-size: 20px;
position: absolute;
z-index: 5;
text-indent: 0;
transition: opacity 0.5s;
transform: translateX(calc(-50% + 10px)) translateY(-50%) scale(0.5);
width: 200px;
padding:5px;
opacity:0;
}
.map-marker-label p{
margin:10px;
margin-top: 0px;
}
.map-marker-label h3{
margin:10px;
margin-bottom: 5px;
}
#map-connection-popup
The default styles are listed below, and can be changed by overwriting the respective CSS selector to style according to preferences.
#map-connection-popup{
pointer-events: none;
background-color: #ffffff;
color: black;
text-align: center;
border-radius: 7px;
position: absolute;
z-index: 5;
text-indent: 0;
padding: 5px;
box-shadow: 3px 1px 7px 2px #46464773;
opacity: 0;
transition: opacity 0.25s;
font-size: 16px;
max-width: 400px;
}
#map-connection-popup p{
margin:10px;
margin-top: 0px;
}
#map-connection-popup h3{
margin:10px;
margin-bottom: 5px;
}
.legend-box
The default styles are listed below, and can be changed by overwriting the respective CSS selector to style according to preferences.
.legend-box{
border-radius: 10px;
background-color: #ffffff;
box-shadow: 2px 5px 5px 2px #46464748;
padding:15px;
display: inline-block;
}
markers
To get a list of all the generated marker objects, access the class variable markers
(list of objects).
MapConnections.markers
connections
To get a list of all the generated connection objects, access the class variable connections
(list of objects).
MapConnections.connections
showAllMarkerIndices
MapConnections.showAllMarkerIndices()
showMarkerIndex
MapConnections.showMarkerIndex({
markerIndex: int,
})
markerIndex
: The index of the marker in the markers
list of marker objects.
showAllConnectionIndices
MapConnections.showAllConnectionIndices()
showConnectionIndex
MapConnections.showConnectionIndex({
connectionIndex: int,
})
connectionIndex
: The index of the connection in the connections
list of connection objects.
hideAllMarkerIndices
MapConnections.hideAllMarkerIndices()
hideMarkerIndex
MapConnections.hideMarkerIndex({
markerIndex: int,
})
markerIndex
: The index of the marker in the markers
list of marker objects.
hideAllConnectionIndices
MapConnections.hideAllConnectionIndices()
hideConnectionIndex
MapConnections.hideConnectionIndex({
connectionIndex: int,
})
connectionIndex
: The index of the connection in the connections
list of connection objects.