Search in sources :

Example 6 with MousePosition

use of ol.control.MousePosition in project gwt-ol3 by TDesjardins.

the class ConstrainedViewExample method show.

/* (non-Javadoc)
     * @see de.desjardins.ol3.demo.client.example.Example#show()
     */
@Override
public void show(String exampleId) {
    XyzOptions xyzOptions = OLFactory.createOptions();
    xyzOptions.setUrl("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}");
    xyzOptions.setAttributions("Tiles &copy; <a href=\"http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer\">ArcGIS</a>");
    Xyz xyzSource = new Xyz(xyzOptions);
    LayerOptions xyzLayerOptions = OLFactory.createOptions();
    xyzLayerOptions.setSource(xyzSource);
    Tile xyzLayer = new Tile(xyzLayerOptions);
    // create a view
    View view = new View();
    Coordinate centerCoordinate = new Coordinate(-121.1, 47.5);
    Coordinate transformedCenterCoordinate = Projection.transform(centerCoordinate, "EPSG:4326", "EPSG:3857");
    view.setCenter(transformedCenterCoordinate);
    view.setZoom(12);
    // restrict zoom
    view.setMinZoom(11);
    view.setMaxZoom(14);
    // create the map
    MapOptions mapOptions = OLFactory.createOptions();
    mapOptions.setTarget(exampleId);
    mapOptions.setView(view);
    Map map = new Map(mapOptions);
    // restrict extent
    ViewOptions viewOptions = new ViewOptions();
    viewOptions.setCenter(map.getView().getCenter());
    viewOptions.setExtent(map.getView().calculateExtent(map.getSize()));
    viewOptions.setZoom(map.getView().getZoom());
    viewOptions.setMinZoom(map.getView().getMinZoom());
    viewOptions.setMaxZoom(map.getView().getMaxZoom());
    View restrictedView = new View(viewOptions);
    map.setView(restrictedView);
    ol.control.Attribution attributionControl = new ol.control.Attribution();
    attributionControl.setCollapsed(false);
    map.addControl(attributionControl);
    MousePosition mousePosition = new MousePosition();
    mousePosition.setCoordinateFormat(Coordinate.createStringXY(2));
    map.addControl(mousePosition);
    map.addLayer(xyzLayer);
}
Also used : XyzOptions(ol.source.XyzOptions) MapOptions(ol.MapOptions) ViewOptions(ol.ViewOptions) Tile(ol.layer.Tile) LayerOptions(ol.layer.LayerOptions) View(ol.View) MousePosition(ol.control.MousePosition) Coordinate(ol.Coordinate) Xyz(ol.source.Xyz) Map(ol.Map)

Example 7 with MousePosition

use of ol.control.MousePosition in project gwt-ol3 by TDesjardins.

the class MvtExample method show.

/* (non-Javadoc)
     * @see de.desjardins.ol3.demo.client.example.Example#show()
     */
@Override
public void show(String exampleId) {
    VectorTileOptions vectorTileOptions = new VectorTileOptions();
    vectorTileOptions.setFormat(new Mvt());
    vectorTileOptions.setUrl("https://{a-d}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/{z}/{x}/{y}.vector.pbf?access_token=" + ACCESS_TOKEN);
    vectorTileOptions.setAttributions("© <a href=\"https://www.mapbox.com/map-feedback/\">Mapbox</a> © <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap contributors</a>'");
    VectorTile vectorTile = new VectorTile(vectorTileOptions);
    VectorTileLayerOptions tileLayerOptions = new VectorTileLayerOptions();
    tileLayerOptions.setSource(vectorTile);
    ol.layer.VectorTile mvtLayer = new ol.layer.VectorTile(tileLayerOptions);
    // 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);
    Map map = new Map(mapOptions);
    ol.control.Attribution attributionControl = new ol.control.Attribution();
    attributionControl.setCollapsed(false);
    map.addControl(attributionControl);
    map.addControl(new MousePosition());
    map.addControl(DemoUtils.createMapboxLogo());
    map.addLayer(mvtLayer);
}
Also used : MapOptions(ol.MapOptions) Mvt(ol.format.Mvt) VectorTileOptions(ol.source.VectorTileOptions) VectorTileLayerOptions(ol.layer.VectorTileLayerOptions) View(ol.View) MousePosition(ol.control.MousePosition) Coordinate(ol.Coordinate) VectorTile(ol.source.VectorTile) Map(ol.Map)

Example 8 with MousePosition

use of ol.control.MousePosition in project gwt-ol3 by TDesjardins.

the class XyzExample method show.

/* (non-Javadoc)
     * @see de.desjardins.ol3.demo.client.example.Example#show()
     */
@Override
public void show(String exampleId) {
    XyzOptions xyzOptions = OLFactory.createOptions();
    xyzOptions.setUrl("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}");
    xyzOptions.setAttributions("Tiles &copy; <a href=\"http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer\">ArcGIS</a>");
    Xyz xyzSource = new Xyz(xyzOptions);
    LayerOptions xyzLayerOptions = OLFactory.createOptions();
    xyzLayerOptions.setSource(xyzSource);
    Tile xyzLayer = new Tile(xyzLayerOptions);
    // create a view
    View view = new View();
    Coordinate centerCoordinate = new Coordinate(-121.1, 47.5);
    Coordinate transformedCenterCoordinate = Projection.transform(centerCoordinate, "EPSG:4326", "EPSG:3857");
    view.setCenter(transformedCenterCoordinate);
    view.setZoom(7);
    // create the map
    MapOptions mapOptions = OLFactory.createOptions();
    mapOptions.setTarget(exampleId);
    mapOptions.setView(view);
    Map map = new Map(mapOptions);
    ol.control.Attribution attributionControl = new ol.control.Attribution();
    attributionControl.setCollapsed(false);
    map.addControl(attributionControl);
    MousePosition mousePosition = new MousePosition();
    mousePosition.setCoordinateFormat(Coordinate.createStringXY(2));
    map.addControl(mousePosition);
    map.addLayer(xyzLayer);
}
Also used : XyzOptions(ol.source.XyzOptions) MapOptions(ol.MapOptions) Tile(ol.layer.Tile) LayerOptions(ol.layer.LayerOptions) View(ol.View) MousePosition(ol.control.MousePosition) Coordinate(ol.Coordinate) Xyz(ol.source.Xyz) Map(ol.Map)

Aggregations

MousePosition (ol.control.MousePosition)8 Coordinate (ol.Coordinate)7 Map (ol.Map)7 MapOptions (ol.MapOptions)7 View (ol.View)7 LayerOptions (ol.layer.LayerOptions)6 Tile (ol.layer.Tile)6 XyzOptions (ol.source.XyzOptions)6 Osm (ol.source.Osm)3 Xyz (ol.source.Xyz)3 Collection (ol.Collection)2 MousePositionOptions (ol.control.MousePositionOptions)2 ScaleLine (ol.control.ScaleLine)2 ZoomSlider (ol.control.ZoomSlider)2 ZoomToExtent (ol.control.ZoomToExtent)2 Base (ol.layer.Base)2 Projection (ol.proj.Projection)2 ProjectionOptions (ol.proj.ProjectionOptions)2 Feature (ol.Feature)1 FeatureOptions (ol.FeatureOptions)1