diff --git a/.config/pmd/ruleset.xml b/.config/pmd/ruleset.xml index 5f881567..667f74e5 100644 --- a/.config/pmd/ruleset.xml +++ b/.config/pmd/ruleset.xml @@ -59,6 +59,9 @@ + + + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 17140f36..98416791 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -160,7 +160,7 @@ jobs: cache: 'maven' - name: Build site - run: ../mvnw -B site -DskipTests + run: ../mvnw -B compile site -DskipTests -T2C working-directory: ${{ env.PRIMARY_MAVEN_MODULE }} - name: Deploy to Github pages diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml index 7824917b..b38f0d82 100644 --- a/.github/workflows/sonar.yml +++ b/.github/workflows/sonar.yml @@ -11,7 +11,7 @@ on: - '.idea/**' - 'assets/**' pull_request: - types: [opened, synchronize, reopened] + branches: [ develop ] paths-ignore: - '**.md' - '.config/**' diff --git a/.github/workflows/test-deploy.yml b/.github/workflows/test-deploy.yml index 9c07de25..e3ed038b 100644 --- a/.github/workflows/test-deploy.yml +++ b/.github/workflows/test-deploy.yml @@ -24,7 +24,7 @@ jobs: gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} - name: Publish to OSSRH - run: ../mvnw -B deploy -Possrh + run: ../mvnw -B deploy -Possrh -DskipTests working-directory: ${{ env.PRIMARY_MAVEN_MODULE }} env: MAVEN_CENTRAL_USERNAME: ${{ secrets.S01_OSS_SONATYPE_MAVEN_USERNAME }} diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index e56bc180..4d624fa9 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,4 +14,4 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.8/apache-maven-3.9.8-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip diff --git a/CHANGELOG.md b/CHANGELOG.md index c676766e..15f7ffd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 4.4.0 +* Added support for [GeoJSON](https://leafletjs.com/reference.html#geojson) and [FeatureGroup](https://leafletjs.com/reference.html#featuregroup) #438 +* Add "draggable" property to LMarkerOptions #413 (thanks to @ChristianHoesel) + ## 4.3.0 * Updated to Vaadin 24.4 * Deduplicated ``tLMapZoomPanOptions`` diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 61df7d52..87ccb356 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,3 +58,31 @@ If the ``develop`` is ready for release, create a pull request to the ``master`` When the release is finished do the following: * Merge the auto-generated PR (with the incremented version number) back into the ``develop`` * Ensure that [Vaadin Directory](https://vaadin.com/directory) syncs the update and maybe update the component / version there + +### Release failures + +There are 2 modes of release failure: +1. The remote server was e.g. down and non of the artifacts got published +2. There was a build failure during release and only parts of the artifacts got released + +In case 1 we can re-release the existing version,
in case 2 we have to release a new version when we can't get the artifacts deleted (as is the case with Maven Central) + +#### How-to: Re-Releasing an existing version + +1. Delete the release on GitHub +2. Delete the release Git tag from the repo (locally and remote!) +3. Delete the ``master``-Branch and re-create it from the ``develop`` branch (or reset it to the state before the release-workflow commits have been done) + * This requires __temporarily__ removing the branch protection + * Once this was done a new release is triggered immediately! + +#### How-to: Releasing a new version + +1. Merge the ``master`` branch back into ``develop`` (or another temporary branch) +2. Make sure all master branch versions are prepared for a new release
e.g. if the broken release was ``1.0.0`` the version should now be at ``1.0.1-SNAPSHOT`` - the ``SNAPSHOT`` is important for the workflow! +3. Mark the broken release as broken e.g. inside the Changelog, GitHub Release page, etc.
+You can use something like this: + ``` + > [!WARNING] + > This release is broken as my cat accidentally clicked the abort button during the process + ``` +4. Merge the changes back into the ``master`` branch to trigger a new release diff --git a/README.md b/README.md index 3e653149..42718a3c 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ To get started it's recommended to have a look at the [demo](./vaadin-maps-leafl > [!NOTE] > **The API only supports sending instructions to the client**
> Due to data integrity retrieving client-side data (that can be modified by users) is not supported. -> * Event listeners can still be registered but this needs to be done manually.
[An example is available in the demo](https://github.com/xdev-software/vaadin-maps-leaflet-flow/blob/5a008511935105ea977187112cd0053c7de33e19/vaadin-maps-leaflet-flow-demo/src/main/java/software/xdev/vaadin/maps/leaflet/flow/demo/ComplexDemo.java#L223). +> * Event listeners can still be registered but this needs to be done manually.
[An example is available in the demo](./vaadin-maps-leaflet-flow-demo/src/main/java/software/xdev/vaadin/maps/leaflet/flow/demo/EventDemo.java). ## Installation [Installation guide of the latest release](https://github.com/xdev-software/vaadin-maps-leaflet-flow/releases/latest#Installation) diff --git a/pom.xml b/pom.xml index 021f7df6..b2fd1fde 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ software.xdev vaadin-maps-leaflet-flow-root - 4.3.1-SNAPSHOT + 4.4.0-SNAPSHOT pom @@ -40,12 +40,12 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.4.0 + 3.5.0 com.puppycrawl.tools checkstyle - 10.17.0 + 10.18.1 @@ -70,7 +70,7 @@ org.apache.maven.plugins maven-pmd-plugin - 3.23.0 + 3.25.0 true true @@ -82,12 +82,12 @@ net.sourceforge.pmd pmd-core - 7.2.0 + 7.5.0 net.sourceforge.pmd pmd-java - 7.2.0 + 7.5.0 @@ -99,7 +99,7 @@ org.apache.maven.plugins maven-jxr-plugin - 3.4.0 + 3.5.0 diff --git a/renovate.json5 b/renovate.json5 index de6a6df7..068c28f0 100644 --- a/renovate.json5 +++ b/renovate.json5 @@ -9,6 +9,16 @@ "maven" ], "enabled": false + }, + { + "description": "Group net.sourceforge.pmd", + "matchPackagePatterns": [ + "^net.sourceforge.pmd" + ], + "datasources": [ + "maven" + ], + "groupName": "net.sourceforge.pmd" } ] } diff --git a/vaadin-maps-leaflet-flow-demo/pom.xml b/vaadin-maps-leaflet-flow-demo/pom.xml index 16a1b67d..f0eed5c7 100644 --- a/vaadin-maps-leaflet-flow-demo/pom.xml +++ b/vaadin-maps-leaflet-flow-demo/pom.xml @@ -7,11 +7,11 @@ software.xdev vaadin-maps-leaflet-flow-root - 4.3.1-SNAPSHOT + 4.4.0-SNAPSHOT vaadin-maps-leaflet-flow-demo - 4.3.1-SNAPSHOT + 4.4.0-SNAPSHOT jar @@ -29,9 +29,9 @@ software.xdev.vaadin.Application - 24.4.4 + 24.4.11 - 3.3.1 + 3.3.3 diff --git a/vaadin-maps-leaflet-flow-demo/src/main/java/software/xdev/vaadin/maps/leaflet/flow/DemoView.java b/vaadin-maps-leaflet-flow-demo/src/main/java/software/xdev/vaadin/maps/leaflet/flow/DemoView.java index 18f86330..e5fe26f6 100644 --- a/vaadin-maps-leaflet-flow-demo/src/main/java/software/xdev/vaadin/maps/leaflet/flow/DemoView.java +++ b/vaadin-maps-leaflet-flow-demo/src/main/java/software/xdev/vaadin/maps/leaflet/flow/DemoView.java @@ -16,6 +16,7 @@ import software.xdev.vaadin.maps.leaflet.flow.demo.ComplexDemo; import software.xdev.vaadin.maps.leaflet.flow.demo.EventDemo; import software.xdev.vaadin.maps.leaflet.flow.demo.FreeingUpResourceBenchmarkDemo; +import software.xdev.vaadin.maps.leaflet.flow.demo.GeoJSONDemo; import software.xdev.vaadin.maps.leaflet.flow.demo.InitialResizeDemo; import software.xdev.vaadin.maps.leaflet.flow.demo.MinimalisticDemo; import software.xdev.vaadin.maps.leaflet.flow.demo.MultiLayerWithPyramidDemo; @@ -93,6 +94,11 @@ protected void onAttach(final AttachEvent attachEvent) "using Pyramids ▲ and more...\n" + "Showcases a selection of different layers and how they can be displayed on a map" ), + new Example( + GeoJSONDemo.NAV, + "GeoJSON", + "Showcases how GeoJSON can be used" + ), new Example( FreeingUpResourceBenchmarkDemo.NAV, "Freeing up resources Benchmark", diff --git a/vaadin-maps-leaflet-flow-demo/src/main/java/software/xdev/vaadin/maps/leaflet/flow/demo/ComplexDemo.java b/vaadin-maps-leaflet-flow-demo/src/main/java/software/xdev/vaadin/maps/leaflet/flow/demo/ComplexDemo.java index 586993af..cc1f6ec4 100644 --- a/vaadin-maps-leaflet-flow-demo/src/main/java/software/xdev/vaadin/maps/leaflet/flow/demo/ComplexDemo.java +++ b/vaadin-maps-leaflet-flow-demo/src/main/java/software/xdev/vaadin/maps/leaflet/flow/demo/ComplexDemo.java @@ -105,7 +105,9 @@ public ComplexDemo() final LMarker markerInfo = new LMarker( this.reg, new LLatLng(this.reg, 49.674662, 12.162869), - new LMarkerOptions().withIcon(divIconInfo)); + new LMarkerOptions() + .withIcon(divIconInfo) + .withDraggable(true)); @SuppressWarnings("checkstyle:LineLength") final LIcon iconXDEV = new LIcon(this.reg, new LIconOptions() diff --git a/vaadin-maps-leaflet-flow-demo/src/main/java/software/xdev/vaadin/maps/leaflet/flow/demo/GeoJSONDemo.java b/vaadin-maps-leaflet-flow-demo/src/main/java/software/xdev/vaadin/maps/leaflet/flow/demo/GeoJSONDemo.java new file mode 100644 index 00000000..e7fbb38c --- /dev/null +++ b/vaadin-maps-leaflet-flow-demo/src/main/java/software/xdev/vaadin/maps/leaflet/flow/demo/GeoJSONDemo.java @@ -0,0 +1,75 @@ +package software.xdev.vaadin.maps.leaflet.flow.demo; + +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.base.RawString; +import software.xdev.vaadin.maps.leaflet.basictypes.LLatLng; +import software.xdev.vaadin.maps.leaflet.layer.other.LGeoJSONLayer; +import software.xdev.vaadin.maps.leaflet.layer.other.LGeoJSONLayerOptions; +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(GeoJSONDemo.NAV) +@SuppressWarnings("checkstyle:MagicNumber") +public class GeoJSONDemo extends VerticalLayout +{ + public static final String NAV = "/geojson"; + + public GeoJSONDemo() + { + // Let the view use 100% of the site + this.setSizeFull(); + + this.add(new Anchor("https://leafletjs.com/examples/geojson", "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)); + + // Set what part of the world should be shown + map.setView(new LLatLng(reg, 39.75621, -104.99404), 17); + + // Handle GeoJSON + final String serializedGeoJSON = """ + { + "type": "Feature", + "properties": { + "name": "Coors Field", + "amenity": "Baseball Stadium", + "popupContent": "This is where the Rockies play!" + }, + "geometry": { + "type": "Point", + "coordinates": [-104.99404, 39.75621] + } + } + """; + new LGeoJSONLayer( + reg, + serializedGeoJSON, + new LGeoJSONLayerOptions() + .withOnEachFeature(new RawString("(feature, layer) => { " + + " if (feature.properties && feature.properties.popupContent) { " + + " layer.bindPopup(feature.properties.popupContent); " + + " }" + + " }")) + ) + .addTo(map); + } +} diff --git a/vaadin-maps-leaflet-flow/pom.xml b/vaadin-maps-leaflet-flow/pom.xml index fcc20f67..94c576c6 100644 --- a/vaadin-maps-leaflet-flow/pom.xml +++ b/vaadin-maps-leaflet-flow/pom.xml @@ -6,7 +6,7 @@ software.xdev vaadin-maps-leaflet-flow - 4.3.1-SNAPSHOT + 4.4.0-SNAPSHOT jar vaadin-maps-leaflet-flow @@ -49,7 +49,7 @@ UTF-8 - 24.4.4 + 24.4.11 @@ -108,7 +108,7 @@ com.fasterxml.jackson.core jackson-databind - 2.17.1 + 2.17.2 @@ -124,12 +124,12 @@ org.apache.maven.plugins maven-site-plugin - 4.0.0-M15 + 4.0.0-M16 org.apache.maven.plugins maven-project-info-reports-plugin - 3.6.1 + 3.7.0 @@ -192,7 +192,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.7.0 + 3.10.0 attach-javadocs @@ -272,7 +272,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.2.4 + 3.2.5 sign-artifacts @@ -315,12 +315,12 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.4.0 + 3.5.0 com.puppycrawl.tools checkstyle - 10.17.0 + 10.18.1 @@ -345,7 +345,7 @@ org.apache.maven.plugins maven-pmd-plugin - 3.23.0 + 3.25.0 true true @@ -357,12 +357,12 @@ net.sourceforge.pmd pmd-core - 7.2.0 + 7.5.0 net.sourceforge.pmd pmd-java - 7.2.0 + 7.5.0 @@ -374,7 +374,7 @@ org.apache.maven.plugins maven-jxr-plugin - 3.4.0 + 3.5.0 diff --git a/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/base/has/LHasSetStylePath.java b/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/base/has/LHasSetStylePath.java new file mode 100644 index 00000000..3b0a7d95 --- /dev/null +++ b/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/base/has/LHasSetStylePath.java @@ -0,0 +1,29 @@ +/* + * Copyright © 2019 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.vaadin.maps.leaflet.base.has; + +import software.xdev.vaadin.maps.leaflet.base.LComponent; +import software.xdev.vaadin.maps.leaflet.layer.vector.LPathOptions; + + +public interface LHasSetStylePath> extends LComponent +{ + default S setStyle(final LPathOptions options) + { + this.invokeSelf(".setStyle(" + this.componentRegistry().writeOptionsOrEmptyObject(options) + ")"); + return this.self(); + } +} diff --git a/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/LAbstractLayerGroup.java b/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/LAbstractLayerGroup.java new file mode 100644 index 00000000..3b7cce06 --- /dev/null +++ b/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/LAbstractLayerGroup.java @@ -0,0 +1,64 @@ +/* + * Copyright © 2019 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.vaadin.maps.leaflet.layer; + +import java.io.Serializable; + +import software.xdev.vaadin.maps.leaflet.base.has.LHasSetZIndex; +import software.xdev.vaadin.maps.leaflet.registry.LComponentManagementRegistry; + + +/** + * @see Leaflet docs + */ +public class LAbstractLayerGroup> extends LLayer + implements LHasSetZIndex +{ + protected LAbstractLayerGroup( + final LComponentManagementRegistry compReg, + final String jsConstructorCallExpression, + final Serializable... parameters) + { + super(compReg, jsConstructorCallExpression, parameters); + } + + /** + * @see Leaflet docs + */ + public S addLayer(final LLayer layer) + { + this.invokeSelf(".addLayer(" + layer.clientComponentJsAccessor() + ")"); + return this.self(); + } + + /** + * @see Leaflet docs + */ + public S removeLayer(final LLayer layer) + { + this.invokeSelf(".removeLayer(" + layer.clientComponentJsAccessor() + ")"); + return this.self(); + } + + /** + * @see Leaflet docs + */ + public S clearLayers() + { + this.invokeSelf(".clearLayers()"); + return this.self(); + } +} diff --git a/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/LLayerGroup.java b/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/LLayerGroup.java index f79cab75..caa41350 100644 --- a/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/LLayerGroup.java +++ b/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/LLayerGroup.java @@ -18,14 +18,13 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import software.xdev.vaadin.maps.leaflet.base.has.LHasSetZIndex; import software.xdev.vaadin.maps.leaflet.registry.LComponentManagementRegistry; /** * @see Leaflet docs */ -public class LLayerGroup extends LLayer implements LHasSetZIndex +public class LLayerGroup extends LAbstractLayerGroup { public LLayerGroup( final LComponentManagementRegistry compReg, @@ -54,31 +53,4 @@ public LLayerGroup( { this(compReg, layers, null); } - - /** - * @see Leaflet docs - */ - public LLayerGroup addLayer(final LLayer layer) - { - this.invokeSelf(".addLayer(" + layer.clientComponentJsAccessor() + ")"); - return this.self(); - } - - /** - * @see Leaflet docs - */ - public LLayerGroup removeLayer(final LLayer layer) - { - this.invokeSelf(".removeLayer(" + layer.clientComponentJsAccessor() + ")"); - return this.self(); - } - - /** - * @see Leaflet docs - */ - public LLayerGroup clearLayers() - { - this.invokeSelf(".clearLayers()"); - return this.self(); - } } diff --git a/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/other/LAbstractFeatureGroup.java b/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/other/LAbstractFeatureGroup.java new file mode 100644 index 00000000..33acc8bc --- /dev/null +++ b/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/other/LAbstractFeatureGroup.java @@ -0,0 +1,39 @@ +/* + * Copyright © 2019 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.vaadin.maps.leaflet.layer.other; + +import java.io.Serializable; + +import software.xdev.vaadin.maps.leaflet.base.has.LHasBringTo; +import software.xdev.vaadin.maps.leaflet.base.has.LHasSetStylePath; +import software.xdev.vaadin.maps.leaflet.layer.LAbstractLayerGroup; +import software.xdev.vaadin.maps.leaflet.registry.LComponentManagementRegistry; + + +/** + * @see Leaflet docs + */ +public class LAbstractFeatureGroup> extends LAbstractLayerGroup + implements LHasBringTo, LHasSetStylePath +{ + protected LAbstractFeatureGroup( + final LComponentManagementRegistry compReg, + final String jsConstructorCallExpression, + final Serializable... parameters) + { + super(compReg, jsConstructorCallExpression, parameters); + } +} diff --git a/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/other/LFeatureGroup.java b/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/other/LFeatureGroup.java new file mode 100644 index 00000000..04f8e111 --- /dev/null +++ b/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/other/LFeatureGroup.java @@ -0,0 +1,59 @@ +/* + * Copyright © 2019 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.vaadin.maps.leaflet.layer.other; + +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import software.xdev.vaadin.maps.leaflet.layer.LAbstractLayerGroup; +import software.xdev.vaadin.maps.leaflet.layer.LLayer; +import software.xdev.vaadin.maps.leaflet.layer.LLayerOptions; +import software.xdev.vaadin.maps.leaflet.registry.LComponentManagementRegistry; + + +/** + * @see Leaflet docs + */ +public class LFeatureGroup extends LAbstractLayerGroup +{ + public LFeatureGroup( + final LComponentManagementRegistry compReg, + final LLayer[] layers, + final LLayerOptions[] options) + { + super( + compReg, + "L.featureGroup(" + + (layers != null + ? "[" + Stream.of(layers) + .map(LLayer::clientComponentJsAccessor) + .collect(Collectors.joining(",")) + "]" + : "") + + (options != null + ? ", [" + Stream.of(options) + .map(compReg::writeOptionsOrEmptyObject) + .collect(Collectors.joining(",")) + "]" + : "") + + ")"); + } + + public LFeatureGroup( + final LComponentManagementRegistry compReg, + final LLayer... layers) + { + this(compReg, layers, null); + } +} diff --git a/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/other/LGeoJSONLayer.java b/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/other/LGeoJSONLayer.java new file mode 100644 index 00000000..aab95c34 --- /dev/null +++ b/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/other/LGeoJSONLayer.java @@ -0,0 +1,82 @@ +/* + * Copyright © 2019 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.vaadin.maps.leaflet.layer.other; + +import java.io.Serializable; + +import software.xdev.vaadin.maps.leaflet.layer.LLayer; +import software.xdev.vaadin.maps.leaflet.registry.LComponentManagementRegistry; + + +/** + * @see Leaflet docs + */ +public class LGeoJSONLayer extends LAbstractFeatureGroup +{ + protected LGeoJSONLayer( + final LComponentManagementRegistry compReg, + final String jsConstructorCallExpression, + final Serializable... parameters) + { + super(compReg, jsConstructorCallExpression, parameters); + } + + public LGeoJSONLayer( + final LComponentManagementRegistry compReg, + final String serializedGeoJSON, + final LGeoJSONLayerOptions options) + { + super( + compReg, + "L.geoJSON(" + + serializedGeoJSON + + compReg.writeOptionsOptionalNextParameter(options) + ")"); + } + + public LGeoJSONLayer( + final LComponentManagementRegistry compReg, + final String serializedGeoJSON) + { + this(compReg, serializedGeoJSON, (LGeoJSONLayerOptions)null); + } + + /** + * @see Leaflet docs + */ + public LGeoJSONLayer addData(final String serializedGeoJSON) + { + this.invokeSelf(".addLayer(" + serializedGeoJSON + ")"); + return this.self(); + } + + /** + * @see Leaflet docs + */ + public LGeoJSONLayer resetStyle(final LLayer layer) + { + this.invokeSelf(".resetStyle(" + (layer != null ? layer.clientComponentJsAccessor() : "") + ")"); + return this.self(); + } + + /** + * @see Leaflet docs + */ + public LGeoJSONLayer resetStyle() + { + return this.resetStyle(null); + } + +} diff --git a/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/other/LGeoJSONLayerOptions.java b/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/other/LGeoJSONLayerOptions.java new file mode 100644 index 00000000..cf3ab326 --- /dev/null +++ b/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/other/LGeoJSONLayerOptions.java @@ -0,0 +1,112 @@ +/* + * Copyright © 2019 XDEV Software (https://xdev.software) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package software.xdev.vaadin.maps.leaflet.layer.other; + +import software.xdev.vaadin.maps.leaflet.base.RawString; +import software.xdev.vaadin.maps.leaflet.layer.LInteractiveLayerOptions; + + +/** + * @see Leaflet docs + */ +public class LGeoJSONLayerOptions extends LInteractiveLayerOptions +{ + private RawString pointToLayer; + private RawString style; + private RawString onEachFeature; + private RawString coordsToLatLng; + private Boolean markersInheritOptions; + + public RawString getPointToLayer() + { + return this.pointToLayer; + } + + public void setPointToLayer(final RawString pointToLayer) + { + this.pointToLayer = pointToLayer; + } + + public LGeoJSONLayerOptions withPointToLayer(final RawString pointToLayer) + { + this.setPointToLayer(pointToLayer); + return this.self(); + } + + public RawString getStyle() + { + return this.style; + } + + public void setStyle(final RawString style) + { + this.style = style; + } + + public LGeoJSONLayerOptions withStyle(final RawString style) + { + this.setStyle(style); + return this.self(); + } + + public RawString getOnEachFeature() + { + return this.onEachFeature; + } + + public void setOnEachFeature(final RawString onEachFeature) + { + this.onEachFeature = onEachFeature; + } + + public LGeoJSONLayerOptions withOnEachFeature(final RawString onEachFeature) + { + this.setOnEachFeature(onEachFeature); + return this.self(); + } + + public RawString getCoordsToLatLng() + { + return this.coordsToLatLng; + } + + public void setCoordsToLatLng(final RawString coordsToLatLng) + { + this.coordsToLatLng = coordsToLatLng; + } + + public LGeoJSONLayerOptions withCoordsToLatLng(final RawString coordsToLatLng) + { + this.setCoordsToLatLng(coordsToLatLng); + return this.self(); + } + + public Boolean getMarkersInheritOptions() + { + return this.markersInheritOptions; + } + + public void setMarkersInheritOptions(final Boolean markersInheritOptions) + { + this.markersInheritOptions = markersInheritOptions; + } + + public LGeoJSONLayerOptions withMarkersInheritOptions(final Boolean markersInheritOptions) + { + this.setMarkersInheritOptions(markersInheritOptions); + return this.self(); + } +} diff --git a/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/ui/LMarkerOptions.java b/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/ui/LMarkerOptions.java index b3ece837..bb50accf 100644 --- a/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/ui/LMarkerOptions.java +++ b/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/ui/LMarkerOptions.java @@ -35,6 +35,7 @@ public class LMarkerOptions extends LInteractiveLayerOptions private Double riseOffset; private String shadowPane; private Boolean autoPanFocus; + private Boolean draggable; public LIcon getIcon() { @@ -195,4 +196,20 @@ public LMarkerOptions withAutoPanFocus(final Boolean autoPanFocus) this.setAutoPanFocus(autoPanFocus); return this.self(); } + + public Boolean getDraggable() + { + return this.draggable; + } + + public void setDraggable(final Boolean draggable) + { + this.draggable = draggable; + } + + public LMarkerOptions withDraggable(final Boolean draggable) + { + this.setDraggable(draggable); + return this.self(); + } } diff --git a/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/vector/LPath.java b/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/vector/LPath.java index b81a62ad..fe19e526 100644 --- a/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/vector/LPath.java +++ b/vaadin-maps-leaflet-flow/src/main/java/software/xdev/vaadin/maps/leaflet/layer/vector/LPath.java @@ -19,6 +19,7 @@ import software.xdev.vaadin.maps.leaflet.base.has.LHasBringTo; import software.xdev.vaadin.maps.leaflet.base.has.LHasRedraw; +import software.xdev.vaadin.maps.leaflet.base.has.LHasSetStylePath; import software.xdev.vaadin.maps.leaflet.layer.LInteractiveLayer; import software.xdev.vaadin.maps.leaflet.registry.LComponentManagementRegistry; @@ -27,7 +28,7 @@ * @see Leaflet docs */ public abstract class LPath> extends LInteractiveLayer - implements LHasBringTo, LHasRedraw + implements LHasBringTo, LHasRedraw, LHasSetStylePath { protected LPath( final LComponentManagementRegistry compReg, @@ -36,13 +37,4 @@ protected LPath( { super(compReg, jsConstructorCallExpression, parameters); } - - /** - * @see Leaflet docs - */ - public S setStyle(final LPathOptions options) - { - this.invokeSelf(".setStyle(" + this.componentRegistry().writeOptionsOrEmptyObject(options) + ")"); - return this.self(); - } }