From 171195a83642f2a5e323db260b90ec93923c2bf4 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sat, 21 Jul 2018 08:24:44 -0600 Subject: [PATCH 1/4] Remove broken link to sources --- doc/quickstart.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/quickstart.hbs b/doc/quickstart.hbs index 4c5acffa65..13edbfbda5 100644 --- a/doc/quickstart.hbs +++ b/doc/quickstart.hbs @@ -130,7 +130,7 @@ The `layers: [ ... ]` array is used to define the list of layers available in th ] ``` -Layers in OpenLayers are defined with a type (Image, Tile or Vector) which contains a source. The source is the protocol used to get the map tiles. You can consult the list of [available layer sources here](/en/{{ latest }}/apidoc/ol.source.html) +Layers in OpenLayers are defined with a type (Image, Tile or Vector) which contains a source. The source is the protocol used to get the map tiles. The next part of the `Map` object is the `View`. The view allows to specify the center, resolution, and rotation of the map. The simplest way to define a view is to define a center point and a zoom level. Note that zoom level 0 is zoomed out. From f0ffb48633f906f4ac5461b8b4d98d25d9359dad Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sat, 21 Jul 2018 08:37:38 -0600 Subject: [PATCH 2/4] Update concepts --- doc/tutorials/concepts.hbs | 90 +++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/doc/tutorials/concepts.hbs b/doc/tutorials/concepts.hbs index edbb4ec1ef..ba93365e39 100644 --- a/doc/tutorials/concepts.hbs +++ b/doc/tutorials/concepts.hbs @@ -6,27 +6,34 @@ layout: doc.hbs # Basic Concepts ## Map -The core component of OpenLayers is the map (`Map`). It is rendered to a `target` container (e.g. a `div` element on the web page that contains the map). All map properties can either be configured at construction time, or by using setter methods, e.g. `setTarget()`. + +The core component of OpenLayers is the map (`ol/Map`). It is rendered to a `target` container (e.g. a `div` element on the web page that contains the map). All map properties can either be configured at construction time, or by using setter methods, e.g. `setTarget()`. + +The markup below could be used to create a `
` that contains your map. ```xml
- +The script below constructs a map that is rendered in the `
` above, using the `map` id of the element as a selector. + +```js +import Map from 'ol/Map'; + +var map = new Map({target: 'map'}); ``` ## View -`Map` is not responsible for things like center, zoom level and projection of the map. Instead, these are properties of a `View` instance. + +The map is not responsible for things like center, zoom level and projection of the map. Instead, these are properties of a `ol/View` instance. ```js - import View from 'ol/View'; +import View from 'ol/View'; - map.setView(new View({ - center: [0, 0], - zoom: 2 - })); +map.setView(new View({ + center: [0, 0], + zoom: 2 +})); ``` A `View` also has a `projection`. The projection determines the coordinate system of the `center` and the units for map resolution calculations. If not specified (like in the above snippet), the default projection is Spherical Mercator (EPSG:3857), with meters as map units. @@ -35,54 +42,49 @@ The `zoom` option is a convenient way to specify the map resolution. The availab ## Source -To get remote data for a layer, OpenLayers uses `source/Source` subclasses. These are available for free and commercial map tile services like OpenStreetMap or Bing, for OGC sources like WMS or WMTS, and for vector data in formats like GeoJSON or KML. + +To get remote data for a layer, OpenLayers uses `ol/source/Source` subclasses. These are available for free and commercial map tile services like OpenStreetMap or Bing, for OGC sources like WMS or WMTS, and for vector data in formats like GeoJSON or KML. ```js - import OSM from 'ol/source/OSM'; +import OSM from 'ol/source/OSM'; - var osmSource = OSM(); +var osmSource = OSM(); ``` ## Layer -A layer is a visual representation of data from a `source`. OpenLayers has four basic types of layers: `layer/Tile`, `layer/Image`, `layer/Vector` and `layer/VectorTile`. -`layer/Tile` is for layer sources that provide pre-rendered, tiled images in grids that are organized by zoom levels for specific resolutions. +A layer is a visual representation of data from a `source`. OpenLayers has four basic types of layers: -`layer/Image` is for server rendered images that are available for arbitrary extents and resolutions. - -`layer/Vector` is for vector data that is rendered client-side. - -`layer/VectorTile` is for tiled vector data that is rendered client-side. + * `ol/layer/Tile` - Renders sources that provide tiled images in grids that are organized by zoom levels for specific resolutions. + * `ol/layer/Image` - Renders sources that provide map images at arbitrary extents and resolutions. + * `ol/layer/Vector` - Renders vector data client-side. + * `ol/layer/VectorTile` - Renders data that is provided as vector tiles. ```js - import TileLayer from 'ol/layer/Tile'; +import TileLayer from 'ol/layer/Tile'; - var osmLayer = new TileLayer({source: osmSource}); - map.addLayer(osmLayer); +var osmLayer = new TileLayer({source: osmSource}); +map.addLayer(osmLayer); ``` ## Putting it all together +The above snippets can be combined into a single script that renders a map with a single tile layer: -The above snippets can be conflated to a self contained map configuration with view and layers: +```js +import Map from 'ol/Map'; +import View from 'ol/View'; +import OSM from 'ol/source/OSM'; +import TileLayer from 'ol/source/Tile'; -```xml -
- +new Map({ + layers: [ + new TileLayer({source: new OSM()}) + ], + view: new View({ + center: [0, 0], + zoom: 2 + }), + target: 'map' +}); ``` From 0edb39c8ab7f16c97e7b57d3b0eb2a2d7feb97f4 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sat, 21 Jul 2018 08:40:03 -0600 Subject: [PATCH 3/4] Single quote instead of backtick --- doc/tutorials/raster-reprojection.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/tutorials/raster-reprojection.md b/doc/tutorials/raster-reprojection.md index 8f95fe652b..167d25f353 100644 --- a/doc/tutorials/raster-reprojection.md +++ b/doc/tutorials/raster-reprojection.md @@ -12,9 +12,9 @@ The view in any Proj4js supported coordinate reference system is possible and pr # Usage The API usage is very simple. Just specify proper projection (e.g. using [EPSG](https://epsg.io) code) on `ol/View`: ```js -import {Map, View} from `ol`; -import TileLayer from `ol/layer/Tile`; -import TileWMS from `ol/source/TileWMS`; +import {Map, View} from 'ol'; +import TileLayer from 'ol/layer/Tile'; +import TileWMS from 'ol/source/TileWMS'; var map = new Map({ target: 'map', From d8b290966b8ceb5ec7e3b2372425484bdcefb3c6 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Sat, 21 Jul 2018 09:11:30 -0600 Subject: [PATCH 4/4] Tracking --- config/jsdoc/api/template/tmpl/layout.tmpl | 7 +++++++ examples/templates/example.html | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/config/jsdoc/api/template/tmpl/layout.tmpl b/config/jsdoc/api/template/tmpl/layout.tmpl index 259b25fb66..fd99c511a7 100644 --- a/config/jsdoc/api/template/tmpl/layout.tmpl +++ b/config/jsdoc/api/template/tmpl/layout.tmpl @@ -4,6 +4,13 @@ var version = obj.packageInfo.version; + + OpenLayers v<?js= version ?> API - <?js= title ?> diff --git a/examples/templates/example.html b/examples/templates/example.html index d1c315ee79..ac807473a8 100644 --- a/examples/templates/example.html +++ b/examples/templates/example.html @@ -1,6 +1,13 @@ + +