Mapbox - Custom Markers 2
by lmartins
HTML
<script src="https://api.tiles.mapbox.com/mapbox.js/v1.6.2/mapbox.js"></script>
<link rel="stylesheet" href="https://api.tiles.mapbox.com/mapbox.js/v1.6.2/mapbox.css">
<div id="systems-map" class="map"></div>
<nav class='menu-ui'>
<a href='#' class='active' data-filter='all'>Show all</a>
<a href='#' data-filter='cat1'>Cat1</a>
</nav>
SCSS
body, html{
height: 100%;
}
.Page.mapsPage{
width: 100%;
max-width: none;
padding: 0;
}
.map {
height: 100%;
}
.mapNotification{
width: 30px;
height: 30px;
right: -20px;
background: white;
border-radius: 100%;
box-shadow: hsla(192, 67%, 14%, 0.4) 0 1px 3px;
}
.info {
padding: 6px 8px;
font: 14px/16px Arial, Helvetica, sans-serif;
background: white;
background: rgba(255,255,255,0.8);
box-shadow: 0 0 15px rgba(0,0,0,0.2);
border-radius: 5px;
}
.info h4 {
margin: 0 0 5px;
color: #777;
}
$popup-bg: hsla(210, 29%, 24%, 0.90);
//.map .leaflet-popup-content-wrapper {
// background: $popup-bg;
// color:#fff;
//}
//.map .leaflet-popup-content-wrapper a {
// color:#bdc3c7;
//}
//.map .leaflet-popup-tip-container {
// width: 40px;
// height: 25px;
// margin: 0 auto;
// position: relative;
//}
//.map .leaflet-popup-tip {
// width: 0;
// height: 0;
// margin: 0;
// border-left: 20px solid transparent;
// border-right: 20px solid transparent;
// border-top: 20px solid $popup-bg;
// box-shadow: none;
//}
.leaflet-popup{
header{
font-weight: bold;
border-bottom: 1px solid hsla(0, 0%, 92%, 1);
margin-bottom: 0.75em;
}
.notificationsList{
margin: 0;
padding: 0 0 0 1.5em;
max-height: 140px;
overflow: auto;
}
// TODO: Formato para lista vazia
p{
text-align: center;
font-size: 13px !important;
color: hsla(220, 8%, 65%, 1);
display: block;
margin: 0 !important;
padding: 0.5em 0;
}
}
// SYSTEM ICON
// Markers para cada sistema no mapa
.systemIcon{
//font-size: 1.2em;
line-height: 1.8;
min-width: 1.8em;
min-height: 1.8em;
border-radius: 100%;
background: hsl(204, 97%, 40%);
box-shadow:
hsla(0, 100%, 0%, 0.35) 0 1px 2px,
hsla(204, 97%, 40%, 0.3) 0 0 0 6px;
color: white;
text-align: center;
cursor: pointer;
&:hover{
transform: scale(1.1);
background: hsl(204, 97%, 46%);
}
&.hasAlerts{
//background:...
JavaScript
'use strict';
var buildAlertsList, buildVisibleSys, geoJson, geoLocateBtn, geoLocateInfo, map, mapEl, myLayer, onScreenEl, osmAttrib, osmUrl, streets, systemLocations, systemsArray, updateLocationInfo, updateVisibleSys;
osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
osmAttrib = 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a>';
mapEl = document.querySelector('#systems-map');
map = L.mapbox.map('systems-map', streets).addControl(L.mapbox.geocoderControl(osmUrl));
streets = L.tileLayer(osmUrl, {
attribution: osmAttrib
});
streets.addTo(map);
systemsArray = [
{
type: 'Feature',
properties: {
title: "Marker 1",
cat1: true,
icon: {
className: 'systemIcon hasAlerts',
html: 3
},
alertsInfo: ["Título do primeiro alerta", "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.", "Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim."]
},
geometry: {
type: 'Point',
coordinates: [-8.64106, 39.53833]
}
}, {
type: 'Feature',
properties: {
title: "Marker 2",
cat1: true,
icon: {
className: 'systemIcon hasAlerts',
html: 1
},
alertsInfo: ["Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus."]
},
geometry: {
type: 'Point',
coordinates: [-8.24106, 39.13833]
}
}, {
type: 'Feature',
properties: {
title: "Marker 3",
icon: {
className: 'systemIcon',
html: 0
},
alertsInfo: []
},
geometry: {
type: 'Point',
coordinates: [-8.21106, 37.13833]
}
}, {
type: 'Feature',
properties: {
title: "Marker...