Search in sources :

Example 1 with Gpx

use of ol.format.Gpx in project gwt-ol3 by TDesjardins.

the class GpxExample method show.

/* (non-Javadoc)
     * @see de.desjardins.ol3.demo.client.example.Example#show()
     */
@Override
public void show(String exampleId) {
    // create a OSM-layer
    Osm osmSource = new Osm();
    LayerOptions osmLayerOptions = OLFactory.createOptions();
    osmLayerOptions.setSource(osmSource);
    Tile osmLayer = new Tile(osmLayerOptions);
    // create a GPX vector layer
    VectorOptions vectorOptions = new VectorOptions();
    vectorOptions.setUrl("https://openlayers.org/en/v4.6.4/examples/data/gpx/fells_loop.gpx");
    vectorOptions.setFormat(new Gpx());
    ol.source.Vector vectorSource = new ol.source.Vector(vectorOptions);
    VectorLayerOptions vectorLayerOptions = new VectorLayerOptions();
    vectorLayerOptions.setSource(vectorSource);
    ol.layer.Vector gpxLayer = new ol.layer.Vector(vectorLayerOptions);
    // create a view
    View view = new View();
    Coordinate center = new Coordinate(-7916041.528716288, 5228379.045749711);
    view.setCenter(center);
    view.setZoom(12);
    // create the map
    MapOptions mapOptions = OLFactory.createOptions();
    mapOptions.setTarget(exampleId);
    mapOptions.setView(view);
    Map map = new Map(mapOptions);
    map.addLayer(osmLayer);
    map.addLayer(gpxLayer);
    // add some controls
    map.addControl(new ScaleLine());
    DemoUtils.addDefaultControls(map.getControls());
    Attribution attribution = new Attribution();
    attribution.setCollapsed(true);
    map.addControl(attribution);
    // add some interactions
    map.addInteraction(new KeyboardPan());
    map.addInteraction(new KeyboardZoom());
}
Also used : ScaleLine(ol.control.ScaleLine) KeyboardPan(ol.interaction.KeyboardPan) MapOptions(ol.MapOptions) Osm(ol.source.Osm) Tile(ol.layer.Tile) LayerOptions(ol.layer.LayerOptions) VectorLayerOptions(ol.layer.VectorLayerOptions) View(ol.View) Gpx(ol.format.Gpx) Attribution(ol.control.Attribution) VectorLayerOptions(ol.layer.VectorLayerOptions) Coordinate(ol.Coordinate) KeyboardZoom(ol.interaction.KeyboardZoom) Map(ol.Map) VectorOptions(ol.source.VectorOptions)

Aggregations

Coordinate (ol.Coordinate)1 Map (ol.Map)1 MapOptions (ol.MapOptions)1 View (ol.View)1 Attribution (ol.control.Attribution)1 ScaleLine (ol.control.ScaleLine)1 Gpx (ol.format.Gpx)1 KeyboardPan (ol.interaction.KeyboardPan)1 KeyboardZoom (ol.interaction.KeyboardZoom)1 LayerOptions (ol.layer.LayerOptions)1 Tile (ol.layer.Tile)1 VectorLayerOptions (ol.layer.VectorLayerOptions)1 Osm (ol.source.Osm)1 VectorOptions (ol.source.VectorOptions)1