Skip to content
sfairgrieve edited this page Aug 13, 2014 · 4 revisions

The framework adds several new marker types geared towards dynamic data visualization. See the Markers example for an illustration of each of these markers.

L.MapMarker

Creates an SVG-based map marker, similar to the default Leaflet image-based marker but fully customizable using the basic L.Path properties

Map Marker

Usage

L.MapMarker(<LatLng> LatLng, <Marker options> options?);

var marker = new L.MapMarker(new L.LatLng(0, 0), {
	radius: 10,
	// L.Path style options
	...
});

map.addLayer(marker);

Options

numberOfSides

Type: Number

Default: 3

If an inner radius is specified, then the marker will have a hole in the center. This property determines the shape of the hole.

rotation

Type: Number

Default: 0

If an inner radius is specified, this controls the rotation of the hole in the center.

radius OR radiusX, radiusY

Type: Number

Default: 10

The radius of the circular part of the marker, also adjusts the height of the marker

innerRadius OR innerRadiusX, innerRadiusY

Type: Number

Default: null

The inner radius of the marker hole in pixels.

imageCircleUrl

Type: String

Default: null

The URL of an image to display on the marker. This will be displayed in the main circular area of the marker.

L.RegularPolygonMarker

Creates an N-sided marker

Regular Polygons

Usage

L.RegularPolygonMarker(<LatLng> LatLng, <Marker options> options?);

var marker = new L.RegularPolygonMarker(new L.LatLng(0, 0), {
	numberOfSides: 3,
	rotation: 60.0,
	radius: 10,
	// L.Path style options
	...
});

map.addLayer(marker);

Options

numberOfSides

Type: Number

Default: 3

This property determines the shape of the marker.

rotation

Type: Number

Default: 0

If an inner radius is specified, this controls the rotation of the hole in the center.

radius OR radiusX, radiusY

Type: Number

Default: 10

The radius of the circular part of the marker, also adjusts the height of the marker

innerRadius OR innerRadiusX, innerRadiusY

Type: Number

Default: null

The inner radius of the marker hole in pixels.

imageCircleUrl

Type: String

Default: null

The URL of an image to display on the marker. This will be displayed in the main circular area of the marker.

L.StarMarker

Star Marker

Creates a star-shaped marker with N-points

Usage

L.StarMarker(<LatLng> LatLng, <StarMarker options> options?);

Options (in addition to the L.RegularPolygonMarker options defined above)

numberOfPoints

Type: Number

Default: 5

The number of points the star should have

ChartMarkers

Bar Chart MarkerRadial Bar Chart MarkerPie Chart MarkerCoxcomb Chart MarkerStacked Regular Polygon MarkerRadial Meter Marker

Display dynamic charts (bar chart, radial bar chart, pie chart, coxcomb chart, etc.) as markers

Usage

L.BarChartMarker(<LatLng> LatLng, <Chart options> options?); L.RadialBarChartMarker(<LatLng> LatLng, <Chart options> options?); L.PieChartMarker(<LatLng> LatLng, <Chart options> options?); L.CoxcombChartMarker(<LatLng> LatLng, <Chart options> options?); L.StackedRegularPolygonMarker(<LatLng> LatLng, <Chart options> options?); L.RadialMeterMarker(<LatLng> LatLng, <Chart options> options?);

var options = {
	data: {
		'dataPoint1': Math.random() * 20,
		'dataPoint2': Math.random() * 20,
		'dataPoint3': Math.random() * 20,
		'dataPoint4': Math.random() * 20
	},
	chartOptions: {
		'dataPoint1': {
			fillColor: '#FEE5D9',
			minValue: 0,
			maxValue: 20,
			maxHeight: 20,
			displayText: function (value) {
				return value.toFixed(2);
			}
		},
		'dataPoint2': {
			fillColor: '#FCAE91',
			minValue: 0,
			maxValue: 20,
			maxHeight: 20,
			displayText: function (value) {
				return value.toFixed(2);
			}
		},
		'dataPoint3': {
			fillColor: '#FB6A4A',
			minValue: 0,
			maxValue: 20,
			maxHeight: 20,
			displayText: function (value) {
				return value.toFixed(2);
			}
		},
		'dataPoint4': {
			fillColor: '#CB181D',
			minValue: 0,
			maxValue: 20,
			maxHeight: 20,
			displayText: function (value) {
				return value.toFixed(2);
			}
		}
	},
	weight: 1,
	color: '#000000',
	... // Other L.Path style options
}

var barChartMarker = new L.BarChartMarker(new L.LatLng(0, 0), options);

Options (in addition to the L.Path style options)

data

Type: Object

Default: null

A set of key/value pairs that provides a data value for each property displayed by the marker

chartOptions

Type: Object

Default: null

A set of key/value pairs that defines the options associated with each data property displayed by the marker.

backgroundStyle (L.RadialMeterMarker)

Type: Object

Default: L.Path object with a semi-transparent gray fill and stroke

An object of L.Path style options that will be used to style the background area of the chart. Set this to null or false to prevent a background from being displayed.

L.Callout

Used for annotating markers, lines, and polygons. Callouts include a line and associated icon (L.Icon or L.DivIcon).

Usage

L.Callout(<LatLng> latlng, <Callout options> options?);

var callout = new L.Callout(new L.LatLng(0.0, 0.0), {
	arrow: true,
	numberOfSides: 3,
	radius: 8,
	icon: new L.DivIcon(...),
	direction: L.CalloutLine.DIRECTION.NE,
	lineStyle: L.CalloutLine.LINESTYLE.ARC,
	size: new L.Point(50, 50),
	weight: 2,
	fillOpacity: 1.0,
	color: '#FFFFFF',
	fillColor: '#FFFFFF'
});

map.addLayer(callout);

Options (in addition to L.Path style options)

arrow

Type: Boolean

Default: true

true/false - whether or not an arrow should be added to the end of the callout line

numberOfSides

Type: Number

Default: 3

The number of sides the arrow at the end of the callout line will have.

radius

Type: Number

Default: 6

The radius of the arrow that will be displayed at the end of the callout line

icon

Type: Object

Default: null

An L.Icon or L.DivIcon object that will be displayed at the end of the callout line

direction

Type: String

Default: 'ne'

The quadrant in which the callout will be placed: 'ne', 'se', 'sw', 'nw'. Use L.CalloutLine.DIRECTION properties (NE, SE, SW, NW) to specify this

lineStyle

Type: String

Default: 'angle'

The style of the associated callout line: 'arc', 'angle', 'straight'. Use L.CalloutLine.LINESTYLE properties (ARC, ANGLE, STRAIGHT) to specify this. 'arc' displays a curved line, 'angle' displays an angled line, and 'straight' displays a straight line from the annotation point to the associated icon.

size

Type: Object

Default: L.Point(60, 30)

The bounds of the callout line

Include L.Path options to style the callout line associated with the callout object (e.g. color, fillColor, weight, etc.)