optimized map init
This commit is contained in:
parent
7a36ef5ed5
commit
8dc710686f
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEventHandler;
|
||||
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.URLUtil;
|
||||
|
@ -25,6 +26,9 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
|
|||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.RootPanel;
|
||||
|
||||
import ol.Coordinate;
|
||||
import ol.OLFactory;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Entry point classes define <code>onModuleLoad()</code>.
|
||||
|
@ -82,6 +86,13 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
olMap = new OpenLayerOSM(mainPanel.getMapPanel().getElement().getId(),layerManager.getEventBus());
|
||||
layerManager.setOlMap(olMap);
|
||||
mainPanel.setMap(olMap);
|
||||
|
||||
//EPSG_4326_TO_ITALY
|
||||
Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT);
|
||||
Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
|
||||
|
||||
olMap.setCenter(transformedCenterCoordinate);
|
||||
olMap.setZoom(GeoportalDataViewerConstants.ITALY_FIT_ZOOM_ON);
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
@ -21,5 +21,12 @@ public class GeoportalDataViewerConstants {
|
|||
public static final int MAX_WFS_FEATURES = 5; // zero for no limit
|
||||
|
||||
public static final String NEW_LINE_BR = "<br/>";
|
||||
|
||||
public static final double ITALY_CENTER_LONG = 12.45;
|
||||
|
||||
public static final double ITALY_CENTER_LAT = 42.98;
|
||||
|
||||
public static final int ITALY_FIT_ZOOM_ON = 5;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -95,12 +95,12 @@ import ol.style.TextOptions;
|
|||
// create a view
|
||||
view = new View(viewOptions);
|
||||
|
||||
//EPSG_4326_TO_ITALY
|
||||
Coordinate centerCoordinate = OLFactory.createCoordinate(12.45, 42.98);
|
||||
Coordinate transformedCenterCoordinate = Projection.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
|
||||
|
||||
view.setCenter(transformedCenterCoordinate);
|
||||
view.setZoom(5);
|
||||
// //EPSG_4326_TO_ITALY
|
||||
// Coordinate centerCoordinate = OLFactory.createCoordinate(12.45, 42.98);
|
||||
// Coordinate transformedCenterCoordinate = Projection.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
|
||||
//
|
||||
// view.setCenter(transformedCenterCoordinate);
|
||||
// view.setZoom(5);
|
||||
|
||||
// create the map
|
||||
MapOptions mapOptions = OLFactory.createOptions();
|
||||
|
@ -163,6 +163,25 @@ import ol.style.TextOptions;
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the center.
|
||||
*
|
||||
* @param centerCoordinate the new center
|
||||
*/
|
||||
public void setCenter(Coordinate centerCoordinate) {
|
||||
view.setCenter(centerCoordinate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the center.
|
||||
*
|
||||
* @param centerCoordinate the new center
|
||||
*/
|
||||
public void setZoom(int zoom) {
|
||||
view.setZoom(zoom);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the WMS layer.
|
||||
*
|
||||
|
|
|
@ -112,13 +112,6 @@ public class OpenLayerOSM {
|
|||
|
||||
// create a view
|
||||
view = new View(viewOptions);
|
||||
|
||||
//EPSG_4326_TO_ITALY
|
||||
Coordinate centerCoordinate = OLFactory.createCoordinate(12.45, 42.98);
|
||||
Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
|
||||
|
||||
view.setCenter(transformedCenterCoordinate);
|
||||
view.setZoom(5);
|
||||
|
||||
// create the map
|
||||
MapOptions mapOptions = OLFactory.createOptions();
|
||||
|
@ -182,6 +175,23 @@ public class OpenLayerOSM {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the center.
|
||||
*
|
||||
* @param centerCoordinate the new center
|
||||
*/
|
||||
public void setCenter(Coordinate centerCoordinate) {
|
||||
view.setCenter(centerCoordinate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the center.
|
||||
*
|
||||
* @param centerCoordinate the new center
|
||||
*/
|
||||
public void setZoom(int zoom) {
|
||||
view.setZoom(zoom);
|
||||
}
|
||||
|
||||
|
||||
public void showPopup(String html, Coordinate coordinate) {
|
||||
|
|
|
@ -61,7 +61,13 @@ import ol.OLFactory;
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
olsm = new LightOpenLayerOSM(theMapId);
|
||||
olsm = new LightOpenLayerOSM(theMapId);
|
||||
//EPSG_4326_TO_ITALY
|
||||
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.ITALY_FIT_ZOOM_ON);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue