From e8f22d54152dbeab74fafb63943feca01fbd4347 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Tue, 20 Aug 2019 16:07:53 -0600 Subject: [PATCH] Cluster and spiderify packages near each other --- www/assets/js/location.js | 2 +- www/assets/js/map_leaflet.js | 11 +++--- www/index.html | 3 ++ www/package.json | 3 +- www/pages/signin.html | 66 ------------------------------------ www/yarn.lock | 5 +++ 6 files changed, 17 insertions(+), 73 deletions(-) delete mode 100644 www/pages/signin.html diff --git a/www/assets/js/location.js b/www/assets/js/location.js index 41f758c..2d071ed 100644 --- a/www/assets/js/location.js +++ b/www/assets/js/location.js @@ -29,7 +29,7 @@ if ("geolocation" in navigator) { if (lastGpsUpdateTimestamp < (currentTimestamp - 10)) { updateDistances(position.coords.latitude, position.coords.longitude); if (map != null) { - map.updatePackageLayer(packages); + //map.updatePackageLayer(packages); } lastGpsUpdateTimestamp = currentTimestamp; diff --git a/www/assets/js/map_leaflet.js b/www/assets/js/map_leaflet.js index 166198b..77f95d5 100644 --- a/www/assets/js/map_leaflet.js +++ b/www/assets/js/map_leaflet.js @@ -28,7 +28,7 @@ function leafletMap() { iconLoading: "far fa-compass fa-spin" }).addTo(map); - map.packagelayer = L.layerGroup(); + map.packagelayer = L.markerClusterGroup(); map.packagelayer.addTo(map); @@ -64,7 +64,7 @@ function leafletMap() { iconAnchor: [12.5, 12.5] }); - L.marker( + var marker = L.marker( [ package.coords[0], package.coords[1] @@ -72,10 +72,11 @@ function leafletMap() { { icon: icon }) - .on('click', function () { + .on("click", function () { openPackageInfoSheet(package); - }) - .addTo(map.packagelayer); + }); + + map.packagelayer.addLayer(marker); }); } diff --git a/www/index.html b/www/index.html index 76a74ee..33aa397 100644 --- a/www/index.html +++ b/www/index.html @@ -5,6 +5,8 @@ + + @@ -23,6 +25,7 @@ + diff --git a/www/package.json b/www/package.json index ebb149f..13a75df 100644 --- a/www/package.json +++ b/www/package.json @@ -8,7 +8,8 @@ "jquery": "^3.4.1", "leaflet": "^1.5.1", "leaflet-geometryutil": "^0.9.1", - "leaflet.locatecontrol": "^0.67.0" + "leaflet.locatecontrol": "^0.67.0", + "leaflet.markercluster": "^1.4.1" }, "devDependencies": {} } diff --git a/www/pages/signin.html b/www/pages/signin.html deleted file mode 100644 index 03669ca..0000000 --- a/www/pages/signin.html +++ /dev/null @@ -1,66 +0,0 @@ - - -
- - - - -
- -
-
-
-
- -
-
    -
  • -
    -
    Username
    -
    - - -
    -
    -
  • - -
  • -
    -
    Password
    -
    - - -
    -
    -
  • - -
-
- -
-
-
- Sign In -
-
-
- Create Account -
- -
-
-
- -
- -
- - - -
\ No newline at end of file diff --git a/www/yarn.lock b/www/yarn.lock index f1d6fc8..568c9e5 100644 --- a/www/yarn.lock +++ b/www/yarn.lock @@ -36,6 +36,11 @@ leaflet.locatecontrol@^0.67.0: resolved "https://registry.yarnpkg.com/leaflet.locatecontrol/-/leaflet.locatecontrol-0.67.0.tgz#adfeebfd662f61d639a5a5fba362368579f8ac55" integrity sha512-3R8jYBwYyXc5Ka7bZvx6naWUvfmJTGJfZ2o/ZWombhCK7NkOxEpwFA3bhW9/BRZ99cLyjeNuLUaLwcPrMKYrjA== +leaflet.markercluster@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/leaflet.markercluster/-/leaflet.markercluster-1.4.1.tgz#b53f2c4f2ca7306ddab1dbb6f1861d5e8aa6c5e5" + integrity sha512-ZSEpE/EFApR0bJ1w/dUGwTSUvWlpalKqIzkaYdYB7jaftQA/Y2Jav+eT4CMtEYFj+ZK4mswP13Q2acnPBnhGOw== + leaflet@>=0.7.0, leaflet@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/leaflet/-/leaflet-1.5.1.tgz#9afb9d963d66c870066b1342e7a06f92840f46bf"