Search in sources :

Example 1 with IconOptions

use of ol.style.IconOptions 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)

Aggregations

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