-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #337 from xdev-software/develop
Release 4.2.0
- Loading branch information
Showing
32 changed files
with
422 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
...ow-demo/src/main/java/software/xdev/vaadin/maps/leaflet/flow/demo/NotOfThisEarthDemo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package software.xdev.vaadin.maps.leaflet.flow.demo; | ||
|
||
import java.util.Map; | ||
|
||
import com.vaadin.flow.component.html.Anchor; | ||
import com.vaadin.flow.router.Route; | ||
|
||
import software.xdev.vaadin.maps.leaflet.MapContainer; | ||
import software.xdev.vaadin.maps.leaflet.basictypes.LLatLng; | ||
import software.xdev.vaadin.maps.leaflet.basictypes.LLatLngBounds; | ||
import software.xdev.vaadin.maps.leaflet.crs.LCRS; | ||
import software.xdev.vaadin.maps.leaflet.layer.raster.LImageOverlay; | ||
import software.xdev.vaadin.maps.leaflet.layer.ui.LMarker; | ||
import software.xdev.vaadin.maps.leaflet.layer.vector.LPolyline; | ||
import software.xdev.vaadin.maps.leaflet.map.LMap; | ||
import software.xdev.vaadin.maps.leaflet.map.LMapOptions; | ||
import software.xdev.vaadin.maps.leaflet.registry.LComponentManagementRegistry; | ||
import software.xdev.vaadin.maps.leaflet.registry.LDefaultComponentManagementRegistry; | ||
|
||
|
||
@Route(NotOfThisEarthDemo.NAV) | ||
@SuppressWarnings("checkstyle:MagicNumber") | ||
public class NotOfThisEarthDemo extends AbstractDemo | ||
{ | ||
public static final String NAV = "not-of-this-earth"; | ||
|
||
private final LComponentManagementRegistry reg; | ||
|
||
public NotOfThisEarthDemo() | ||
{ | ||
// Let the view use 100% of the site | ||
this.setSizeFull(); | ||
|
||
this.add(new Anchor("https://leafletjs.com/examples/crs-simple/crs-simple.html", "Based on this example")); | ||
|
||
// Create the registry which is needed so that components can be reused and their methods invoked | ||
// Note: You normally don't need to invoke any methods of the registry and just hand it over to the components | ||
this.reg = new LDefaultComponentManagementRegistry(this); | ||
|
||
this.buildMap(); | ||
} | ||
|
||
private void buildMap() | ||
{ | ||
// Create and add the MapContainer (which contains the map) to the UI | ||
final MapContainer mapContainer = new MapContainer( | ||
this.reg, | ||
new LMapOptions() | ||
.withCrs(LCRS.Defined.SIMPLE) | ||
.withMinZoom(-3)); | ||
mapContainer.setSizeFull(); | ||
this.add(mapContainer); | ||
|
||
final LMap map = mapContainer.getlMap(); | ||
|
||
new LImageOverlay( | ||
this.reg, | ||
"uqm_map_full.png", | ||
new LLatLngBounds( | ||
this.reg, | ||
this.xy(-25, -26.5), | ||
this.xy(1023, 1021.5)) | ||
).addTo(map); | ||
|
||
final LLatLng cordSol = this.xy(175.2, 145); | ||
final LLatLng cordDeneb = this.xy(218.7, 8.3); | ||
Map.ofEntries( | ||
Map.entry(cordSol, "Sol"), | ||
Map.entry(this.xy(41.6, 130.1), "Mizar"), | ||
Map.entry(this.xy(13.4, 56.5), "Krueger-Z"), | ||
Map.entry(cordDeneb, "Deneb") | ||
).forEach((cords, text) -> new LMarker(this.reg, cords) | ||
.bindPopup(text) | ||
.addTo(map)); | ||
|
||
new LPolyline(this.reg, cordSol, cordDeneb) | ||
.addTo(map); | ||
|
||
map.setView(this.xy(300, 140), 1); | ||
} | ||
|
||
private LLatLng xy(final double x, final double y) | ||
{ | ||
return new LLatLng(this.reg, y, x); | ||
} | ||
} |
142 changes: 142 additions & 0 deletions
142
...-demo/src/main/java/software/xdev/vaadin/maps/leaflet/flow/demo/WatermarkControlDemo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
package software.xdev.vaadin.maps.leaflet.flow.demo; | ||
|
||
import com.vaadin.flow.component.UI; | ||
import com.vaadin.flow.component.html.Anchor; | ||
import com.vaadin.flow.component.orderedlayout.VerticalLayout; | ||
import com.vaadin.flow.router.Route; | ||
|
||
import software.xdev.vaadin.maps.leaflet.MapContainer; | ||
import software.xdev.vaadin.maps.leaflet.basictypes.LLatLng; | ||
import software.xdev.vaadin.maps.leaflet.controls.LControl; | ||
import software.xdev.vaadin.maps.leaflet.controls.LControlOptions; | ||
import software.xdev.vaadin.maps.leaflet.layer.raster.LTileLayer; | ||
import software.xdev.vaadin.maps.leaflet.map.LMap; | ||
import software.xdev.vaadin.maps.leaflet.registry.LComponentManagementRegistry; | ||
import software.xdev.vaadin.maps.leaflet.registry.LDefaultComponentManagementRegistry; | ||
|
||
|
||
@Route(WatermarkControlDemo.NAV) | ||
@SuppressWarnings("checkstyle:MagicNumber") | ||
public class WatermarkControlDemo extends VerticalLayout | ||
{ | ||
public static final String NAV = "/watermark-control"; | ||
|
||
@SuppressWarnings("checkstyle:LineLength") | ||
public WatermarkControlDemo() | ||
{ | ||
LWatermark.register(); | ||
|
||
// Let the view use 100% of the site | ||
this.setSizeFull(); | ||
|
||
this.add(new Anchor( | ||
"https://leafletjs.com/examples/extending/extending-3-controls.html#controls", | ||
"Based on this example")); | ||
|
||
// Create the registry which is needed so that components can be reused and their methods invoked | ||
// Note: You normally don't need to invoke any methods of the registry and just hand it over to the components | ||
final LComponentManagementRegistry reg = new LDefaultComponentManagementRegistry(this); | ||
|
||
// Create and add the MapContainer (which contains the map) to the UI | ||
final MapContainer mapContainer = new MapContainer(reg); | ||
mapContainer.setSizeFull(); | ||
this.add(mapContainer); | ||
|
||
final LMap map = mapContainer.getlMap(); | ||
|
||
// Add a (default) TileLayer so that we can see something on the map | ||
map.addLayer(LTileLayer.createDefaultForOpenStreetMapTileServer(reg)); | ||
|
||
new LWatermark(reg, | ||
new LWatermarkOptions() | ||
.withPosition(LControl.Positions.BOTTOM_LEFT) | ||
.withWidth("20em") | ||
.withSrc(""" | ||
data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="1000" height="200" viewBox="0 0 18300 4500"> | ||
<defs> | ||
<style> | ||
.fil0{fill:%23d71e23} | ||
</style> | ||
</defs> | ||
<g> | ||
<path class="fil0" d="M9763 10965h-920l-17-6-1503-588-1506 588-11 4-13 2-1562 148-1102 105 1064-369 2311-801-1638-633-683-263h1609l16 6 1515 588 1521-588 10-4 9-1 1388-211 1177-178-1131 441-2177 849 1675 647 682 264zM25514 9520l-1909 1442-22 17h-693l-23-19-1765-1440-285-233h907l22 17 1490 1178 1395-1177 23-19h1171zM20426 10961h-4015V9260h4126l-1 127-1 99v126h-112l-3041-3 2 322 3038 3h110l2 124 1 83 2 128h-3146v352l3035-6h112v346z" transform="translate(-5400 -7700)"/> | ||
<path class="fil0" d="M10994 9275h2026a12150 12150 0 0 1 1368 73c292 35 559 83 798 143h1c290 73 510 158 659 254 165 106 248 229 248 368 0 134-85 254-254 359-151 94-375 180-672 256-292 76-618 132-977 170-359 37-751 56-1174 56h-2102V9275h79zm917 1354h1106c300 0 574-14 822-41 247-27 469-67 665-121h1a2470 2470 0 0 0 277-96c176-79 264-164 264-256 0-60-39-118-117-173-92-66-234-125-425-178-197-55-418-96-665-123-248-27-522-41-822-41h-1106v1029z" transform="translate(-5400 -7700)"/> | ||
</g> | ||
</svg> | ||
""")) | ||
.addTo(map); | ||
|
||
// Set what part of the world should be shown | ||
map.setView(new LLatLng(reg, 49.6751, 12.1607), 5); | ||
} | ||
|
||
public static class LWatermark extends LControl<LWatermark> | ||
{ | ||
public LWatermark( | ||
final LComponentManagementRegistry compReg, | ||
final LWatermarkOptions options) | ||
{ | ||
super(compReg, "L.control.watermark(" + compReg.writeOptions(options) + ")"); | ||
} | ||
|
||
public static void register() | ||
{ | ||
UI.getCurrent().getPage().executeJs(""" | ||
L.Control.Watermark = L.Control.extend({ | ||
onAdd: function(map) { | ||
var img = L.DomUtil.create('img'); | ||
img.src = this.options.src; | ||
img.style.width = this.options.width; | ||
return img; | ||
}, | ||
onRemove: function(map) { | ||
// Nothing to do here | ||
} | ||
}); | ||
L.control.watermark = function(opts) { | ||
return new L.Control.Watermark(opts); | ||
} | ||
"""); | ||
} | ||
} | ||
|
||
public static class LWatermarkOptions extends LControlOptions<LWatermarkOptions> | ||
{ | ||
private String src; | ||
private String width; | ||
|
||
public String getSrc() | ||
{ | ||
return this.src; | ||
} | ||
|
||
public void setSrc(final String src) | ||
{ | ||
this.src = src; | ||
} | ||
|
||
public LWatermarkOptions withSrc(final String src) | ||
{ | ||
this.setSrc(src); | ||
return this.self(); | ||
} | ||
|
||
public String getWidth() | ||
{ | ||
return this.width; | ||
} | ||
|
||
public void setWidth(final String width) | ||
{ | ||
this.width = width; | ||
} | ||
|
||
public LWatermarkOptions withWidth(final String width) | ||
{ | ||
this.setWidth(width); | ||
return this.self(); | ||
} | ||
} | ||
} |
Binary file added
BIN
+307 KB
...n-maps-leaflet-flow-demo/src/main/resources/META-INF/resources/uqm_map_full.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.