Before we start, let's stop
and see where we are...
Objectives
- Why to use Open Layers
- Understand OL concepts: map, layers,...
- Learn how to
- add WMS and cached layers
- add WFS and other vector layers
- add some interactivity to your map
- apply rules to your vector layers
- apply styles to your vector layers
Outline
- The Open Layers project
- Open Layers basics
- Working with layers
- Working with controls
- Vector layers
-
Mature, well established
-
For years THE web mapping framework
- Great support for standards
- WMS/WFS/WMTS/TMS
- GML/KML/GeoRSS/WMC...
-
New challenges
and competition (Leaflet)
-
Users and developers mailing lists
-
Beginner's guide and
cookbook available
Dissect your map
- markup
- styles
- initialization code
- after loading OL library
- order is important
WMS Layers
- Constructor with 3 parameters
- Name of the layers in your viewer
- URL of the service
- Parameters to pass to the service
- WMS layers to load
- image format
- transparency
- ...
Cached layers
- Images already rendered at the server
- Several formats
- OpenStreetMap is a typical base map
- EPSG:3857 (see epsg-registry for details)
- OSM accepts custom urls
Proprietary layers
- There are some proprietary
services available by default
- Bing
- Google Maps
- ArcIMS
- ArcGIS Server REST (9.3)
- Others via custom code
- Usually need to accept a Terms of Service,
get an API key, etc.
Vector Layers
Minimum parameters of a vector layer constructor:
- A layer name
- A configuration object with:
- A list o strategies
- When your data is requested
- Ordered
- Independent
- A protocol
- How your data is requested
-
Deal with data format
More on vector layers later
Bonus exercises
- Visit the USGS web portal and try to represent other earthquakes documents (KML for example?)
- Create a selection control and try to show below your map additional information stored on your earthquakes vector layer
Controls
- Add interactivity to the map
- Not all provide a user interface
- Some are loaded by default
- Examples:
- Overview map
- Scale line
- Selection tools
- Drawing tools
- and many more
Open Layers and vector concepts
"Dealing with vector layers and features is like a postal service"
- Format:
- Protocol
- the way you put your address on the envelope
- independent of the format or the features
- i.e. through national post service or USPS, writing down the address or using a barcode?
- Strategy
- when you send your letter to the addresses
- i.e. as written or go to the post office every Monday?
Creating new features
- Just create, without persisting yet
- Create a checkbox to activate/deactivate the control
- Create a OpenLayers.Control.DrawFeature
- Create a function to toggle the control
Persisting features
- We use the transactional profile of WFS
- We need to add a couple of controls
- Add the OpenLayers.Strategy.Save
- Add a new EditingPanel control to the map
- Check the changes on the GeoServer layer preview
Vector Styling
- To apply a style we need to use filters
-
Symbolizers are similar to CSS
- A rule joins a filter with a symbolizer
- A style is a group of rules with a default symbolizer
- A style map is a map of render intents with styles