use of ol.Coordinate in project gwt-ol3 by TDesjardins.
the class GeoJsonExample method show.
/* (non-Javadoc)
* @see de.desjardins.ol3.demo.client.example.Example#show() */
@Override
public void show(String exampleId) {
// create linestring
Coordinate coordinate1 = new Coordinate(4e6, 2e6);
Coordinate coordinate2 = new Coordinate(8e6, -2e6);
Coordinate[] coordinates = { coordinate1, coordinate2 };
LineString lineString = new LineString(coordinates);
// create feature
FeatureOptions featureOptions = new FeatureOptions();
featureOptions.setGeometry(lineString);
Feature feature = new Feature(featureOptions);
// convert feature to GeoJSON
GeoJson geoJsonFormat = new GeoJson();
java.lang.Object geoJson = geoJsonFormat.writeFeatureObject(feature, null);
// convert features from GeoJSON
Feature featureGeoJson = geoJsonFormat.readFeature(geoJson, null);
// show converted features
Collection<Feature> lstFeatures = new Collection<Feature>();
lstFeatures.push(featureGeoJson);
VectorOptions vectorSourceOptions = new VectorOptions();
vectorSourceOptions.setFeatures(lstFeatures);
Vector vectorSource = new Vector(vectorSourceOptions);
VectorLayerOptions vectorLayerOptions = new VectorLayerOptions();
vectorLayerOptions.setSource(vectorSource);
ol.layer.Vector vectorLayer = new ol.layer.Vector(vectorLayerOptions);
// create a OSM-layer
XyzOptions osmSourceOptions = new XyzOptions();
Osm osmSource = new Osm(osmSourceOptions);
LayerOptions osmLayerOptions = new LayerOptions();
osmLayerOptions.setSource(osmSource);
Tile osmLayer = new Tile(osmLayerOptions);
// create a view
View view = new View();
Coordinate centerCoordinate = new Coordinate(0, 0);
view.setCenter(centerCoordinate);
view.setZoom(2);
// create the map
MapOptions mapOptions = new MapOptions();
mapOptions.setTarget(exampleId);
mapOptions.setView(view);
Collection<Base> lstLayer = new Collection<Base>();
lstLayer.push(osmLayer);
lstLayer.push(vectorLayer);
mapOptions.setLayers(lstLayer);
Map map = new Map(mapOptions);
// add some controls
map.addControl(new ScaleLine());
DemoUtils.addDefaultControls(map.getControls());
// add some interactions
map.addInteraction(new KeyboardPan());
map.addInteraction(new KeyboardZoom());
map.addControl(new Rotate());
}
use of ol.Coordinate in project gwt-ol3 by TDesjardins.
the class GraticuleExample method show.
/* (non-Javadoc)
* @see de.desjardins.ol3.demo.client.example.Example#show()
*/
@Override
public void show(String exampleId) {
// create an 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 = new Coordinate(1490463, 6894388);
view.setCenter(centerCoordinate);
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 ZoomSlider());
MousePosition mousePosition = new MousePosition();
mousePosition.setCoordinateFormat(Coordinate.createStringXY(2));
map.addControl(mousePosition);
map.addControl(new ZoomToExtent());
OverviewMap overviewMap = new OverviewMap();
map.addControl(overviewMap);
Graticule graticule = new Graticule();
graticule.setMap(map);
}
use of ol.Coordinate in project gwt-ol3 by TDesjardins.
the class MapGuideExample method show.
/* (non-Javadoc)
* @see de.desjardins.ol3.demo.client.example.Example#show()
*/
@Override
public void show(String exampleId) {
// create a projection
Projection projection = Projection.get("EPSG:4326");
// create a MapGuide params
ImageMapGuideParams imageMapGuideParams = new ImageMapGuideParams();
imageMapGuideParams.setFormat("PNG");
imageMapGuideParams.setMapDefinition("Library://Public/Samples/Sheboygan/Maps/Sheboygan.MapDefinition");
imageMapGuideParams.setUserName("OpenLayers");
imageMapGuideParams.setPassword("OpenLayers");
// create a MapGuide image
ImageMapGuideOptions imageMapGuideOptions = new ImageMapGuideOptions();
imageMapGuideOptions.setParams(imageMapGuideParams);
imageMapGuideOptions.setUrl("http://www.buoyshark.com/mapguide/mapagent/mapagent.fcgi?");
imageMapGuideOptions.setUseOverlay(false);
imageMapGuideOptions.setMetersPerUnit(111319.4908d);
imageMapGuideOptions.setRatio(2.0f);
ImageMapGuide imageMapGuideSource = new ImageMapGuide(imageMapGuideOptions);
LayerOptions layerOptions = new LayerOptions();
Extent bounds = new Extent(-87.865114442365922d, 43.665065564837931d, -87.595394059497067d, 43.823852564430069d);
layerOptions.setExtent(bounds);
layerOptions.setSource(imageMapGuideSource);
Image mapGuideLayer = new Image(layerOptions);
// create a view
ViewOptions viewOptions = new ViewOptions();
viewOptions.setProjection(projection);
viewOptions.setZoom(12.0d);
Coordinate centerCoordinate = new Coordinate(-87.7302542509315d, 43.744459064634d);
viewOptions.setCenter(centerCoordinate);
View view = new View(viewOptions);
// create the map
MapOptions mapOptions = new MapOptions();
mapOptions.setTarget(exampleId);
mapOptions.setView(view);
Collection<Base> lstLayer = new Collection<Base>();
lstLayer.push(mapGuideLayer);
mapOptions.setLayers(lstLayer);
Map map = new Map(mapOptions);
// add some controls
map.addControl(new ScaleLine());
DemoUtils.addDefaultControls(map.getControls());
// add some interactions
map.addInteraction(new KeyboardPan());
map.addInteraction(new KeyboardZoom());
map.addControl(new Rotate());
}
use of ol.Coordinate in project gwt-ol3 by TDesjardins.
the class MarkerExample method show.
/* (non-Javadoc)
* @see de.desjardins.ol3.demo.client.example.Example#show() */
@Override
public void show(String exampleId) {
// create a point
Coordinate coordinate1 = OLFactory.createCoordinate(4e6, 2e6);
Point point1 = new Point(coordinate1);
// create feature
FeatureOptions featureOptions = OLFactory.createOptions();
featureOptions.setGeometry(point1);
Feature feature = new Feature(featureOptions);
Collection<Feature> features = new Collection<Feature>();
features.push(feature);
// create source
VectorOptions vectorSourceOptions = OLFactory.createOptions();
vectorSourceOptions.setFeatures(features);
Vector vectorSource = new Vector(vectorSourceOptions);
// create style
StyleOptions styleOptions = new StyleOptions();
IconOptions iconOptions = new IconOptions();
iconOptions.setSrc("https://openlayers.org/en/v3.20.1/examples/data/icon.png");
Icon icon = new Icon(iconOptions);
styleOptions.setImage(icon);
Style style = new Style(styleOptions);
VectorLayerOptions vectorLayerOptions = OLFactory.createOptions();
vectorLayerOptions.setSource(vectorSource);
vectorLayerOptions.setStyle(style);
ol.layer.Vector vectorLayer = new ol.layer.Vector(vectorLayerOptions);
// 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(0, 0);
view.setCenter(centerCoordinate);
view.setZoom(2);
// create the map
MapOptions mapOptions = new MapOptions();
mapOptions.setTarget(exampleId);
mapOptions.setView(view);
Collection<Base> lstLayer = new Collection<Base>();
lstLayer.push(osmLayer);
lstLayer.push(vectorLayer);
mapOptions.setLayers(lstLayer);
Map map = new Map(mapOptions);
// add some controls
map.addControl(new ScaleLine());
DemoUtils.addDefaultControls(map.getControls());
// add some interactions
map.addInteraction(new KeyboardPan());
map.addInteraction(new KeyboardZoom());
map.addControl(new Rotate());
}
use of ol.Coordinate in project gwt-ol3 by TDesjardins.
the class RasterExample method show.
/*
* (non-Javadoc)
* @see de.desjardins.ol3.demo.client.example.Example#show()
*/
@Override
public void show(String exampleId) {
XyzOptions osmSourceOptions = OLFactory.createOptions();
osmSourceOptions.setCrossOrigin("Anonymous");
Osm osmSource = new Osm(osmSourceOptions);
LayerOptions osmLayerOptions = OLFactory.createOptions();
osmLayerOptions.setSource(osmSource);
// create OSM layer only for background and attribution
Tile osmLayer = new Tile(osmLayerOptions);
// create raster source
Raster raster = getRasterSource(osmSource, RasterOperationType.PIXEL);
LayerOptions layerOptions = OLFactory.createOptions();
layerOptions.setSource(raster);
Image image = new Image(layerOptions);
Collection<Base> layers = new Collection<>();
layers.push(osmLayer);
layers.push(image);
View view = new View();
Coordinate centerCoordinate = new Coordinate(-0.1275, 51.507222);
Coordinate transformedCenterCoordinate = Projection.transform(centerCoordinate, DemoConstants.EPSG_4326, DemoConstants.EPSG_3857);
view.setCenter(transformedCenterCoordinate);
view.setZoom(10);
MapOptions mapOptions = OLFactory.createOptions();
mapOptions.setTarget(exampleId);
mapOptions.setView(view);
mapOptions.setLayers(layers);
Map map = new Map(mapOptions);
// add some controls
DemoUtils.addDefaultControls(map.getControls());
}
Aggregations