use of ol.Coordinate in project gwt-ol3 by TDesjardins.
the class FilterTest method testWithin.
public void testWithin() {
injectUrlAndTest(() -> {
Within within = new Within("geometryName", new Circle(new Coordinate(5, 5), 5), "EPSG:3857");
assertNotNull(within);
Within within2 = Filter.within("geometryName", new Circle(new Coordinate(5, 5), 5));
assertTrue(within2 instanceof Within);
Within within3 = Filter.within("geometryName", new Circle(new Coordinate(5, 5), 5), "EPSG:3857");
assertTrue(within3 instanceof Within);
});
}
use of ol.Coordinate in project gwt-ol3 by TDesjardins.
the class CircleTest method testCircle.
public void testCircle() {
injectUrlAndTest(() -> {
double radius = 5;
Circle circle = new Circle(new Coordinate(10, 10), radius);
assertNotNull(circle);
assertTrue(circle instanceof Geometry);
Coordinate coordinate = circle.getCenter();
assertNotNull(coordinate);
assert (10 == coordinate.getX());
assert (10 == coordinate.getY());
assert (radius == circle.getRadius());
assertTrue(circle.intersectsExtent(new Extent(0, 0, 15, 15)));
assertFalse(circle.intersectsExtent(new Extent(0, 0, 5, 5)));
});
}
use of ol.Coordinate in project gwt-ol3 by TDesjardins.
the class MapboxExample method show.
/* (non-Javadoc)
* @see de.desjardins.ol3.demo.client.example.Example#show()
*/
@Override
public void show(String exampleId) {
XyzOptions mapboxOptions = new XyzOptions();
mapboxOptions.setTileSize(new Size(512, 512));
mapboxOptions.setUrl("https://api.mapbox.com/styles/v1/mapbox/dark-v8/tiles/{z}/{x}/{y}?access_token=" + ACCESS_TOKEN);
mapboxOptions.setAttributions("© <a href='https://www.mapbox.com/about/maps/'>Mapbox</a> © <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a>");
Xyz mapboxSource = new Xyz(mapboxOptions);
LayerOptions xyzLayerOptions = OLFactory.createOptions();
xyzLayerOptions.setSource(mapboxSource);
Tile mapboxLayer = new Tile(xyzLayerOptions);
// create a view
View view = new View();
Coordinate centerCoordinate = new Coordinate(1490463, 6894388);
view.setCenter(centerCoordinate);
view.setZoom(10);
// create the map
MapOptions mapOptions = new MapOptions();
mapOptions.setTarget(exampleId);
mapOptions.setView(view);
Map map = new Map(mapOptions);
ol.control.Attribution attributionControl = new ol.control.Attribution();
attributionControl.setCollapsed(false);
map.addControl(attributionControl);
map.addControl(new MousePosition());
map.addControl(DemoUtils.createMapboxLogo());
map.addLayer(mapboxLayer);
}
use of ol.Coordinate in project gwt-ol3 by TDesjardins.
the class MeasureExample method show.
/* (non-Javadoc)
* @see de.desjardins.ol3.demo.client.example.Example#show()
*/
@Override
public void show(String exampleId) {
// create a OSM-layer
XyzOptions osmSourceOptions = OLFactory.createOptions();
Osm osmSource = new Osm(osmSourceOptions);
LayerOptions osmLayerOptions = OLFactory.createOptions();
osmLayerOptions.setSource(osmSource);
Tile osmLayer = new Tile(osmLayerOptions);
// create a view
View view = OLFactory.createView();
Coordinate centerCoordinate = new Coordinate(-0.1275, 51.507222);
Coordinate transformedCenterCoordinate = Projection.transform(centerCoordinate, "EPSG:4326", "EPSG:3857");
view.setCenter(transformedCenterCoordinate);
view.setZoom(10);
// create the map
MapOptions mapOptions = OLFactory.createOptions();
mapOptions.setTarget(exampleId);
mapOptions.setView(view);
Map map = new Map(mapOptions);
map.addLayer(osmLayer);
// add some controls
map.addControl(new ScaleLine());
DemoUtils.addDefaultControls(map.getControls());
Attribution attribution = new Attribution();
attribution.setCollapsed(true);
map.addControl(attribution);
// add some interactions
map.addInteraction(new KeyboardPan());
map.addInteraction(new KeyboardZoom());
// add measurement functionality to the map
final Measure measure = new Measure(map);
// start measuring immediately
measure.startMeasureLength(new MeasureListener() {
@Override
public void onMeasure(MeasureEvent evt) {
// log the measured length
GWT.log("measure: " + evt.getMeasure());
}
}, true, true);
}
use of ol.Coordinate in project gwt-ol3 by TDesjardins.
the class OverlayExample method show.
/* (non-Javadoc)
* @see de.desjardins.ol3.demo.client.example.Example#show()
*/
@Override
public void show(String exampleId) {
// create a OSM-layer
XyzOptions osmSourceOptions = OLFactory.createOptions();
Osm osmSource = new Osm(osmSourceOptions);
LayerOptions osmLayerOptions = OLFactory.createOptions();
osmLayerOptions.setSource(osmSource);
Tile osmLayer = new Tile(osmLayerOptions);
// create a view
View view = new View();
Coordinate centerCoordinate = OLFactory.createCoordinate(2.3, 51.507222);
Coordinate transformedCenterCoordinate = Projection.transform(centerCoordinate, "EPSG:4326", "EPSG:3857");
view.setCenter(transformedCenterCoordinate);
view.setZoom(10);
// create the map
MapOptions mapOptions = OLFactory.createOptions();
mapOptions.setTarget(exampleId);
mapOptions.setView(view);
Map map = new Map(mapOptions);
map.addLayer(osmLayer);
// add some controls
map.addControl(OLFactory.createScaleLine());
DemoUtils.addDefaultControls(map.getControls());
Attribution attribution = new Attribution();
attribution.setCollapsed(true);
map.addControl(attribution);
// add some interactions
map.addInteraction(OLFactory.createKeyboardPan());
map.addInteraction(OLFactory.createKeyboardZoom());
DivElement overlay = Document.get().createDivElement();
overlay.setClassName("overlay-font");
overlay.setInnerText("Created with GWT SDK " + GWT.getVersion());
OverlayOptions overlayOptions = OLFactory.createOptions();
overlayOptions.setElement(overlay);
overlayOptions.setPosition(transformedCenterCoordinate);
overlayOptions.setOffset(OLFactory.createPixel(-300, 0));
map.addOverlay(new Overlay(overlayOptions));
}
Aggregations