56 lines
1.4 KiB
Java
56 lines
1.4 KiB
Java
|
package org.gcube.portlets.user.geoportaldataviewer.client.ui.map;
|
||
|
|
||
|
import org.gcube.portlets.user.geoportaldataviewer.client.gis.LightOpenLayerOSM;
|
||
|
|
||
|
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.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.Widget;
|
||
|
|
||
|
import ol.Coordinate;
|
||
|
|
||
|
public class MapView extends Composite{
|
||
|
|
||
|
private static MapViewUiBinder uiBinder = GWT.create(MapViewUiBinder.class);
|
||
|
|
||
|
interface MapViewUiBinder extends UiBinder<Widget, MapView> {
|
||
|
}
|
||
|
|
||
|
@UiField
|
||
|
HTMLPanel theMap;
|
||
|
|
||
|
private LightOpenLayerOSM olsm;
|
||
|
|
||
|
public MapView(Double x, Double y) {
|
||
|
initWidget(uiBinder.createAndBindUi(this));
|
||
|
String theMapId = "map"+Random.nextInt();
|
||
|
theMap.getElement().setId(theMapId);
|
||
|
theMap.setSize("300px", "300px");
|
||
|
|
||
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||
|
|
||
|
@Override
|
||
|
public void execute() {
|
||
|
olsm = new LightOpenLayerOSM(theMapId);
|
||
|
if(x!=null && y!=null) {
|
||
|
Coordinate point = new Coordinate(x, y);
|
||
|
addPoint(point);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
});
|
||
|
|
||
|
}
|
||
|
|
||
|
private void addPoint(Coordinate coordinate){
|
||
|
olsm.addPoint(coordinate);
|
||
|
olsm.getMap().getView().setCenter(coordinate);
|
||
|
|
||
|
}
|
||
|
}
|