Merge pull request #11 from jugglingnutcase/clustering
Cluster close markers together on the map
This commit is contained in:
commit
5168bc9c8f
38
css/MarkerCluster.Default.css
Normal file
38
css/MarkerCluster.Default.css
Normal 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
6
css/MarkerCluster.css
Normal 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;
|
||||
}
|
@ -6,14 +6,17 @@
|
||||
<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"/>
|
||||
<link href='http://api.tiles.mapbox.com/mapbox.js/v1.0.0/mapbox.css' rel='stylesheet' />
|
||||
<link rel='stylesheet' type='text/css' href='http://fonts.googleapis.com/css?family=Lato:300,400,700,300italic'>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<link href='http://api.tiles.mapbox.com/mapbox.js/v1.0.0/mapbox.css' rel='stylesheet' />
|
||||
<link rel='stylesheet' type='text/css' href='http://fonts.googleapis.com/css?family=Lato:300,400,700,300italic'>
|
||||
<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">
|
||||
|
6
js/leaflet.markercluster.js
Normal file
6
js/leaflet.markercluster.js
Normal file
File diff suppressed because one or more lines are too long
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user