Create markers from HTML

Use L.divIcon to create custom HTML markers.

<!DOCTYPE html>
<meta charset=utf-8 />
<title>Create markers from HTML</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src=''></script>
<link href='' rel='stylesheet' />
  body { margin:0; padding:0; }
  #map { position:absolute; top:0; bottom:0; width:100%; }
 * Unlike other icons, you can style `L.divIcon` with CSS.
 * These styles make each marker a pink triangle.
.css-icon {
  width: 0;
  height: 0;
  border-top: 30px solid transparent;
  border-bottom: 30px solid transparent;
  border-left: 30px solid #ff8888;
<div id='map'></div>
L.mapbox.accessToken = '<your access token here>';
var map ='map')
    .setView([0, 0], 2)

// Define an icon called cssIcon
var cssIcon = L.divIcon({
  // Specify a class name we can refer to in CSS.
  className: 'css-icon',
  // Set marker width and height
  iconSize: [60, 60]

// Create three markers and set their icons to cssIcon
L.marker([45, 45], {icon: cssIcon}).addTo(map);
L.marker([0, 0], {icon: cssIcon}).addTo(map);
L.marker([-45, -45], {icon: cssIcon}).addTo(map);
to create your own custom map and use it in this example.
Use this example by copying its source into your own HTML page and replacing the Map ID with one of your own from your projects. Having trouble with JavaScript? Try out Codecademy or contact our support team.
Copy example