Merge pull request #11 from jugglingnutcase/clustering
Cluster close markers together on the map
This commit is contained in:
		
							
								
								
									
										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,6 +6,7 @@
 | 
				
			|||||||
		<script type="text/javascript" src='js/jquery.js '></script>
 | 
							<script type="text/javascript" src='js/jquery.js '></script>
 | 
				
			||||||
		<script type="text/javascript" src='js/tabletop.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/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"/>
 | 
							<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"/>
 | 
							<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 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/style.css"> 
 | 
				
			||||||
		<link media="screen" rel="stylesheet" type="text/css" href="css/site.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>
 | 
						</head>
 | 
				
			||||||
<body>
 | 
					<body>
 | 
				
			||||||
	<div id="wrapper">
 | 
						<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) {
 | 
					function addMarkerLayer(geoJSON, map, zoomLevel) {
 | 
				
			||||||
  var viewCoords = [geoJSON[0].geometry.coordinates[1], geoJSON[0].geometry.coordinates[0]]
 | 
					  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.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
 | 
					  return markerLayer
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user