Fixed fit to Extent on features loaded end

This commit is contained in:
Francesco Mangiacrapa 2023-02-07 15:25:53 +01:00
parent 003590f46e
commit 2b6272dd60
7 changed files with 69 additions and 23 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/geoportal-data-viewer-app-3.2.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/geoportal-data-viewer-app-3.2.1/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/geoportal-data-viewer-app-3.2.1-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<classpathentry excluding="**" kind="src" output="target/geoportal-data-viewer-app-3.2.1/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -35,5 +35,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/geoportal-data-viewer-app-3.2.1-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/geoportal-data-viewer-app-3.2.1/WEB-INF/classes"/>
</classpath>

View File

@ -1,4 +1,4 @@
eclipse.preferences.version=1
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-3.2.1-SNAPSHOT
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-3.2.1
warSrcDir=src/main/webapp
warSrcDirIsOutput=false

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
@ -48,8 +48,14 @@
<wb-module deploy-name="geoportal-data-viewer-app-3.2.1-SNAPSHOT">
<wb-module deploy-name="geoportal-data-viewer-app-3.2.1">
@ -99,7 +105,10 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -149,7 +158,10 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -199,7 +211,10 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
@ -249,7 +264,10 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
@ -302,7 +320,10 @@
<dependent-module archiveName="geoportal-data-common-2.0.2.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
<dependency-type>uses</dependency-type>
</dependent-module>
@ -352,7 +373,10 @@
<property name="java-output-path" value="/geoportal-data-viewer-app/target/geoportal-data-viewer-app-0.0.1-SNAPSHOT/WEB-INF/classes"/>
@ -402,7 +426,10 @@
<property name="context-root" value="geoportal-data-viewer-app"/>
@ -452,7 +479,10 @@
</wb-module>

View File

@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- [#24432] Reverting serialization LinkedHashMap<String, String> to LinkedHashMap<String, Object>.
- Improved Alert UX in case of broken shared link
- Moved to gwt 2.9.0
## [v3.2.0] - 2023-01-31

View File

@ -20,7 +20,7 @@
<properties>
<!-- Convenience property to set the GWT version -->
<gwt.version>2.10.0</gwt.version>
<gwt.version>2.9.0</gwt.version>
<gwt.compiler.style>PRETTY</gwt.compiler.style>
<gson.version>2.6.2</gson.version>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>

View File

@ -9,7 +9,6 @@ import java.util.Set;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.RelationshipDV;
@ -910,8 +909,9 @@ public class GeoportalDataViewer implements EntryPoint {
Feature[] features = geoJson.readFeatures(geoJSONFeatures);
GWT.log("features: " + features);
olMapMng.getOLMap().addLayerFeaturesAsHighlight(layerItem, features);
olMapMng.getOLMap().addLayerFeaturesAsHighlight(layerItem, features, true);
/* Fit to extent calculating the features extent
if (projectDV != null) {
GeoJSON spatialReference = projectDV.getSpatialReference();
@ -922,6 +922,7 @@ public class GeoportalDataViewer implements EntryPoint {
if (transfCoord != null)
olMapMng.getOLMap().setCenter(transfCoord);
}
*/
}
}

View File

@ -636,7 +636,7 @@ public abstract class OpenLayerMap {
* @param layerItem the layer item
* @param features the features
*/
public void addLayerFeaturesAsHighlight(LayerItem layerItem, Feature[] features) {
public void addLayerFeaturesAsHighlight(LayerItem layerItem, Feature[] features, boolean fitMapToFeaturesExtent) {
removeLayerFeaturesAsHighlight(layerItem.getName());
@ -649,17 +649,30 @@ public abstract class OpenLayerMap {
style.setStroke(stroke);
Vector vectorSource = OLFactory.createVectorSource();
EventListener<ol.events.Event> listenerE = new EventListener<ol.events.Event>() {
@Override
public void onEvent(ol.events.Event event) {
ol.Extent theExtent = vectorSource.getExtent();
//GWT.log(theExtent.toString());
map.getView().fit(theExtent);
}
};
if (fitMapToFeaturesExtent)
vectorSource.addChangeListener(listenerE);
vectorSource.addFeatures(features);
GWT.log("features: " + features);
// GWT.log("features: " + features);
VectorLayerOptions vectorLayerOptions = new VectorLayerOptions();
vectorLayerOptions.setSource(vectorSource);
vectorLayerOptions.setStyle(style);
// vectorLayerOptions.setMap(map);
GWT.log("vectorLayerOptions: " + vectorLayerOptions);
// GWT.log("vectorLayerOptions: " + vectorLayerOptions);
ol.layer.Vector vector = OLFactory.createVector(vectorLayerOptions);
// vector.setStyle(style);
@ -669,6 +682,7 @@ public abstract class OpenLayerMap {
vectorLayersHighlighted.put(layerItem.getName(), vector);
map.addLayer(vector);
}
/**