diff --git a/img/raster/layers-2x.png b/img/raster/layers-2x.png
new file mode 100644
index 0000000..a2cf7f9
Binary files /dev/null and b/img/raster/layers-2x.png differ
diff --git a/img/raster/layers.png b/img/raster/layers.png
new file mode 100644
index 0000000..bca0a0e
Binary files /dev/null and b/img/raster/layers.png differ
diff --git a/img/raster/marker-icon-2x.png b/img/raster/marker-icon-2x.png
new file mode 100644
index 0000000..0015b64
Binary files /dev/null and b/img/raster/marker-icon-2x.png differ
diff --git a/img/raster/marker-icon.png b/img/raster/marker-icon.png
new file mode 100644
index 0000000..e2e9f75
Binary files /dev/null and b/img/raster/marker-icon.png differ
diff --git a/img/raster/marker-shadow.png b/img/raster/marker-shadow.png
new file mode 100644
index 0000000..d1e773c
Binary files /dev/null and b/img/raster/marker-shadow.png differ
diff --git a/package.json b/package.json
index 1d9b615..96e4cc3 100644
--- a/package.json
+++ b/package.json
@@ -26,6 +26,7 @@
"express": "^4.14.0",
"express-session": "^1.14.0",
"leaflet": "^0.7.7",
+ "leaflet.markercluster": "^0.5.0",
"lodash": "^4.13.1",
"marko": "^3.7.2",
"mongoose": "^4.5.4",
diff --git a/src/app.js b/src/app.js
index ded4d85..4ce5401 100644
--- a/src/app.js
+++ b/src/app.js
@@ -2,22 +2,43 @@
const $ = require('dollr/dollr').$;
const L = require('leaflet');
+require('leaflet.markercluster');
-L.Icon.Default.imagePath = 'node_modules/leaflet/dist/images/';
+L.Icon.Default.imagePath = './img';
const Map = L.map('map');
navigator.geolocation.getCurrentPosition((position) => {
console.log();
- Map.setView([position.coords.latitude, position.coords.longitude], 11);
+ const InitialPosition = [position.coords.latitude, position.coords.longitude];
+ Map.setView(InitialPosition, 11);
+ makeDummyLayer(InitialPosition);
});
+//Layers
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox',
maxZoom: 18
}).addTo(Map);
+function makeDummyLayer(markerPos) { //
+ //All layers will have to be initialized like this, dummy layer called Markers
+ const dummyLayer = L.markerClusterGroup({
+ spiderfyOnMaxZoom: false,
+ showCoverageOnHover: false,
+ zoomToBoundsOnClick: false,
+ removeOutsideVisibleBounds: true,
+ maxClusterRadius: 0 //Essentially disables clustering, we just want performance gains from this plugin
+ }).addTo(Map);
+
+ //Add a dummy geolet to the dummy layer
+ const dummyMarker = L.marker(markerPos).addTo(Map);
+ dummyMarker.bindPopup("Hejhej! HTML fungerar i popupen. Template här?.").openPopup();
+
+ return [dummyLayer, dummyMarker];
+}
+
$(function () {
$('button').addEventListener('click', function () {
console.log('click');