use of org.cesiumjs.cs.widgets.ViewerPanel in project gwt-cs by iSergio.
the class CustomGeocoder method buildPanel.
@Override
public void buildPanel() {
OpenStreetMapNominatimGeocoder openStreetMapNominatimGeocoder = new OpenStreetMapNominatimGeocoder();
openStreetMapNominatimGeocoder.geocode = new OpenStreetMapNominatimGeocoder.Geocode() {
@Override
public Promise<JsObject, Void> function(String input) {
String endpoint = "http://nominatim.openstreetmap.org/search?";
String query = "format=json&q=" + input;
String requestString = endpoint + query;
Promise<JsObject, Void> promise = Resource.fetchJson(requestString);
promise.then(new Fulfill<JsObject>() {
@Override
public void onFulfilled(JsObject value) {
JSONArray jsonArray = new JSONArray(value);
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.get(i).isObject();
JSONArray bboxDegrees = jsonObject.get("boundingbox").isArray();
Rectangle destination = Rectangle.fromDegrees(Double.parseDouble(bboxDegrees.get(2).isString().toString().replace("\"", "")), Double.parseDouble(bboxDegrees.get(0).isString().toString().replace("\"", "")), Double.parseDouble(bboxDegrees.get(3).isString().toString().replace("\"", "")), Double.parseDouble(bboxDegrees.get(1).isString().toString().replace("\"", "")));
GeocoderResult geocoderResult = new GeocoderResult();
geocoderResult.displayName = jsonObject.get("display_name").isString().toString();
geocoderResult.destinationRectangle = destination;
jsonArray.set(i, new JSONObject((JsObject) (Object) geocoderResult));
}
}
});
return promise;
}
};
ViewerOptions viewerOptions = new ViewerOptions();
viewerOptions.geocoder = openStreetMapNominatimGeocoder;
csVPanel = new ViewerPanel(viewerOptions);
contentPanel.add(new HTML("<p>Example of a custom geocoder.</p>"));
contentPanel.add(csVPanel);
initWidget(contentPanel);
}
use of org.cesiumjs.cs.widgets.ViewerPanel in project gwt-cs by iSergio.
the class Drawing method buildPanel.
@Override
public void buildPanel() {
csVPanel = new ViewerPanel();
csVPanel.getViewer().scene().globe.depthTestAgainstTerrain = true;
Image image = new Image(GWT.getModuleBaseURL() + "images/point.png");
image.setPixelSize(22, 22);
drawPointTBtn = new ToggleButton(image);
drawPointTBtn.setPixelSize(22, 22);
drawPointTBtn.getElement().getStyle().setBackgroundImage("none");
drawPointTBtn.getElement().getStyle().setBorderColor("rgba(63,66,70,1)");
drawPointTBtn.getElement().getStyle().setBackgroundColor("rgba(63,66,70,0.7)");
drawPointTBtn.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
drawExtentTBtn.setValue(false, false);
drawPolygonTBtn.setValue(false, false);
drawCircleTBtn.setValue(false, false);
if (drawInteraction != null) {
drawInteraction.destroy();
drawInteraction = null;
}
if (event.getValue()) {
DrawInteractionOptions options = new DrawInteractionOptions();
options.type = PrimitiveType.POINT;
options.markerType = MarkerType.BILLBOARD_GRAPHIC;
drawInteraction = new DrawInteraction(csVPanel.getViewer().scene(), options);
drawInteraction.addDrawListener(new DrawInteractionListener(), DrawInteraction.EventType.DRAW_END);
}
}
});
image = new Image(GWT.getModuleBaseURL() + "images/line.png");
image.setPixelSize(22, 22);
drawLineTBtn = new ToggleButton(image);
drawLineTBtn.setPixelSize(22, 22);
drawLineTBtn.getElement().getStyle().setBackgroundImage("none");
drawLineTBtn.getElement().getStyle().setBorderColor("rgba(63,66,70,1)");
drawLineTBtn.getElement().getStyle().setBackgroundColor("rgba(63,66,70,0.7)");
drawLineTBtn.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
drawExtentTBtn.setValue(false, false);
drawPolygonTBtn.setValue(false, false);
drawCircleTBtn.setValue(false, false);
if (drawInteraction != null) {
drawInteraction.destroy();
drawInteraction = null;
}
if (event.getValue()) {
DrawInteractionOptions options = new DrawInteractionOptions();
options.type = PrimitiveType.CORRIDOR;
options.markerType = MarkerType.BILLBOARD_GRAPHIC;
drawInteraction = new DrawInteraction(csVPanel.getViewer().scene(), options);
drawInteraction.addDrawListener(new DrawInteractionListener(), DrawInteraction.EventType.DRAW_END);
}
}
});
image = new Image(GWT.getModuleBaseURL() + "images/rect.png");
image.setPixelSize(22, 22);
drawExtentTBtn = new ToggleButton(image);
drawExtentTBtn.setPixelSize(22, 22);
drawExtentTBtn.getElement().getStyle().setBackgroundImage("none");
drawExtentTBtn.getElement().getStyle().setBorderColor("rgba(63,66,70,1)");
drawExtentTBtn.getElement().getStyle().setBackgroundColor("rgba(63,66,70,0.7)");
drawExtentTBtn.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
drawLineTBtn.setValue(false, false);
drawPolygonTBtn.setValue(false, false);
drawCircleTBtn.setValue(false, false);
if (drawInteraction != null) {
drawInteraction.destroy();
drawInteraction = null;
}
if (event.getValue()) {
DrawInteractionOptions options = new DrawInteractionOptions();
options.markerType = MarkerType.BILLBOARD_GRAPHIC;
options.outlineColor = Color.RED();
options.outlineWidth = 1;
drawInteraction = new DrawInteraction(csVPanel.getViewer().scene(), options);
drawInteraction.addDrawListener(new DrawInteractionListener(), DrawInteraction.EventType.DRAW_END);
// As Entity
// drawInteraction.addDrawListener(new DrawInteraction.Listener() {
// @Override
// public void onDraw(DrawInteraction.Event event) {
// if (!(event.getPrimitive() instanceof RectanglePrimitive)) {
// return;
// }
// RectanglePrimitive primitive = ((RectanglePrimitive) event.getPrimitive());
// Rectangle rectangle = primitive.getRectangle();
//
// RectangleGraphicsOptions rectangleGraphicsOptions = new RectangleGraphicsOptions();
// rectangleGraphicsOptions.coordinates = new ConstantProperty<>(rectangle);
// rectangleGraphicsOptions.material = new ColorMaterialProperty(Color.RED().withAlpha(0.5f));
//
// EntityOptions entityOptions = new EntityOptions();
// entityOptions.rectangle = new RectangleGraphics(rectangleGraphicsOptions);
//
// csVPanel.getViewer().entities().add(entityOptions);
// }
// }, DrawInteraction.EventType.DRAW_END);
}
}
});
image = new Image(GWT.getModuleBaseURL() + "images/polygon.png");
image.setPixelSize(22, 22);
drawPolygonTBtn = new ToggleButton(image);
drawPolygonTBtn.setPixelSize(22, 22);
drawPolygonTBtn.getElement().getStyle().setBackgroundImage("none");
drawPolygonTBtn.getElement().getStyle().setBorderColor("rgba(63,66,70,1)");
drawPolygonTBtn.getElement().getStyle().setBackgroundColor("rgba(63,66,70,0.7)");
drawPolygonTBtn.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
drawLineTBtn.setValue(false, false);
drawExtentTBtn.setValue(false, false);
drawCircleTBtn.setValue(false, false);
if (drawInteraction != null) {
drawInteraction.destroy();
drawInteraction = null;
}
if (event.getValue()) {
DrawInteractionOptions options = new DrawInteractionOptions();
options.type = PrimitiveType.POLYGON;
options.markerType = MarkerType.BILLBOARD_GRAPHIC;
options.color = Color.BLUE().withAlpha(0.5f);
drawInteraction = new DrawInteraction(csVPanel.getViewer().scene(), options);
// As GroundPrimitive
drawInteraction.addDrawListener(new DrawInteractionListener(), DrawInteraction.EventType.DRAW_END);
}
}
});
image = new Image(GWT.getModuleBaseURL() + "images/circle.png");
image.setPixelSize(22, 22);
drawCircleTBtn = new ToggleButton(image);
drawCircleTBtn.setPixelSize(22, 22);
drawCircleTBtn.getElement().getStyle().setBackgroundImage("none");
drawCircleTBtn.getElement().getStyle().setBorderColor("rgba(63,66,70,1)");
drawCircleTBtn.getElement().getStyle().setBackgroundColor("rgba(63,66,70,0.7)");
drawCircleTBtn.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
drawLineTBtn.setValue(false, false);
drawExtentTBtn.setValue(false, false);
drawPolygonTBtn.setValue(false, false);
if (drawInteraction != null) {
drawInteraction.destroy();
drawInteraction = null;
}
if (event.getValue()) {
DrawInteractionOptions options = new DrawInteractionOptions();
options.type = PrimitiveType.CIRCLE;
options.markerType = MarkerType.BILLBOARD_GRAPHIC;
drawInteraction = new DrawInteraction(csVPanel.getViewer().scene(), options);
// As GroundPrimitive
drawInteraction.addDrawListener(new DrawInteractionListener(), DrawInteraction.EventType.DRAW_END);
}
}
});
final FlexTable flexTable = new FlexTable();
flexTable.setWidget(1, 0, drawPointTBtn);
flexTable.setWidget(2, 0, drawLineTBtn);
flexTable.setWidget(3, 0, drawExtentTBtn);
flexTable.setWidget(4, 0, drawPolygonTBtn);
flexTable.setWidget(5, 0, drawCircleTBtn);
final AbsolutePanel aPanel = new AbsolutePanel();
aPanel.add(csVPanel);
aPanel.add(flexTable, RootPanel.get().getOffsetWidth() - 74, 42);
contentPanel.add(new HTML("<p>Use Viewer to start building new applications or easily embed Cesium into existing applications.</p>"));
contentPanel.add(aPanel);
Window.addResizeHandler(new ResizeHandler() {
@Override
public void onResize(ResizeEvent resizeEvent) {
aPanel.setWidgetPosition(flexTable, RootPanel.get().getOffsetWidth() - 74, 42);
}
});
initWidget(contentPanel);
}
use of org.cesiumjs.cs.widgets.ViewerPanel in project gwt-cs by iSergio.
the class GeoJSONsimplestyle method buildPanel.
@Override
public void buildPanel() {
ViewerOptions viewerOptions = new ViewerOptions();
viewerOptions.sceneMode = SceneMode.SCENE2D();
viewerOptions.timeline = false;
viewerOptions.animation = false;
csVPanel = new ViewerPanel(viewerOptions);
Promise<GeoJsonDataSource, String> dataSource = GeoJsonDataSource.load(GWT.getModuleBaseURL() + "SampleData/simplestyles.geojson");
csVPanel.getViewer().dataSources().add(dataSource);
dataSource.then(new Fulfill<GeoJsonDataSource>() {
@Override
public void onFulfilled(GeoJsonDataSource value) {
csVPanel.getViewer().zoomTo(value);
}
});
contentPanel.add(new HTML("<p>Load GeoJSON with simplestyle information.</p>"));
contentPanel.add(csVPanel);
initWidget(contentPanel);
}
use of org.cesiumjs.cs.widgets.ViewerPanel in project gwt-cs by iSergio.
the class GoogleEarthEnterprise method buildPanel.
@Override
public void buildPanel() {
GoogleEarthEnterpriseMetadata geeMetadata = GoogleEarthEnterpriseMetadata.create("http://www.earthenterprise.org/3d");
ViewerOptions options = new ViewerOptions();
options.imageryProvider = GoogleEarthEnterpriseImageryProvider.create(geeMetadata);
options.terrainProvider = GoogleEarthEnterpriseTerrainProvider.create(geeMetadata);
options.baseLayerPicker = false;
ViewerPanel csVPanel = new ViewerPanel(options);
ViewOptions viewOptions = new ViewOptions();
viewOptions.destinationRec = Rectangle.fromDegrees(-123.0, 36.0, -121.7, 39.0);
csVPanel.getViewer().camera.setView(viewOptions);
contentPanel.add(new HTML("<p>Add imagery from a Web Map Service (WMS) server.</p>"));
contentPanel.add(csVPanel);
initWidget(contentPanel);
}
use of org.cesiumjs.cs.widgets.ViewerPanel in project gwt-cs by iSergio.
the class HelloWorld method buildPanel.
@Override
public void buildPanel() {
ViewerPanel csVPanel = new ViewerPanel();
contentPanel.add(new HTML("<p>Use Viewer to start building new applications or easily embed Cesium into existing applications.</p>"));
contentPanel.add(csVPanel);
initWidget(contentPanel);
}
Aggregations