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

@ -48,7 +48,13 @@
<wb-module deploy-name="geoportal-data-viewer-app-3.2.1-SNAPSHOT">
<wb-module deploy-name="geoportal-data-viewer-app-3.2.1">
@ -127,6 +133,9 @@
@ -177,6 +186,9 @@
@ -227,6 +239,9 @@
@ -277,6 +292,9 @@
@ -330,6 +348,9 @@
@ -380,6 +401,9 @@
@ -430,6 +454,9 @@
@ -480,6 +507,9 @@

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);
}
/**