Search in sources :

Example 6 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}
 * @param stroke
 *            {@link Stroke}
 * @return {@link Style}
 */
public static Style createStyle(Fill fill, Stroke stroke) {
    StyleOptions styleOptions = createOptions();
    styleOptions.setFill(fill);
    styleOptions.setStroke(stroke);
    return createStyle(styleOptions);
}
Also used : StyleOptions(ol.style.StyleOptions)

Example 7 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}
 * @param stroke {@link Stroke}
 * @param text {@link Text}
 * @return {@link Style}
 */
public static Style createStyle(Fill fill, Stroke stroke, Text text) {
    StyleOptions styleOptions = createOptions();
    styleOptions.setFill(fill);
    styleOptions.setStroke(stroke);
    styleOptions.setText(text);
    return createStyle(styleOptions);
}
Also used : StyleOptions(ol.style.StyleOptions)

Example 8 with StyleOptions

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

the class ClusterExample method show.

/* (non-Javadoc)
     * @see de.desjardins.ol3.demo.client.example.Example#show() */
@Override
public void show(String exampleId) {
    Collection<Feature> features = new Collection<Feature>();
    int e = 450000;
    for (int i = 0; i < 20000; ++i) {
        // create a point
        Coordinate coordinate = new Coordinate(2 * e * Math.random() - e, 2 * e * Math.random() - e);
        Point point = new Point(coordinate);
        // create feature
        FeatureOptions featureOptions = new FeatureOptions();
        featureOptions.setGeometry(point);
        Feature feature = new Feature(featureOptions);
        features.push(feature);
    }
    // create source
    VectorOptions vectorSourceOptions = new VectorOptions();
    vectorSourceOptions.setFeatures(features);
    Vector vectorSource = new Vector(vectorSourceOptions);
    // create clustering
    ClusterOptions clusterOptions = new ClusterOptions();
    clusterOptions.setDistance(40);
    clusterOptions.setSource(vectorSource);
    Cluster clusterSource = new Cluster(clusterOptions);
    // create vector layer
    VectorLayerOptions vectorLayerOptions = new VectorLayerOptions();
    vectorLayerOptions.setSource(clusterSource);
    vectorLayerOptions.setStyle(new GenericFunction<Feature, Style[]>() {

        @Override
        public Style[] call(Feature cluster) {
            // create style
            List<Style> style = new ArrayList<>();
            Feature[] features = (Feature[]) cluster.get("features");
            int clusterSize = features.length;
            StyleOptions styleOptions = new StyleOptions();
            TextOptions textOptions = new TextOptions();
            textOptions.setText(String.valueOf(clusterSize));
            styleOptions.setText(new Text(textOptions));
            CircleOptions circleOptions = new CircleOptions();
            circleOptions.setRadius(10);
            Color color = Color.getColorFromString("#3399CC");
            circleOptions.setFill(OLFactory.createFill(color));
            styleOptions.setImage(new Circle(circleOptions));
            style.add(new Style(styleOptions));
            return style.toArray(new Style[0]);
        }
    });
    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());
}
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) TextOptions(ol.style.TextOptions) FeatureOptions(ol.FeatureOptions) CircleOptions(ol.style.CircleOptions) Style(ol.style.Style) ArrayList(java.util.ArrayList) List(java.util.List) Vector(ol.source.Vector) Circle(ol.style.Circle) Color(ol.color.Color) Osm(ol.source.Osm) Cluster(ol.source.Cluster) StyleOptions(ol.style.StyleOptions) Tile(ol.layer.Tile) Text(ol.style.Text) Point(ol.geom.Point) View(ol.View) Point(ol.geom.Point) Base(ol.layer.Base) ClusterOptions(ol.source.ClusterOptions) VectorLayerOptions(ol.layer.VectorLayerOptions) Coordinate(ol.Coordinate) KeyboardZoom(ol.interaction.KeyboardZoom) Collection(ol.Collection) Map(ol.Map) VectorOptions(ol.source.VectorOptions)

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