implemented Base Map layers switching

This commit is contained in:
Francesco Mangiacrapa 2021-11-12 12:37:15 +01:00
parent 143fed7c79
commit 6197d40fae
12 changed files with 323 additions and 109 deletions

View File

@ -1,6 +1,7 @@
package org.gcube.portlets.user.geoportaldataviewer.client;
import java.util.Iterator;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
@ -12,6 +13,8 @@ import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerCon
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent.LAYER_TYPE;
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ChangeMapLayerEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ChangeMapLayerEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent;
@ -29,7 +32,9 @@ import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPanel;
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
import com.google.gwt.core.client.EntryPoint;
@ -89,11 +94,31 @@ public class GeoportalDataViewer implements EntryPoint {
private OLMapManager olMapMng = null;
int attempt = 0;
private LoaderIcon loaderApp = new LoaderIcon("Loading application....");
private HTML attributionDiv = new HTML();
/**
* This is the entry point method.
*/
public void onModuleLoad() {
loaderApp.getElement().getStyle().setZIndex(100);
paramWmsRequest = Window.Location.getParameter(GeoportalDataViewerConstants.GET_WMS_PARAMETER);
paramGeonaItemType = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE);
paramGeonaItemID = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID);
paramLayerTitle = Window.Location.getParameter(GeoportalDataViewerConstants.GET_LAYER_TITLE);
GWT.log(GeoportalDataViewerConstants.GET_WMS_PARAMETER + " = " + paramWmsRequest);
GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE + " = " + paramGeonaItemType);
GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID + " = " + paramGeonaItemID);
GWT.log(GeoportalDataViewerConstants.GET_LAYER_TITLE + " = " + paramLayerTitle);
RootPanel.get(APP_DIV).add(loaderApp);
mainPanel = new GeonaDataViewMainPanel(applicationBus, getClientHeight());
RootPanel.get(APP_DIV).add(mainPanel);
@ -102,23 +127,38 @@ public class GeoportalDataViewer implements EntryPoint {
@Override
public void execute() {
olMapMng = new OLMapManager(mainPanel.getMapPanel().getElement().getId(),
layerManager.getLayerManagerBus());
layerManager.setOlMap(olMapMng.getOLOSMMap());
mainPanel.setMap(olMapMng.getOLOSMMap());
String attributionHTML = "<div class='map-credits'><div class='map-attribution-container'>"
+olMapMng.getOLOSMMap().getMapAttribution()+
"</div></div>";
//LOADING THE BASE MAP LAYERS
GeoportalDataViewerServiceAsync.Util.getInstance().getListBaseLayers(new AsyncCallback<List<BaseMapLayer>>() {
RootPanel.get(APP_DIV).add(new HTML(attributionHTML));
@Override
public void onFailure(Throwable caught) {
RootPanel.get(APP_DIV).remove(loaderApp);
Window.alert("Error occurred on instancing the GeoPortale Viewer. Please, contact the support");
}
@Override
public void onSuccess(List<BaseMapLayer> listBaseMapLayers) {
RootPanel.get(APP_DIV).remove(loaderApp);
loadGeonaDataViewerProfile();
mainPanel.setBaseLayers(listBaseMapLayers);
BaseMapLayer firstBaseLayer = listBaseMapLayers.get(0);
//Passing the first base map layer that will be applied as first base layer
olMapMng = new OLMapManager(mainPanel.getMapPanel().getElement().getId(),
layerManager.getLayerManagerBus(), firstBaseLayer);
layerManager.setOlMap(olMapMng.getOLOSMMap());
mainPanel.setMap(olMapMng.getOLOSMMap());
//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();
}
});
//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();
}
});
@ -129,28 +169,15 @@ public class GeoportalDataViewer implements EntryPoint {
}
});
paramWmsRequest = Window.Location.getParameter(GeoportalDataViewerConstants.GET_WMS_PARAMETER);
paramGeonaItemType = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE);
// paramUUID =
// Window.Location.getParameter(GeoportalDataViewerConstants.GET_UUID_PARAMETER);
paramGeonaItemID = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID);
paramLayerTitle = Window.Location.getParameter(GeoportalDataViewerConstants.GET_LAYER_TITLE);
GWT.log(GeoportalDataViewerConstants.GET_WMS_PARAMETER + " = " + paramWmsRequest);
GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE + " = " + paramGeonaItemType);
GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID + " = " + paramGeonaItemID);
// GWT.log(GeoportalDataViewerConstants.GET_UUID_PARAMETER + " = " + paramUUID);
GWT.log(GeoportalDataViewerConstants.GET_LAYER_TITLE + " = " + paramLayerTitle);
// VALIDATING THE LONG FORMAT FOR GID
// try {
// if (paramGeonaItemID != null)
// Long.parseLong(paramGeonaItemID);
// } catch (Exception e) {
// Window.alert("Bad format for parameter " + GeoportalDataViewerConstants.GET_GEONA_ITEM_ID
// + ". It must be a Long");
// paramGeonaItemID = null;
// }
bindEvents();
RootPanel.get(APP_DIV).add(attributionDiv);
}
private void loadGeonaDataViewerProfile() {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
@ -206,8 +233,7 @@ public class GeoportalDataViewer implements EntryPoint {
});
}
});
bindEvents();
}
/**
@ -410,6 +436,30 @@ public class GeoportalDataViewer implements EntryPoint {
}
});
applicationBus.addHandler(ChangeMapLayerEvent.TYPE, new ChangeMapLayerEventHandler() {
@Override
public void onChangeBaseMapLayer(ChangeMapLayerEvent changeMapLayerEvent) {
BaseMapLayer baseLayer = changeMapLayerEvent.getBaseMapLayer();
if (baseLayer == null)
return;
String attributionHTML = "<div class='map-credits'><div class='map-credits-container'>"
+ baseLayer.getAttribution() + "</div></div>";
olMapMng.getOLOSMMap().changeBaseMap(baseLayer);
//THE OSM Contributors are automatically added by gwt-ol, other ones not.
if(!baseLayer.getType().equals(BaseMapLayer.OL_BASE_MAP.OSM)) {
attributionDiv.setHTML(attributionHTML);
}else
attributionDiv.setHTML("");
}
});
}

View File

@ -9,6 +9,7 @@ import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
@ -124,5 +125,7 @@ public interface GeoportalDataViewerService extends RemoteService {
List<GeoNaSpatialQueryResult> getWFSFeatures(List<LayerObject> layerObjects, String mapSrsName,
BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel);
List<BaseMapLayer> getListBaseLayers();
}

View File

@ -9,6 +9,7 @@ import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
@ -58,4 +59,6 @@ public interface GeoportalDataViewerServiceAsync {
void getWFSFeatures(List<LayerObject> layerObjects, String mapSrsName, BoundsMap selectBBOX, int maxWFSFeature,
double zoomLevel, AsyncCallback<List<GeoNaSpatialQueryResult>> callback);
void getListBaseLayers(AsyncCallback<List<BaseMapLayer>> callback);
}

View File

@ -10,6 +10,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
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.client.ui.map.ExtentMapUtil.PLACE;
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;
@ -45,19 +46,21 @@ public class OLMapManager {
*
* @param targetId the target id
* @param layerManagerBus the layer manager bus
* @param baseMapLayer the base map layer
*/
public OLMapManager(String targetId, HandlerManager layerManagerBus) {
public OLMapManager(String targetId, HandlerManager layerManagerBus, BaseMapLayer baseMapLayer) {
this.targetId = targetId;
this.layerManagerBus = layerManagerBus;
instanceOLMap();
instanceOLMap(baseMapLayer);
}
/**
* Instance OL map.
* @param baseMapLayer
*/
public void instanceOLMap() {
public void instanceOLMap(BaseMapLayer baseMapLayer) {
olMap = new OpenLayerOSM(targetId, layerManagerBus) {
olMap = new OpenLayerOSM(targetId, layerManagerBus, baseMapLayer) {
@Override
public void clickListener(MapBrowserEvent event) {

View File

@ -0,0 +1,57 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class ChangeMapLayerEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Nov 12, 2021
*/
public class ChangeMapLayerEvent extends GwtEvent<ChangeMapLayerEventHandler> {
public static Type<ChangeMapLayerEventHandler> TYPE = new Type<ChangeMapLayerEventHandler>();
private BaseMapLayer baseMapLayer;
/**
* Instantiates a new change map layer event.
*
* @param baseMapLayer the base map layer
*/
public ChangeMapLayerEvent(BaseMapLayer baseMapLayer) {
this.baseMapLayer = baseMapLayer;
}
/**
* Gets the associated type.
*
* @return the associated type
*/
@Override
public Type<ChangeMapLayerEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
@Override
protected void dispatch(ChangeMapLayerEventHandler handler) {
handler.onChangeBaseMapLayer(this);
}
/**
* Gets the base map layer.
*
* @return the base map layer
*/
public BaseMapLayer getBaseMapLayer() {
return baseMapLayer;
}
}

View File

@ -0,0 +1,20 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface ChangeMapLayerEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Nov 12, 2021
*/
public interface ChangeMapLayerEventHandler extends EventHandler {
/**
* On change base map layer.
*
* @param changeMapLayerEvent the change map layer event
*/
void onChangeBaseMapLayer(ChangeMapLayerEvent changeMapLayerEvent);
}

View File

@ -142,20 +142,15 @@ public abstract class OpenLayerOSM {
private Layer baseLayerTile;
private String mapAttribution;
/**
* Instantiates a new open layer OSM.
*
* @param divTargetId the div target id
* @param eventBus the event bus
* @param eventBus the event bus
* @param baseLayer the base layer
*/
/*
* (non-Javadoc)
*
* @see de.desjardins.ol3.demo.client.example.Example#show()
*/
public OpenLayerOSM(String divTargetId, HandlerManager eventBus) {
public OpenLayerOSM(String divTargetId, HandlerManager eventBus, BaseMapLayer baseLayer) {
this.eventBus = eventBus;
for (int i = 0; i < 100; i++) {
@ -191,12 +186,6 @@ public abstract class OpenLayerOSM {
map.addInteraction(new KeyboardPan());
map.addInteraction(new KeyboardZoom());
String attribution = "© <a href='https://www.mapbox.com/about/maps/'>Mapbox</a> © <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a> <strong><a href='https://www.mapbox.com/map-feedback/' target='_blank'>Improve this map</a></strong>";
BaseMapLayer baseLayer = new BaseMapLayer(
"https://{a-d}.tiles.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoiZDRzY2llbmNlIiwiYSI6ImNpcW1nZjE4MDAwMXNod25rdHJsemRoNTQifQ.YPNkNLb8EzjThpvJl1tg4w",
attribution, BaseMapLayer.OL_BASE_MAP.MAPBOX);
//applying base map
changeBaseMap(baseLayer);
@ -204,11 +193,15 @@ public abstract class OpenLayerOSM {
}
/**
* 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();
this.mapAttribution = baseLayer.getAttribution();
try {
if (baseLayerTile != null)
@ -221,8 +214,12 @@ public abstract class OpenLayerOSM {
case OSM:
XyzOptions xyzOptions = OLFactory.createOptions();
Osm osmSource = new Osm(xyzOptions);
osmSource.setUrl(baseLayer.getUrl());
//setAttributions is buggy
//osmSource.setAttributions(baseLayer.getAttribution());
LayerOptions layerOptions = OLFactory.createOptions();
layerOptions.setSource(osmSource);
layerOptions.setZIndex(0);
baseLayerTile = new Tile(layerOptions);
break;
@ -231,18 +228,23 @@ public abstract class OpenLayerOSM {
XyzOptions xyzOptions2 = OLFactory.createOptions();
Xyz xyz = new Xyz(xyzOptions2);
xyz.setAttributions(mapAttribution);
//setAttributions is buggy
//xyz.setAttributions(baseLayer.getAttribution());
xyz.setUrl(baseLayer.getUrl());
LayerOptions layerOptions2 = OLFactory.createOptions();
layerOptions2.setSource(xyz);
layerOptions2.setZIndex(0);
baseLayerTile = new Tile(layerOptions2);
break;
}
// map == null at init time
if (map != null)
if (map != null) {
map.addLayer(baseLayerTile);
}
}
@ -863,8 +865,8 @@ public abstract class OpenLayerOSM {
/**
* Swap details layers.
*
* @param layerSource the source index
* @param layerTarget the target index
* @param swapLSource the swap L source
* @param swapLTarget the swap L target
*/
public void swapDetailsLayers(SwapLayer swapLSource, SwapLayer swapLTarget) {
@ -895,8 +897,4 @@ public abstract class OpenLayerOSM {
return map.get((map.keySet().toArray())[index]);
}
public String getMapAttribution() {
return mapAttribution;
}
}

View File

@ -1,14 +1,18 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
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.OpenLayerOSM;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.Images;
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.NavLink;
@ -18,6 +22,8 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.uibinder.client.UiBinder;
@ -27,7 +33,9 @@ import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RadioButton;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
/**
@ -83,12 +91,17 @@ public class GeonaDataViewMainPanel extends Composite {
@UiField
HTMLPanel panelAttribution;
@UiField
HTMLPanel panelBaseLayers;
private MapPanel mapPanel;
private OpenLayerOSM map;
private HandlerManager applicationBus;
/**
* Instantiates a new geona data view main panel.
@ -122,7 +135,7 @@ public class GeonaDataViewMainPanel extends Composite {
bindEvents();
}
private void bindEvents() {
layersDDB.addClickHandler(new ClickHandler() {
@ -332,5 +345,39 @@ public class GeonaDataViewMainPanel extends Composite {
panelAttribution.add(label);
panelAttribution.add(p);
}
public void setBaseLayers(List<BaseMapLayer> listBaseLayers) {
if(listBaseLayers==null)
return;
int i = 0;
for (BaseMapLayer baseMapLayer : listBaseLayers) {
RadioButton radio = new RadioButton("base-layer");
radio.setText(baseMapLayer.getName());
if(i==0) {
radio.setValue(true, true);
}
radio.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
applicationBus.fireEvent(new ChangeMapLayerEvent(baseMapLayer));
}
});
SimplePanel sp = new SimplePanel(radio);
sp.getElement().addClassName("form-inline");
sp.getElement().addClassName("map-layers-radio");
panelBaseLayers.add(sp);
i++;
}
}
}

View File

@ -16,6 +16,10 @@
<g:HTMLPanel ui:field="mainContainerPanel">
<g:HTMLPanel ui:field="mainToolBar"
addStyleNames="inner-toolbar">
<b:DropdownButton type="LINK" text="Map">
<g:HTMLPanel ui:field="panelBaseLayers">
</g:HTMLPanel>
</b:DropdownButton>
<b:DropdownButton type="LINK" text=" " icon="INFO">
<g:HTMLPanel ui:field="panelInfo"
addStyleNames="info-interaction">
@ -31,7 +35,7 @@
Click on the Points shown on the Map to view their features
</b:Paragraph>
<g:HTMLPanel ui:field="panelAttribution"
addStyleNames="info-interaction" visible="false">
addStyleNames="info-interaction" visible="false">
</g:HTMLPanel>
</g:HTMLPanel>
</b:DropdownButton>

View File

@ -34,6 +34,7 @@ import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.Concessio
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accesspolicy.GeoNACheckAccessPolicy;
import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
@ -660,5 +661,31 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
}
}
@Override
public List<BaseMapLayer> getListBaseLayers() {
List<BaseMapLayer> listBL = new ArrayList<BaseMapLayer>();
// OSM
String attribution = "© <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a>";
BaseMapLayer baseLayer = new BaseMapLayer("Open Street Map", "https://tile.openstreetmap.org/{z}/{x}/{y}.png", attribution,
BaseMapLayer.OL_BASE_MAP.OSM);
listBL.add(baseLayer);
// MAPBOX
attribution = "© <a href='https://www.mapbox.com/about/maps/'>Mapbox</a> © <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a> <a href='https://www.mapbox.com/map-feedback/' target='_blank'>Improve this map</a>";
baseLayer = new BaseMapLayer("MapBox Satellite",
"https://{a-d}.tiles.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoiZDRzY2llbmNlIiwiYSI6ImNpcW1nZjE4MDAwMXNod25rdHJsemRoNTQifQ.YPNkNLb8EzjThpvJl1tg4w",
attribution, BaseMapLayer.OL_BASE_MAP.MAPBOX);
listBL.add(baseLayer);
return listBL;
}
}

View File

@ -7,7 +7,7 @@ import java.io.Serializable;
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Nov 11, 2021
* Nov 11, 2021
*/
public class BaseMapLayer implements Serializable {
@ -21,12 +21,13 @@ public class BaseMapLayer implements Serializable {
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Nov 11, 2021
* Nov 11, 2021
*/
public static enum OL_BASE_MAP {
OSM, MAPBOX, OTHER
};
private String name;
private String url;
private String attribution;
private OL_BASE_MAP type;
@ -38,72 +39,59 @@ public class BaseMapLayer implements Serializable {
}
/**
* Instantiates a new base map layer.
*
* @param url the url
* @param attribution the attribution
* @param type the type
*/
public BaseMapLayer(String url, String attribution, OL_BASE_MAP type) {
public BaseMapLayer(String name, String url, String attribution, OL_BASE_MAP type) {
super();
this.name = name;
this.url = url;
this.attribution = attribution;
this.type = type;
}
/**
* Gets the url.
*
* @return the url
*/
public String getName() {
return name;
}
public String getUrl() {
return url;
}
/**
* Gets the attribution.
*
* @return the attribution
*/
public String getAttribution() {
return attribution;
}
/**
* Gets the type.
*
* @return the type
*/
public OL_BASE_MAP getType() {
return type;
}
/**
* Sets the url.
*
* @param url the new url
*/
public void setName(String name) {
this.name = name;
}
public void setUrl(String url) {
this.url = url;
}
/**
* Sets the attribution.
*
* @param attribution the new attribution
*/
public void setAttribution(String attribution) {
this.attribution = attribution;
}
/**
* Sets the type.
*
* @param type the new type
*/
public void setType(OL_BASE_MAP type) {
this.type = type;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("BaseMapLayer [name=");
builder.append(name);
builder.append(", url=");
builder.append(url);
builder.append(", attribution=");
builder.append(attribution);
builder.append(", type=");
builder.append(type);
builder.append("]");
return builder.toString();
}
}

View File

@ -364,12 +364,26 @@ body {
max-height: 25px;
}
.map-attribution-container {
.map-credits-container {
bottom: 0;
right: 0;
position: absolute;
display: block;
margin: 10px 5px;
margin: 0px 0px;
padding: 2px 4px;
background: white;
}
.map-layers-radio {
margin-left: 5px;
}
.map-layers-radio input {
margin-top: 0 !important;
margin-left: 5px;
}
.map-layers-radio label {
margin-left: 5px;
padding-top: 5px;
}