aboutsummaryrefslogtreecommitdiff
path: root/app/javascript
diff options
context:
space:
mode:
Diffstat (limited to 'app/javascript')
-rw-r--r--app/javascript/controllers/map_controller.js10
-rw-r--r--app/javascript/packs/application.js1
-rw-r--r--app/javascript/scss/application.scss1
3 files changed, 12 insertions, 0 deletions
diff --git a/app/javascript/controllers/map_controller.js b/app/javascript/controllers/map_controller.js
index 57bafa5..0a64f98 100644
--- a/app/javascript/controllers/map_controller.js
+++ b/app/javascript/controllers/map_controller.js
@@ -19,6 +19,7 @@ import "leaflet.markercluster/dist/leaflet.markercluster.js"
import 'leaflet-extra-markers'
import 'leaflet-easyprint'
+import { GeoSearchControl, OpenStreetMapProvider } from 'leaflet-geosearch';
export default class extends Controller {
static targets = [ "container" ]
@@ -75,6 +76,15 @@ export default class extends Controller {
sizeModes: ['A4Portrait', 'A4Landscape']
}).addTo(this.map);
+ /* Add search */
+ const provider = new OpenStreetMapProvider();
+ const searchControl = new GeoSearchControl({
+ provider: provider,
+ style: 'button',
+ position: 'bottomright'
+ });
+ this.map.addControl(searchControl);
+
// Allow calling the mapController from elsewhere.
this.element[this.identifier] = this
}
diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js
index 0ddfdb5..ea65dca 100644
--- a/app/javascript/packs/application.js
+++ b/app/javascript/packs/application.js
@@ -18,6 +18,7 @@ import "../scss/application"
//= require leaflet
//= require leaflet-defaulticon-compatibility
+//= require leaflet-geosearch
//= require leaflet.markercluster
import "controllers"
diff --git a/app/javascript/scss/application.scss b/app/javascript/scss/application.scss
index 3bf6259..2775c69 100644
--- a/app/javascript/scss/application.scss
+++ b/app/javascript/scss/application.scss
@@ -28,6 +28,7 @@
/* Vendors */
@import "leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.webpack.css";
+@import "leaflet-geosearch/dist/geosearch.css";
@import "leaflet.markercluster/dist/MarkerCluster.css";
@import "leaflet.markercluster/dist/MarkerCluster.Default.css";