Managing visibility of "Go to Layers"

This commit is contained in:
Francesco Mangiacrapa 2022-12-22 16:38:43 +01:00
parent 67b93db8af
commit cb99242958
2 changed files with 21 additions and 7 deletions

View File

@ -53,6 +53,7 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.dom.client.Style.Visibility;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerManager;
@ -984,10 +985,14 @@ public class LayerManager {
}
});
Button buttonViewLayers = new Button("Go to Layers");
final Button buttonViewLayers = new Button("Go to Layers");
buttonViewLayers.getElement().setId("go-to-layers");
buttonViewLayers.getElement().setTitle("Zoom to Layers");
buttonViewLayers.setType(ButtonType.LINK);
if(olMap.getCurrentZoomLevel() >= OLMapManager.LAYER_DETAIL_MAX_RESOLUTION) {
buttonViewLayers.setVisible(false);
}
buttonViewLayers.addClickHandler(new ClickHandler() {
@ -995,7 +1000,7 @@ public class LayerManager {
public void onClick(ClickEvent event) {
GWT.log("View Layers clicked");
fireGoToLayers();
buttonViewLayers.setVisible(false);
}
});
@ -1099,7 +1104,10 @@ public class LayerManager {
@Override
public void onBrowserEvent(Event event) {
if (Event.ONCLICK == event.getTypeInt()) {
//buttonElement.setAttribute("visible", "none");
//buttonElement.getStyle().setVisibility(Visibility.HIDDEN);
fireGoToLayers();
}
}
});
@ -1109,7 +1117,7 @@ public class LayerManager {
}
}.schedule(OpenLayerMap.SET_CENTER_ANIMATION_DURATION + 100);
}.schedule(OpenLayerMap.SET_CENTER_ANIMATED_DURATION + 100);
olMap.setCenter(centerTo);
@ -1118,6 +1126,12 @@ public class LayerManager {
protected void fireGoToLayers() {
int zoomValue = (int) (OLMapManager.LAYER_DETAIL_MAX_RESOLUTION + 1);
olMap.setZoom(zoomValue);
try {
Element buttonElement = DOM.getElementById("go-to-layers");
buttonElement.getStyle().setVisibility(Visibility.HIDDEN);
}catch (Exception e) {
// TODO: handle exception
}
}
protected void fireOpenDetails(LayerObject layerObject, FeatureRow theFeature) {

View File

@ -72,9 +72,9 @@ import ol.source.XyzOptions;
*/
public abstract class OpenLayerMap {
public static final int SET_CENTER_ANIMATION_DURATION = 500;
public static final int SET_CENTER_ANIMATED_DURATION = 500;
public static final int ZOOM_ANIMATE_DURATION = 3000;
public static final int ZOOM_ANIMATED_DURATION = 3000;
public static final int MAX_ZOOM = 21;
@ -305,7 +305,7 @@ public abstract class OpenLayerMap {
AnimationOptions animations = new AnimationOptions();
animations.setCenter(centerCoordinate);
animations.setDuration(SET_CENTER_ANIMATION_DURATION);
animations.setDuration(SET_CENTER_ANIMATED_DURATION);
view.animate(animations);
//view.setCenter(centerCoordinate);
@ -318,7 +318,7 @@ public abstract class OpenLayerMap {
*/
public void setZoom(int zoom) {
AnimationOptions animations = new AnimationOptions();
animations.setDuration(ZOOM_ANIMATE_DURATION);
animations.setDuration(ZOOM_ANIMATED_DURATION);
animations.setZoom(zoom);
view.animate(animations);
//view.setZoom(zoom);