@@ -84,7 +84,7 @@ public HomeView() {
8484 if ("Refresh Map" .equals (item .getId ())) {
8585 Notification .show ("Map refresh triggered" );
8686 } else if ("Developer" .equals (item .getId ())) {
87- Notification .show ("Map developed by Matt Akbarian (@makbn)" );
87+ Notification .show ("Map developed by Matt Akbarian (@makbn)" , NOTIFICATION_DURATION , Notification . Position . BOTTOM_END );
8888 } else {
8989 getUI ().ifPresent (ui -> ui .getPage ().open (GITHUB_URL , "_blank" ));
9090 }
@@ -125,7 +125,7 @@ public HomeView() {
125125
126126 addTileProviderComponent (menuContent );
127127 addJourneyDemoButton (menuContent , section );
128- addCpntrolSection (menuContent , section );
128+ addControlSection (menuContent , section );
129129 addUiSection (menuContent , section );
130130 addGeoJsonSection (menuContent , section );
131131 addVectorSection (menuContent , section );
@@ -443,19 +443,19 @@ private void loadStyledGeoJson(Map<String, Object> event) {
443443
444444 JLGeoJson geoJson = mapView .getGeoJsonLayer ().addFromFile (((Set <File >) event .get ("uploadedFiles" )).iterator ().next (), options );
445445 geoJson .setOnActionListener ((jlGeoJson , event1 ) ->
446- Notification .show ("GeoJSON Feature clicked: " + event1 ));
446+ Notification .show ("GeoJSON Feature clicked: " + event1 , NOTIFICATION_DURATION , Notification . Position . BOTTOM_END ));
447447
448448 geoJson .addContextMenu ()
449449 .addItem ("Remove" , "Remove styled GeoJSON layer" )
450450 .setOnMenuItemListener (item -> {
451451 if ("Remove" .equals (item .getId ())) {
452452 geoJson .remove ();
453- Notification .show ("Styled GeoJSON layer removed from map" );
453+ Notification .show ("Styled GeoJSON layer removed from map" , NOTIFICATION_DURATION , Notification . Position . BOTTOM_END );
454454 }
455455 });
456456
457457 } catch (Exception ex ) {
458- Notification .show ("Failed to add GeoJSON: " + ex .getMessage ());
458+ Notification .show ("Failed to add GeoJSON: " + ex .getMessage (), NOTIFICATION_DURATION , Notification . Position . BOTTOM_END );
459459 log .error ("Failed to add styled GeoJSON" , ex );
460460 }
461461 }
@@ -475,20 +475,20 @@ private void addUiSection(VerticalLayout menuContent, BiFunction<String, Button[
475475
476476 marker .setOnActionListener ((jlMarker , event1 ) -> {
477477 if (event1 instanceof MoveEvent ) {
478- Notification .show ("Marker moved: " + jlMarker + " -> " + event1 .action ());
478+ Notification .show ("Marker moved: " + jlMarker + " -> " + event1 .action (), NOTIFICATION_DURATION , Notification . Position . BOTTOM_END );
479479 } else if (event1 instanceof ClickEvent ) {
480- Notification .show ("Marker clicked: " + jlMarker );
480+ Notification .show ("Marker clicked: " + jlMarker , NOTIFICATION_DURATION , Notification . Position . BOTTOM_END );
481481 }
482482 });
483483 marker .getPopup ().setOnActionListener ((jlPopup , jlEvent ) ->
484- Notification .show (String .format ("Marker's Popup '%s' Event: %s" , jlPopup , jlEvent )));
484+ Notification .show (String .format ("Marker's Popup '%s' Event: %s" , jlPopup , jlEvent ), NOTIFICATION_DURATION , Notification . Position . BOTTOM_END ));
485485
486486 marker .addContextMenu ()
487487 .addItem ("Remove" , "Remove this marker" )
488488 .setOnMenuItemListener (item -> {
489489 if ("Remove" .equals (item .getId ())) {
490490 marker .remove ();
491- Notification .show ("Marker removed from map" );
491+ Notification .show ("Marker removed from map" , NOTIFICATION_DURATION , Notification . Position . BOTTOM_END );
492492 }
493493 });
494494 }));
@@ -514,24 +514,36 @@ private void addUiSection(VerticalLayout menuContent, BiFunction<String, Button[
514514 .setOnMenuItemListener (item -> {
515515 if ("Remove" .equals (item .getId ())) {
516516 imageOverlay .remove ();
517- Notification .show ("Eiffel Tower overlay removed from map" );
517+ Notification .show ("Eiffel Tower overlay removed from map" , NOTIFICATION_DURATION , Notification . Position . BOTTOM_END );
518518 }
519519 });
520520
521- Notification .show ("Eiffel Tower overlay added!" );
521+ Notification .show ("Eiffel Tower overlay added!" , NOTIFICATION_DURATION , Notification . Position . BOTTOM_END );
522522 });
523523 addEiffelOverlay .setClassName (MENU_ITEM_CLASS );
524524
525525 menuContent .add (section .apply ("UI Layer" , new Button []{addMarker , addEiffelOverlay }));
526526 }
527527
528- private void addCpntrolSection (VerticalLayout menuContent , BiFunction <String , Button [], VerticalLayout > section ) {
528+ private void addControlSection (VerticalLayout menuContent , BiFunction <String , Button [], VerticalLayout > section ) {
529529 Button zoomIn = new Button ("Zoom in" , e -> mapView .getControlLayer ().setZoom (defaultZoomLevel .addAndGet (1 )));
530530 Button zoomOut = new Button ("Zoom out" , e -> mapView .getControlLayer ().setZoom (defaultZoomLevel .addAndGet (-1 )));
531531 Button fitWorld = new Button ("Fit World" , e -> mapView .getControlLayer ().fitWorld ());
532- Button maxZoom = new Button ("Max Zoom" , e -> DialogBuilder .builder ().numberField ("Max zoom level" ).get (event -> mapView .getControlLayer ().setMaxZoom ((Integer ) event .get ("Max zoom level" ))));
533- Button minZoom = new Button ("Min Zoom" , e -> DialogBuilder .builder ().numberField ("Min zoom level" ).get (event -> mapView .getControlLayer ().setMinZoom ((Integer ) event .get ("Min zoom level" ))));
534- Button flyTo = new Button ("Fly to" , e -> DialogBuilder .builder ().decimalField (LATITUDE ).decimalField (LONGITUDE ).numberField ("Zoom level" ).get (event -> mapView .getControlLayer ().flyTo (JLLatLng .builder ().lat ((Double ) event .get (LATITUDE )).lng ((Double ) event .get (LONGITUDE )).build (), (Integer ) event .get ("Zoom level" ))));
532+ Button maxZoom = new Button ("Max Zoom" , e ->
533+ DialogBuilder .builder ().numberField ("Max zoom level" ).get (event ->
534+ mapView .getControlLayer ().setMaxZoom ((Integer ) event .get ("Max zoom level" ))));
535+
536+ Button minZoom = new Button ("Min Zoom" , e ->
537+ DialogBuilder .builder ().numberField ("Min zoom level" ).get (event ->
538+ mapView .getControlLayer ().setMinZoom ((Integer ) event .get ("Min zoom level" ))));
539+ Button flyTo = new Button ("Fly to" , e ->
540+ DialogBuilder .builder ()
541+ .decimalField (LATITUDE )
542+ .decimalField (LONGITUDE )
543+ .numberField ("Zoom level" )
544+ .get (event ->
545+ mapView .getControlLayer ().flyTo (JLLatLng .builder ().lat ((Double ) event .get (LATITUDE )).lng ((Double ) event .get (LONGITUDE )).build (), (Integer ) event .get ("Zoom level" ))));
546+
535547 for (Button b : new Button []{zoomIn , zoomOut , fitWorld , maxZoom , minZoom , flyTo })
536548 b .setClassName (MENU_ITEM_CLASS );
537549 menuContent .add (section .apply ("Control Layer" , new Button []{zoomIn , zoomOut , fitWorld , maxZoom , minZoom , flyTo }));
@@ -566,6 +578,6 @@ private void addTileProviderComponent(VerticalLayout menuContent) {
566578
567579 @ Override
568580 public void onAction (JLMap <PendingJavaScriptResult > source , Event event ) {
569- Notification .show ("Map event: " + event );
581+ Notification .show ("Map event: " + event , NOTIFICATION_DURATION , Notification . Position . BOTTOM_END );
570582 }
571583}
0 commit comments