Added new set of icons

This commit is contained in:
Francesco Mangiacrapa 2021-11-16 14:07:59 +01:00
parent 002d6d2301
commit 4ae0c39983
19 changed files with 324 additions and 71 deletions

View File

@ -99,6 +99,8 @@ public class GeoportalDataViewer implements EntryPoint {
private HTML attributionDiv = new HTML();
private static List<BaseMapLayer> listBaseMapLayers = null;
/**
* This is the entry point method.
*/
@ -137,6 +139,7 @@ public class GeoportalDataViewer implements EntryPoint {
@Override
public void onSuccess(List<BaseMapLayer> listBaseMapLayers) {
RootPanel.get(APP_DIV).remove(loaderApp);
GeoportalDataViewer.listBaseMapLayers = listBaseMapLayers;
//now the map is loaded and I'm sure that I can load the GeonaDataViewer Profile
loadGeonaDataViewerProfile();
mainPanel.setBaseLayers(listBaseMapLayers);
@ -149,7 +152,6 @@ public class GeoportalDataViewer implements EntryPoint {
layerManager.setOLMap(olMap);
mainPanel.setMap(olMap);
//mainPanel.setMapAttribution(olMapMng.getOLOSMMap().getMapAttribution());
updateSize();
ScriptInjector.fromUrl("//cdnjs.cloudflare.com/ajax/libs/nanogallery2/3.0.5/jquery.nanogallery2.min.js")
.setWindow(ScriptInjector.TOP_WINDOW).inject();
@ -176,6 +178,10 @@ public class GeoportalDataViewer implements EntryPoint {
RootPanel.get(APP_DIV).add(attributionDiv);
}
public static List<BaseMapLayer> getListBaseMapLayers() {
return listBaseMapLayers;
}
private void loadGeonaDataViewerProfile() {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {

View File

@ -5,9 +5,11 @@ import java.util.HashMap;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewer;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.Images;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE;
@ -34,6 +36,7 @@ import ol.interaction.KeyboardPan;
import ol.interaction.KeyboardZoom;
import ol.layer.Base;
import ol.layer.Image;
import ol.layer.Layer;
import ol.layer.LayerOptions;
import ol.layer.Tile;
import ol.layer.VectorLayerOptions;
@ -44,6 +47,7 @@ import ol.source.ImageWmsOptions;
import ol.source.ImageWmsParams;
import ol.source.Osm;
import ol.source.Source;
import ol.source.Xyz;
import ol.source.XyzOptions;
import ol.style.Icon;
import ol.style.IconOptions;
@ -78,7 +82,11 @@ public class LightOpenLayerMap {
private ol.layer.Vector geometryLayer;
private String markerURL = Images.ICONS.mapMarkerIcon().getURL();
private String markerURL = GNAImages.ICONS.mapMarkerIcon().getURL();
private LayerOrder layerOrder = new LayerOrder();
private Layer baseLayerTile;
/**
* Instantiates a new light open layer map.
@ -87,15 +95,6 @@ public class LightOpenLayerMap {
*/
public LightOpenLayerMap(String divTargetId) {
// create a OSM-layer
XyzOptions osmSourceOptions = OLFactory.createOptions();
osmSourceOptions.setCrossOrigin("Anonymous");
// osmSourceOptions.setTileLoadFunction(null);
Osm osmSource = new Osm(osmSourceOptions);
LayerOptions osmLayerOptions = OLFactory.createOptions();
osmLayerOptions.setSource(osmSource);
Tile osmLayer = new Tile(osmLayerOptions);
// create a projection
projectionOptions.setCode(MAP_PROJECTION.EPSG_3857.getName());
projectionOptions.setUnits("m");
@ -114,7 +113,7 @@ public class LightOpenLayerMap {
map = new Map(mapOptions);
map.addLayer(osmLayer);
//map.addLayer(osmLayer);
// map.addLayer(tileDebugLayer);
Attribution attribution = new Attribution();
@ -162,6 +161,72 @@ public class LightOpenLayerMap {
map.addInteraction(new KeyboardPan());
map.addInteraction(new KeyboardZoom());
List<BaseMapLayer> listBaseMapLayers = GeoportalDataViewer.getListBaseMapLayers();
BaseMapLayer bml = null;
if(listBaseMapLayers!=null)
bml = listBaseMapLayers.get(0);
changeBaseMap(bml);
}
/**
* Change base map.
*
* @param baseLayer the base layer
*/
public void changeBaseMap(BaseMapLayer baseLayer) {
BaseMapLayer.OL_BASE_MAP baseMap = baseLayer.getType() == null ? BaseMapLayer.OL_BASE_MAP.OSM
: baseLayer.getType();
try {
if (baseLayerTile != null)
map.removeLayer(baseLayerTile);
} catch (Exception e) {
}
switch (baseMap) {
case MAPBOX:
case OTHER:
XyzOptions xyzOptions2 = OLFactory.createOptions();
xyzOptions2.setCrossOrigin("Anonymous");
Xyz xyz = new Xyz(xyzOptions2);
//setAttributions is buggy
//xyz.setAttributions(baseLayer.getAttribution());
xyz.setUrl(baseLayer.getUrl());
LayerOptions layerOptions2 = OLFactory.createOptions();
layerOptions2.setSource(xyz);
int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.BASE_MAP)+1;
layerOptions2.setZIndex(zIndex);
baseLayerTile = new Tile(layerOptions2);
break;
case OSM:
default:
XyzOptions osmSourceOptions = OLFactory.createOptions();
osmSourceOptions.setCrossOrigin("Anonymous");
Osm osmSource = new Osm(osmSourceOptions);
//osmSource.setUrl(baseLayer.getUrl());
//setAttributions is buggy
//osmSource.setAttributions(baseLayer.getAttribution());
LayerOptions layerOptions = OLFactory.createOptions();
layerOptions.setSource(osmSource);
zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.BASE_MAP)+1;
layerOptions.setZIndex(zIndex);
baseLayerTile = new Tile(layerOptions);
break;
}
// map == null at init time
if (map != null) {
map.addLayer(baseLayerTile);
}
}
/**
@ -212,6 +277,8 @@ public class LightOpenLayerMap {
layerOptions.setSource(imageWMSSource);
ol.layer.Image wmsLayer = new ol.layer.Image(layerOptions);
int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.WMS_DETAIL)+1;
wmsLayer.setZIndex(zIndex);
// visibleLayerItems
map.addLayer(wmsLayer);
@ -370,6 +437,8 @@ public class LightOpenLayerMap {
VectorLayerOptions vectorLayerOptions = new VectorLayerOptions();
vectorLayerOptions.setSource(vector);
geometryLayer = new ol.layer.Vector(vectorLayerOptions);
int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.VECTOR)+1;
geometryLayer.setZIndex(zIndex);
map.addLayer(geometryLayer);
}

View File

@ -0,0 +1,37 @@
package org.gcube.portlets.user.geoportaldataviewer.client.resources;
import com.github.gwtbootstrap.client.ui.constants.BaseIconType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
public interface GNAIcons extends ClientBundle {
/** My custom base icon collection */
public enum CustomIconType implements BaseIconType {
MAP("map"),
PRESET_LOCATION("preset_location"),
LAYERS("layers");
/** Inject the icon's css once at first usage */
static {
GNAImages icons = GWT.create(GNAImages.class);
icons.css().ensureInjected();
}
private static final String PREFIX = "myBaseIcon_";
private String className;
private CustomIconType(String className) {
this.className = className;
}
/**
* {@inheritDoc}
*/
@Override
public String get() {
return PREFIX + className;
}
}
}

View File

@ -0,0 +1,41 @@
package org.gcube.portlets.user.geoportaldataviewer.client.resources;
import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.CssResource;
import com.google.gwt.resources.client.ImageResource;
public interface GNAImages extends ClientBundle {
/** Get access to the css resource during gwt compilation */
@Source("baseIcons.css")
CssResource css();
public static final GNAImages ICONS = GWT.create(GNAImages.class);
/** Our sample image icon. Makes the image resource for the gwt-compiler's css composer accessible */
@Source("map.png")
ImageResource map();
@Source("preset_location.png")
ImageResource preset_location();
@Source("layers.png")
ImageResource layers();
@Source("loading.gif")
ImageResource loading();
@Source("map-marker-icon.png")
ImageResource mapMarkerIcon();
@Source("icon_share.png")
ImageResource shareIcon();
@Source("italy.png")
ImageResource italyIcon();
@Source("world.png")
ImageResource worldIcon();
}

View File

@ -1,25 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.client.resources;
import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;
public interface Images extends ClientBundle {
public static final Images ICONS = GWT.create(Images.class);
@Source("loading.gif")
ImageResource loading();
@Source("map-marker-icon.png")
ImageResource mapMarkerIcon();
@Source("icon_share.png")
ImageResource shareIcon();
@Source("italy.png")
ImageResource italyIcon();
@Source("world.png")
ImageResource worldIcon();
}

View File

@ -0,0 +1,25 @@
/* Prevent our icons from css obfuscation */
@external .myBaseIcon_*; /* Do some css stuff */
@sprite .myBaseIcon_map {
gwt-image: "map";
display: inline-block;
vertical-align: middle;
margin-bottom: 3px;
margin-right: 2px;
}
@sprite .myBaseIcon_preset_location {
gwt-image: "preset_location";
display: inline-block;
vertical-align: middle;
margin-bottom: 3px;
margin-right: 2px;
}
@sprite .myBaseIcon_layers {
gwt-image: "layers";
display: inline-block;
vertical-align: middle;
margin-bottom: 3px;
margin-right: 2px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 581 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 683 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -9,12 +9,14 @@ import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerCon
import org.gcube.portlets.user.geoportaldataviewer.client.events.ChangeMapLayerEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerMap;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.Images;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAIcons;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.DropdownButton;
import com.github.gwtbootstrap.client.ui.NavLink;
import com.github.gwtbootstrap.client.ui.Paragraph;
import com.github.gwtbootstrap.client.ui.constants.IconType;
@ -84,7 +86,7 @@ public class GeonaDataViewMainPanel extends Composite {
Button extentToEarth;
@UiField
Button layersDDB;
Button linkLayers;
@UiField
ScrollPanel overlayLayersPanel;
@ -95,6 +97,12 @@ public class GeonaDataViewMainPanel extends Composite {
@UiField
HTMLPanel panelBaseLayers;
@UiField
DropdownButton linkMap;
@UiField
DropdownButton linkPresetLocation;
private MapPanel mapPanel;
private OpenLayerMap map;
@ -102,7 +110,6 @@ public class GeonaDataViewMainPanel extends Composite {
private HandlerManager applicationBus;
/**
* Instantiates a new geona data view main panel.
*
@ -121,16 +128,20 @@ public class GeonaDataViewMainPanel extends Composite {
dataBoxSelection.setIcon(IconType.BOOKMARK);
removeQuery.setIcon(IconType.REMOVE);
Image italyImg = new Image(Images.ICONS.italyIcon());
Image italyImg = new Image(GNAImages.ICONS.italyIcon());
italyImg.getElement().getStyle().setPaddingLeft(20, Unit.PX);
extentToItaly.getElement().appendChild(italyImg.getElement());
extentToItaly.setWidth("140px");
Image worldImg = new Image(Images.ICONS.worldIcon());
Image worldImg = new Image(GNAImages.ICONS.worldIcon());
worldImg.getElement().getStyle().setPaddingLeft(20, Unit.PX);
extentToEarth.getElement().appendChild(worldImg.getElement());
extentToEarth.setWidth("140px");
linkMap.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get());
linkPresetLocation.setCustomIconStyle(GNAIcons.CustomIconType.PRESET_LOCATION.get());
linkLayers.setCustomIconStyle(GNAIcons.CustomIconType.LAYERS.get());
// layersDDB.setToggle(true);
bindEvents();
@ -138,7 +149,7 @@ public class GeonaDataViewMainPanel extends Composite {
private void bindEvents() {
layersDDB.addClickHandler(new ClickHandler() {
linkLayers.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
@ -294,7 +305,7 @@ public class GeonaDataViewMainPanel extends Composite {
* @return the layers DDB
*/
public Button getLayersDDB() {
return layersDDB;
return linkLayers;
}
/**
@ -314,7 +325,7 @@ public class GeonaDataViewMainPanel extends Composite {
}
private void layersDDBClickEvent() {
layersDDB.fireEvent(new GwtEvent<ClickHandler>() {
linkLayers.fireEvent(new GwtEvent<ClickHandler>() {
@Override
public com.google.gwt.event.shared.GwtEvent.Type<ClickHandler> getAssociatedType() {
return ClickEvent.getType();
@ -358,7 +369,7 @@ public class GeonaDataViewMainPanel extends Composite {
RadioButton radio = new RadioButton("base-layer");
radio.setText(baseMapLayer.getName());
if(i==0) {
radio.setValue(true, true);
radio.setValue(true, false);
}
radio.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

View File

@ -35,12 +35,12 @@
</g:HTMLPanel>
</g:HTMLPanel>
</b:DropdownButton>
<b:DropdownButton type="LINK" text="Map">
<b:DropdownButton type="LINK" title="Select the Map" text="Map" ui:field="linkMap">
<g:HTMLPanel ui:field="panelBaseLayers">
</g:HTMLPanel>
</b:DropdownButton>
<b:DropdownButton type="LINK"
text="Preset Location" icon="TH_LARGE">
title="Center Map to Location" text="Preset Location" ui:field="linkPresetLocation">
<b:Nav>
<b:Button type="LINK" ui:field="extentToItaly"
text="Italy" title="Center to Italy"></b:Button>
@ -62,7 +62,7 @@
</b:DropdownButton>
<b:Button type="LINK" ui:field="removeQuery"
text="Remove Query" visible="false"></b:Button>
<b:Button type="LINK" text="Layers" ui:field="layersDDB">
<b:Button type="LINK" text="Layers" ui:field="linkLayers">
</b:Button>
<g:ScrollPanel ui:field="overlayLayersPanel"
addStyleNames="layers-panel" visible="false"></g:ScrollPanel>

View File

@ -1,23 +1,33 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.map;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewer;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.LightOpenLayerMap;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAIcons;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.PLACE;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import com.github.gwtbootstrap.client.ui.DropdownButton;
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.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Random;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.RadioButton;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
import ol.Coordinate;
@ -44,9 +54,15 @@ public class MapView extends Composite {
interface MapViewUiBinder extends UiBinder<Widget, MapView> {
}
@UiField
HTMLPanel panelBaseLayers;
@UiField
HTMLPanel theMap;
@UiField
DropdownButton linkMap;
@UiField
HorizontalPanel coordinatePanel;
@ -67,11 +83,14 @@ public class MapView extends Composite {
theMap.setWidth(internalMapWidth);
theMap.setHeight(internalMapHeight);
linkMap.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get());
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
lightOLSM = new LightOpenLayerMap(theMapId);
setBaseLayers();
// EPSG_3857 LOCATION TO ITALY
Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY);
@ -82,6 +101,44 @@ public class MapView extends Composite {
});
}
public void setBaseLayers() {
List<BaseMapLayer> listBaseLayers = GeoportalDataViewer.getListBaseMapLayers();
if(listBaseLayers==null)
return;
int i = 0;
String radioId = "base_layer_" + Random.nextInt()+Random.nextInt();
for (BaseMapLayer baseMapLayer : listBaseLayers) {
RadioButton radio = new RadioButton(radioId);
radio.setText(baseMapLayer.getName());
if(i==0) {
radio.setValue(true, false);
}
radio.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
//applicationBus.fireEvent(new ChangeMapLayerEvent(baseMapLayer));
lightOLSM.changeBaseMap(baseMapLayer);
}
});
SimplePanel sp = new SimplePanel(radio);
sp.getElement().addClassName("form-inline");
sp.getElement().addClassName("map-layers-radio");
panelBaseLayers.add(sp);
i++;
}
}
private void setMapSize() {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {

View File

@ -1,23 +1,17 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.internalMap {
height: 280px;
display: inline-block;
margin: 0 auto;
/*float: right;*/
}
.map-style {
width: 100%;
text-align:center;
margin-top: 10px;
margin-bottom: 20px;
}
</ui:style>
<g:HTMLPanel addStyleNames="{style.map-style}">
<g:HTMLPanel ui:field="theMap"
addStyleNames="{style.internalMap}">
<g:HTMLPanel addStyleNames="map-style">
<g:HTMLPanel ui:field="theMap" addStyleNames="internalMap">
<b:DropdownButton type="LINK" title="Select the Map"
addStyleNames="baseLayersMapLink" ui:field="linkMap">
<g:HTMLPanel ui:field="panelBaseLayers">
</g:HTMLPanel>
</b:DropdownButton>
</g:HTMLPanel>
<g:HorizontalPanel ui:field="coordinatePanel"
visible="false"></g:HorizontalPanel>

View File

@ -3,7 +3,7 @@
*/
package org.gcube.portlets.user.geoportaldataviewer.client.util;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.Images;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
@ -18,7 +18,7 @@ import com.google.gwt.user.client.ui.Image;
public class LoaderIcon extends HorizontalPanel{
private Image imgLoading = new Image(Images.ICONS.loading());
private Image imgLoading = new Image(GNAImages.ICONS.loading());
private HTML txtLoading = new HTML("");
/**

View File

@ -24,7 +24,7 @@ public class GeoNaSpatialQueryResult implements Serializable {
private static final long serialVersionUID = 3513120677727206958L;
private List<FeatureRow> features;
private LayerObject sourceLayerObject;
// Map with couple (mongoId concessione, list of uploaded Images for the concessione)
// Map with couple (mongoId concessione, list of uploaded GNAImages for the concessione)
private Map<String, List<UploadedImageDV>> mapImages = null;
/**

View File

@ -387,3 +387,41 @@ body {
margin-left: 5px;
padding-top: 5px;
}
/************ INTERNAL MAP***************/
.internalMap {
height: 280px;
display: inline-block;
margin: 0 auto;
/*float: right;*/
}
.map-style {
width: 100%;
margin-top: 10px;
margin-bottom: 20px;
text-align: center;
}
.baseLayersMapLink {
width: 100%;
text-align: left;
left: 40px;
top: 40px;
z-index: 10;
}
.baseLayersMapLink .btn-link {
border: 1px solid #eee;
background-color: #fcfcfc;
margin: 1px;
}
.baseLayersMapLink .btn-link:hover, .inner-toolbar .btn-link:focus {
background-color: #f3f3f3 !important;
text-decoration: none;
}