working with – ol3



working with – ol3

2 2


working-with-ol3

FOSS4G 2013 Presentation

On Github tschaub / working-with-ol3

working with

ol3

tschaub

@boundlessgeo

.com

Straight to the demos!

goal: put a map on a page

ol.Map / ol.View

var view = new ol.View2D({
  center: [0, 0],
  zoom: 0
});
var map = new ol.Map({
  target: 'map',
  layers: [layer],
  view: view
});
hello world example

goal: use a different data source

ol.layer / ol.source

var osm = new ol.layer.Tile({
  source: new ol.source.OSM()
});
var bing = new ol.layer.Tile({
  source: new ol.source.BingMaps({
    // your key here
    key: 'AlQLZ0-5yk301_ESrmN...',
    style: 'AerialWithLabels'
  })
}));
tiles galore example

goal: give the user control

ol.interaction

  • ol.interaction.Drag
  • ol.interaction.DragRotate
  • ol.interaction.KeyboardPan
  • ol.interaction.TouchZoom
  • // etc.

ol.control

  • ol.control.Zoom
  • ol.control.ScaleLine
  • ol.control.MousePosition
  • ol.control.Attribution
  • // etc.
interaction/control example

goal: work with vector data

ol.layer / ol.source

var vector = new ol.layer.Vector({
  source: new ol.source.Vector({
    url: 'path/to/data.json',
    parser: new ol.parser.GeoJSON()
  })
});
vector layer example

goal: give it some style

ol.style

var style = new ol.style.Style({
  symbolizers: [
    new ol.style.Fill({
      color: '#ff0000',
      opacity: 0.5
    }),
    new ol.style.Stroke({
      color: '#ff00ff',
      width: 1.5
    })
  ]});

ol.style.Rule

var style = new ol.style.Style({
  rules: [
    new ol.style.Rule({
      filter: 'type = "highway"',
      symbolizers: [
        new ol.style.Stroke({
          width: 3
        })
      ]
    })
  ]});
vector style example

goal: let user interact with the data

ol.Overlay

var el = document.getElementById('popup');
var popup = new ol.Overlay({
  element: el
});
map.addOverlay(popup);

map.on('click', function(evt) {
  popup.setPosition(evt.getCoordinate());
  el.className = 'open';
  el.innerHTML = 'Hello Mappers!'
});
overlay example

goal: let user interact with lots data

more points than you can shake a stick at

goal: allow editing

Select/Modify

/** 
 * WARNING: VERY UNSTABLE API TERRAIN BELOW
 */
var select = new ol.interaction.Select({
  layerFilter: function(layer) {
    return layer === vector;
  }
});

var modify = new ol.interaction.Modify();
editing example

goal: get involved

Become a contributor

https://github.com/openlayers/ol3

Join the discussion

https://groups.google.com/d/forum/ol3-dev

Thanks!

watch this space http://ol3js.org/