|
|
|
@ -23,14 +23,14 @@ import com.google.gwt.user.client.ui.Widget;
|
|
|
|
|
import ol.Coordinate;
|
|
|
|
|
import ol.OLFactory;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The Class MapView.
|
|
|
|
|
*
|
|
|
|
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
|
|
|
|
*
|
|
|
|
|
* Nov 11, 2020
|
|
|
|
|
*/
|
|
|
|
|
public class MapView extends Composite{
|
|
|
|
|
/**
|
|
|
|
|
* The Class MapView.
|
|
|
|
|
*
|
|
|
|
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
|
|
|
|
*
|
|
|
|
|
* Nov 11, 2020
|
|
|
|
|
*/
|
|
|
|
|
public class MapView extends Composite {
|
|
|
|
|
|
|
|
|
|
private static MapViewUiBinder uiBinder = GWT.create(MapViewUiBinder.class);
|
|
|
|
|
|
|
|
|
@ -39,55 +39,47 @@ import ol.OLFactory;
|
|
|
|
|
*
|
|
|
|
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
|
|
|
|
*
|
|
|
|
|
* Nov 11, 2020
|
|
|
|
|
* Nov 11, 2020
|
|
|
|
|
*/
|
|
|
|
|
interface MapViewUiBinder extends UiBinder<Widget, MapView> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
HTMLPanel theMap;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
HorizontalPanel coordinatePanel;
|
|
|
|
|
|
|
|
|
|
private LightOpenLayerOSM olsm;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private LightOpenLayerOSM lightOLSM;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Instantiates a new map view.
|
|
|
|
|
*
|
|
|
|
|
* @param centerTo the center to
|
|
|
|
|
* @param zoom the zoom
|
|
|
|
|
* @param zoom the zoom
|
|
|
|
|
*/
|
|
|
|
|
public MapView(Coordinate centerTo, int zoom, String internalMapWidth, String internalMapHeight) {
|
|
|
|
|
initWidget(uiBinder.createAndBindUi(this));
|
|
|
|
|
String theMapId = "map"+Random.nextInt();
|
|
|
|
|
String theMapId = "map" + Random.nextInt();
|
|
|
|
|
theMap.getElement().setId(theMapId);
|
|
|
|
|
theMap.setWidth(internalMapWidth);
|
|
|
|
|
theMap.setHeight(internalMapHeight);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void execute() {
|
|
|
|
|
olsm = new LightOpenLayerOSM(theMapId);
|
|
|
|
|
|
|
|
|
|
//EPSG_3857 LOCATION TO ITALY
|
|
|
|
|
lightOLSM = new LightOpenLayerOSM(theMapId);
|
|
|
|
|
|
|
|
|
|
// EPSG_3857 LOCATION TO ITALY
|
|
|
|
|
Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY);
|
|
|
|
|
Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857);
|
|
|
|
|
olsm.setCenter(transformedCenterCoordinate);
|
|
|
|
|
olsm.setZoom(GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON);
|
|
|
|
|
|
|
|
|
|
// Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT);
|
|
|
|
|
// Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
|
|
|
|
|
// olsm.setCenter(transformedCenterCoordinate);
|
|
|
|
|
// olsm.setZoom(GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON);
|
|
|
|
|
|
|
|
|
|
//setMapSize();
|
|
|
|
|
|
|
|
|
|
lightOLSM.setCenter(transformedCenterCoordinate);
|
|
|
|
|
lightOLSM.setZoom(GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setMapSize() {
|
|
|
|
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
|
|
|
|
|
|
|
|
@ -95,38 +87,38 @@ import ol.OLFactory;
|
|
|
|
|
public void execute() {
|
|
|
|
|
int width = theMap.getParent().getOffsetWidth();
|
|
|
|
|
int height = theMap.getParent().getOffsetHeight();
|
|
|
|
|
if(width==0)
|
|
|
|
|
if (width == 0)
|
|
|
|
|
width = 300;
|
|
|
|
|
|
|
|
|
|
if(height==0)
|
|
|
|
|
|
|
|
|
|
if (height == 0)
|
|
|
|
|
height = 300;
|
|
|
|
|
|
|
|
|
|
GWT.log("Internal Map w: "+width + ", h: "+height);
|
|
|
|
|
theMap.setSize(width+"px", height+"px");
|
|
|
|
|
|
|
|
|
|
GWT.log("Internal Map w: " + width + ", h: " + height);
|
|
|
|
|
theMap.setSize(width + "px", height + "px");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds the marker.
|
|
|
|
|
*
|
|
|
|
|
* @param coordinate the coordinate
|
|
|
|
|
* @param coordinate the coordinate
|
|
|
|
|
* @param showCoordinateText the show coordinate text
|
|
|
|
|
*/
|
|
|
|
|
public void addMarker(Coordinate coordinate, boolean showCoordinateText) {
|
|
|
|
|
|
|
|
|
|
public void addMarker(Coordinate coordinate, boolean showCoordinateText) {
|
|
|
|
|
|
|
|
|
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void execute() {
|
|
|
|
|
if(olsm!=null) {
|
|
|
|
|
olsm.addPoint(coordinate, showCoordinateText, true);
|
|
|
|
|
olsm.getMap().getView().setCenter(coordinate);
|
|
|
|
|
if (lightOLSM != null) {
|
|
|
|
|
lightOLSM.addPoint(coordinate, showCoordinateText, true);
|
|
|
|
|
lightOLSM.getMap().getView().setCenter(coordinate);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds the WMS layer.
|
|
|
|
|
*
|
|
|
|
@ -139,12 +131,12 @@ import ol.OLFactory;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void execute() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ExtentWrapped ew = null;
|
|
|
|
|
BoundsMap theBBOX = bbox;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (bbox != null) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Coordinate lower = OLFactory.createCoordinate(bbox.getLowerLeftX(), bbox.getLowerLeftY());
|
|
|
|
|
Coordinate lowerCoord = MapUtils.transformCoordiante(lower, MAP_PROJECTION.EPSG_4326.getName(),
|
|
|
|
|
MAP_PROJECTION.EPSG_3857.getName());
|
|
|
|
@ -152,22 +144,27 @@ import ol.OLFactory;
|
|
|
|
|
Coordinate upper = OLFactory.createCoordinate(bbox.getUpperRightX(), bbox.getUpperRightY());
|
|
|
|
|
Coordinate upperCoord = MapUtils.transformCoordiante(upper, MAP_PROJECTION.EPSG_4326.getName(),
|
|
|
|
|
MAP_PROJECTION.EPSG_3857.getName());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ew = new ExtentWrapped(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY());
|
|
|
|
|
theBBOX = new BoundsMap(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY(), null);
|
|
|
|
|
theBBOX = new BoundsMap(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY(),
|
|
|
|
|
null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
olsm.addWMSLayer(mapServerHost, layerName, theBBOX);
|
|
|
|
|
|
|
|
|
|
lightOLSM.addWMSLayer(mapServerHost, layerName, theBBOX);
|
|
|
|
|
|
|
|
|
|
if (ew != null) {
|
|
|
|
|
|
|
|
|
|
olsm.getMap().getView().fit(ew);
|
|
|
|
|
|
|
|
|
|
lightOLSM.getMap().getView().fit(ew);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public LightOpenLayerOSM getLightOLSM() {
|
|
|
|
|
return lightOLSM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|