Merge pull request #11 from jugglingnutcase/clustering

Cluster close markers together on the map
This commit is contained in:
Jessica Lord 2013-10-07 14:00:26 -07:00
commit 5168bc9c8f
5 changed files with 63 additions and 7 deletions

View File

@ -0,0 +1,38 @@
.marker-cluster-small {
background-color: rgba(181, 226, 140, 0.6);
}
.marker-cluster-small div {
background-color: rgba(110, 204, 57, 0.6);
}
.marker-cluster-medium {
background-color: rgba(241, 211, 87, 0.6);
}
.marker-cluster-medium div {
background-color: rgba(240, 194, 12, 0.6);
}
.marker-cluster-large {
background-color: rgba(253, 156, 115, 0.6);
}
.marker-cluster-large div {
background-color: rgba(241, 128, 23, 0.6);
}
.marker-cluster {
background-clip: padding-box;
border-radius: 20px;
}
.marker-cluster div {
width: 30px;
height: 30px;
margin-left: 5px;
margin-top: 5px;
text-align: center;
border-radius: 15px;
font: 12px "Helvetica Neue", Arial, Helvetica, sans-serif;
}
.marker-cluster span {
line-height: 30px;
}

6
css/MarkerCluster.css Normal file
View File

@ -0,0 +1,6 @@
.leaflet-cluster-anim .leaflet-marker-icon, .leaflet-cluster-anim .leaflet-marker-shadow {
-webkit-transition: -webkit-transform 0.2s ease-out, opacity 0.2s ease-in;
-moz-transition: -moz-transform 0.2s ease-out, opacity 0.2s ease-in;
-o-transition: -o-transform 0.2s ease-out, opacity 0.2s ease-in;
transition: transform 0.2s ease-out, opacity 0.2s ease-in;
}

View File

@ -6,6 +6,7 @@
<script type="text/javascript" src='js/jquery.js '></script>
<script type="text/javascript" src='js/tabletop.js'></script>
<script type="text/javascript" src='js/sheetsee.js'></script>
<script type="text/javascript" src='js/leaflet.markercluster.js'></script>
<link rel="shortcut icon" href="https://raw.github.com/jlord/hack-spots/master/favico.png"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
@ -14,6 +15,8 @@
<link rel='stylesheet' type='text/css' href='http://fonts.googleapis.com/css?family=Amatic+SC:400,700'>
<link media="screen" rel="stylesheet" type="text/css" href="css/style.css">
<link media="screen" rel="stylesheet" type="text/css" href="css/site.css">
<link rel="stylesheet" href="css/MarkerCluster.css" />
<link rel="stylesheet" href="css/MarkerCluster.Default.css" />
</head>
<body>
<div id="wrapper">

File diff suppressed because one or more lines are too long

View File

@ -306,11 +306,14 @@ function addTileLayer(map, tileLayer) {
function addMarkerLayer(geoJSON, map, zoomLevel) {
var viewCoords = [geoJSON[0].geometry.coordinates[1], geoJSON[0].geometry.coordinates[0]]
var markerLayer = L.mapbox.markerLayer(geoJSON)
markerLayer.setGeoJSON(geoJSON)
map.setView(viewCoords, zoomLevel)
// map.fitBounds(geoJSON)
markerLayer.addTo(map)
// Clustering
var markers = new L.MarkerClusterGroup()
var markerLayer = L.mapbox.markerLayer(geoJSON)
markers.addLayer(markerLayer)
map.addLayer(markers)
return markerLayer
}