Search in sources :

Example 6 with ProjectionOptions

use of ol.proj.ProjectionOptions in project gwt-ol3 by TDesjardins.

the class StaticImageExample method show.

/* (non-Javadoc)
     * @see de.desjardins.ol3.demo.client.example.Example#show()
     */
@Override
public void show(String exampleId) {
    ProjectionOptions projectionOptions = OLFactory.createOptions();
    Extent imageExtent = new Extent(0, 0, 1024, 968);
    projectionOptions.setCode("pixel");
    projectionOptions.setExtent(imageExtent);
    projectionOptions.setUnits("pixels");
    Projection projection = new Projection(projectionOptions);
    ImageStaticOptions imageStaticOptions = OLFactory.createOptions();
    imageStaticOptions.setUrl("http://imgs.xkcd.com/comics/online_communities.png");
    imageStaticOptions.setImageSize(new Size(1024, 968));
    imageStaticOptions.setImageExtent(imageExtent);
    imageStaticOptions.setProjection(projection);
    // create attribution
    imageStaticOptions.setAttributions("&copy; <a href=\"http://xkcd.com/license.html\">xkcd</a>");
    ImageStatic imageStatic = new ImageStatic(imageStaticOptions);
    LayerOptions layerOptions = OLFactory.createOptions();
    layerOptions.setSource(imageStatic);
    Image image = new Image(layerOptions);
    Collection<Base> layers = new Collection<Base>();
    layers.push(image);
    ViewOptions viewOptions = OLFactory.createOptions();
    viewOptions.setCenter(new Coordinate(500, 500));
    viewOptions.setProjection(projection);
    viewOptions.setZoom(2);
    View view = new View(viewOptions);
    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());
    ol.control.Attribution attributionControl = new ol.control.Attribution();
    attributionControl.setCollapsed(false);
    map.addControl(attributionControl);
}
Also used : ImageStatic(ol.source.ImageStatic) Extent(ol.Extent) MapOptions(ol.MapOptions) Size(ol.Size) ViewOptions(ol.ViewOptions) Projection(ol.proj.Projection) Image(ol.layer.Image) LayerOptions(ol.layer.LayerOptions) View(ol.View) Base(ol.layer.Base) Coordinate(ol.Coordinate) Collection(ol.Collection) ProjectionOptions(ol.proj.ProjectionOptions) ImageStaticOptions(ol.source.ImageStaticOptions) Map(ol.Map)

Aggregations

View (ol.View)6 Projection (ol.proj.Projection)6 ProjectionOptions (ol.proj.ProjectionOptions)6 MapOptions (ol.MapOptions)5 Coordinate (ol.Coordinate)4 Map (ol.Map)4 ViewOptions (ol.ViewOptions)4 LayerOptions (ol.layer.LayerOptions)4 Collection (ol.Collection)3 ScaleLine (ol.control.ScaleLine)3 Base (ol.layer.Base)3 MousePosition (ol.control.MousePosition)2 MousePositionOptions (ol.control.MousePositionOptions)2 Image (ol.layer.Image)2 Tile (ol.layer.Tile)2 Osm (ol.source.Osm)2 XyzOptions (ol.source.XyzOptions)2 Extent (ol.Extent)1 Feature (ol.Feature)1 FeatureOptions (ol.FeatureOptions)1