Search in sources :

Example 1 with StyleOptions

use of ol.style.StyleOptions 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());
}
Also used : XyzOptions(ol.source.XyzOptions) ScaleLine(ol.control.ScaleLine) KeyboardPan(ol.interaction.KeyboardPan) Rotate(ol.control.Rotate) MapOptions(ol.MapOptions) Feature(ol.Feature) LayerOptions(ol.layer.LayerOptions) VectorLayerOptions(ol.layer.VectorLayerOptions) FeatureOptions(ol.FeatureOptions) IconOptions(ol.style.IconOptions) Style(ol.style.Style) Vector(ol.source.Vector) Osm(ol.source.Osm) StyleOptions(ol.style.StyleOptions) Tile(ol.layer.Tile) Point(ol.geom.Point) View(ol.View) Base(ol.layer.Base) VectorLayerOptions(ol.layer.VectorLayerOptions) Coordinate(ol.Coordinate) KeyboardZoom(ol.interaction.KeyboardZoom) Collection(ol.Collection) Icon(ol.style.Icon) Map(ol.Map) VectorOptions(ol.source.VectorOptions)

Example 2 with StyleOptions

use of ol.style.StyleOptions in project gwt-ol3 by TDesjardins.

the class OLFactory method createStyle.

/**
 * Creates a new {@link Style} style.
 * @param text {@link Text}
 * @return {@link Style}
 */
public static Style createStyle(Text text) {
    StyleOptions styleOptions = createOptions();
    styleOptions.setText(text);
    return createStyle(styleOptions);
}
Also used : StyleOptions(ol.style.StyleOptions)

Example 3 with StyleOptions

use of ol.style.StyleOptions in project gwt-ol3 by TDesjardins.

the class OLFactory method createStyle.

/**
 * Creates a new {@link Style} style.
 *
 * @param stroke
 *            {@link Stroke}
 * @return {@link Style}
 */
public static Style createStyle(Stroke stroke) {
    StyleOptions styleOptions = createOptions();
    styleOptions.setStroke(stroke);
    return createStyle(styleOptions);
}
Also used : StyleOptions(ol.style.StyleOptions)

Example 4 with StyleOptions

use of ol.style.StyleOptions in project gwt-ol3 by TDesjardins.

the class OLFactory method createStyle.

/**
 * Creates a new {@link Style} style.
 *
 * @param image
 *            {@link ol.style.Image}
 * @return {@link Style}
 */
public static Style createStyle(ol.style.Image image) {
    StyleOptions styleOptions = createOptions();
    styleOptions.setImage(image);
    return createStyle(styleOptions);
}
Also used : StyleOptions(ol.style.StyleOptions)

Example 5 with StyleOptions

use of ol.style.StyleOptions in project gwt-ol3 by TDesjardins.

the class OLFactory method createStyle.

/**
 * Creates a new {@link Style} style.
 *
 * @param fill
 *            {@link Fill}
 * @return {@link Style}
 */
public static Style createStyle(Fill fill) {
    StyleOptions styleOptions = createOptions();
    styleOptions.setFill(fill);
    return createStyle(styleOptions);
}
Also used : StyleOptions(ol.style.StyleOptions)

Aggregations

StyleOptions (ol.style.StyleOptions)8 Collection (ol.Collection)2 Coordinate (ol.Coordinate)2 Feature (ol.Feature)2 FeatureOptions (ol.FeatureOptions)2 Map (ol.Map)2 MapOptions (ol.MapOptions)2 View (ol.View)2 Rotate (ol.control.Rotate)2 ScaleLine (ol.control.ScaleLine)2 Point (ol.geom.Point)2 KeyboardPan (ol.interaction.KeyboardPan)2 KeyboardZoom (ol.interaction.KeyboardZoom)2 Base (ol.layer.Base)2 LayerOptions (ol.layer.LayerOptions)2 Tile (ol.layer.Tile)2 VectorLayerOptions (ol.layer.VectorLayerOptions)2 Osm (ol.source.Osm)2 Vector (ol.source.Vector)2 VectorOptions (ol.source.VectorOptions)2