Update various examples to use the Mapbox v4-API
This commit is contained in:
@@ -6,5 +6,8 @@ docs: >
|
|||||||
This example demonstrates creating a custom interaction by subclassing `ol/interaction/Pointer`.
|
This example demonstrates creating a custom interaction by subclassing `ol/interaction/Pointer`.
|
||||||
Note that the built in interaction `ol/interaction/Translate` might be a better option for moving features.
|
Note that the built in interaction `ol/interaction/Translate` might be a better option for moving features.
|
||||||
tags: "drag, feature, vector, editing, custom, interaction"
|
tags: "drag, feature, vector, editing, custom, interaction"
|
||||||
|
cloak:
|
||||||
|
- key: pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q
|
||||||
|
value: Your Mapbox access token from https://mapbox.com/ here
|
||||||
---
|
---
|
||||||
<div id="map" class="map"></div>
|
<div id="map" class="map"></div>
|
||||||
|
|||||||
@@ -123,13 +123,14 @@ const polygonFeature = new Feature(
|
|||||||
new Polygon([[[-3e6, -1e6], [-3e6, 1e6],
|
new Polygon([[[-3e6, -1e6], [-3e6, 1e6],
|
||||||
[-1e6, 1e6], [-1e6, -1e6], [-3e6, -1e6]]]));
|
[-1e6, 1e6], [-1e6, -1e6], [-3e6, -1e6]]]));
|
||||||
|
|
||||||
|
const key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q';
|
||||||
|
|
||||||
const map = new Map({
|
const map = new Map({
|
||||||
interactions: defaultInteractions().extend([new Drag()]),
|
interactions: defaultInteractions().extend([new Drag()]),
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new TileLayer({
|
||||||
source: new TileJSON({
|
source: new TileJSON({
|
||||||
url: 'https://a.tiles.mapbox.com/v3/aj.1x1-degrees.json'
|
url: 'https://a.tiles.mapbox.com/v4/aj.1x1-degrees.json?access_token=' + key
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
new VectorLayer({
|
new VectorLayer({
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ docs: >
|
|||||||
modify the extent of the overlay layer. Use the controls above
|
modify the extent of the overlay layer. Use the controls above
|
||||||
to limit rendering based on an extent (approximate country bounds).
|
to limit rendering based on an extent (approximate country bounds).
|
||||||
tags: "extent, tilejson"
|
tags: "extent, tilejson"
|
||||||
|
cloak:
|
||||||
|
- key: pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q
|
||||||
|
value: Your Mapbox access token from https://mapbox.com/ here
|
||||||
---
|
---
|
||||||
<div id="map" class="map"></div>
|
<div id="map" class="map"></div>
|
||||||
<button type="button" class="btn btn-default" id="India">India</button>
|
<button type="button" class="btn btn-default" id="India">India</button>
|
||||||
|
|||||||
@@ -15,9 +15,11 @@ const extents = {
|
|||||||
Sweden: transform([11.02737, 55.36174, 23.90338, 69.10625])
|
Sweden: transform([11.02737, 55.36174, 23.90338, 69.10625])
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q';
|
||||||
|
|
||||||
const base = new TileLayer({
|
const base = new TileLayer({
|
||||||
source: new TileJSON({
|
source: new TileJSON({
|
||||||
url: 'https://api.tiles.mapbox.com/v3/mapbox.world-light.json?secure',
|
url: 'https://api.tiles.mapbox.com/v4/mapbox.world-light.json?secure&access_token=' + key,
|
||||||
crossOrigin: 'anonymous'
|
crossOrigin: 'anonymous'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
@@ -25,7 +27,7 @@ const base = new TileLayer({
|
|||||||
const overlay = new TileLayer({
|
const overlay = new TileLayer({
|
||||||
extent: extents.India,
|
extent: extents.India,
|
||||||
source: new TileJSON({
|
source: new TileJSON({
|
||||||
url: 'https://api.tiles.mapbox.com/v3/mapbox.world-black.json?secure',
|
url: 'https://api.tiles.mapbox.com/v4/mapbox.world-black.json?secure&access_token=' + key,
|
||||||
crossOrigin: 'anonymous'
|
crossOrigin: 'anonymous'
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ docs: >
|
|||||||
tags: "tilejson, input, bind, group, layergroup"
|
tags: "tilejson, input, bind, group, layergroup"
|
||||||
resources:
|
resources:
|
||||||
- https://code.jquery.com/jquery-2.2.3.min.js
|
- https://code.jquery.com/jquery-2.2.3.min.js
|
||||||
|
cloak:
|
||||||
|
- key: pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q
|
||||||
|
value: Your Mapbox access token from https://mapbox.com/ here
|
||||||
---
|
---
|
||||||
<div id="map" class="map"></div>
|
<div id="map" class="map"></div>
|
||||||
<div id="layertree">
|
<div id="layertree">
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import {fromLonLat} from '../src/ol/proj.js';
|
|||||||
import OSM from '../src/ol/source/OSM.js';
|
import OSM from '../src/ol/source/OSM.js';
|
||||||
import TileJSON from '../src/ol/source/TileJSON.js';
|
import TileJSON from '../src/ol/source/TileJSON.js';
|
||||||
|
|
||||||
|
const key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q';
|
||||||
|
|
||||||
const map = new Map({
|
const map = new Map({
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new TileLayer({
|
||||||
@@ -13,13 +15,13 @@ const map = new Map({
|
|||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new TileLayer({
|
||||||
source: new TileJSON({
|
source: new TileJSON({
|
||||||
url: 'https://api.tiles.mapbox.com/v3/mapbox.20110804-hoa-foodinsecurity-3month.json?secure',
|
url: 'https://api.tiles.mapbox.com/v4/mapbox.20110804-hoa-foodinsecurity-3month.json?secure&access_token=' + key,
|
||||||
crossOrigin: 'anonymous'
|
crossOrigin: 'anonymous'
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
new TileLayer({
|
new TileLayer({
|
||||||
source: new TileJSON({
|
source: new TileJSON({
|
||||||
url: 'https://api.tiles.mapbox.com/v3/mapbox.world-borders-light.json?secure',
|
url: 'https://api.tiles.mapbox.com/v4/mapbox.world-borders-light.json?secure&access_token=' + key,
|
||||||
crossOrigin: 'anonymous'
|
crossOrigin: 'anonymous'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -7,5 +7,8 @@ docs: >
|
|||||||
<p>If you continue to zoom in, you'll see the OSM layer also disappear.</p>
|
<p>If you continue to zoom in, you'll see the OSM layer also disappear.</p>
|
||||||
<p>The rendering of the layers are here controlled using minResolution and maxResolution options.</p>
|
<p>The rendering of the layers are here controlled using minResolution and maxResolution options.</p>
|
||||||
tags: "minResolution, maxResolution, resolution"
|
tags: "minResolution, maxResolution, resolution"
|
||||||
|
cloak:
|
||||||
|
- key: pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q
|
||||||
|
value: Your Mapbox access token from https://mapbox.com/ here
|
||||||
---
|
---
|
||||||
<div id="map" class="map"></div>
|
<div id="map" class="map"></div>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import TileLayer from '../src/ol/layer/Tile.js';
|
|||||||
import OSM from '../src/ol/source/OSM.js';
|
import OSM from '../src/ol/source/OSM.js';
|
||||||
import TileJSON from '../src/ol/source/TileJSON.js';
|
import TileJSON from '../src/ol/source/TileJSON.js';
|
||||||
|
|
||||||
|
const key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the map.
|
* Create the map.
|
||||||
@@ -17,7 +18,7 @@ const map = new Map({
|
|||||||
}),
|
}),
|
||||||
new TileLayer({
|
new TileLayer({
|
||||||
source: new TileJSON({
|
source: new TileJSON({
|
||||||
url: 'https://api.tiles.mapbox.com/v3/mapbox.natural-earth-hypso-bathy.json?secure',
|
url: 'https://api.tiles.mapbox.com/v4/mapbox.natural-earth-hypso-bathy.json?secure&access_token=' + key,
|
||||||
crossOrigin: 'anonymous'
|
crossOrigin: 'anonymous'
|
||||||
}),
|
}),
|
||||||
minResolution: 2000,
|
minResolution: 2000,
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ title: Reusable Source
|
|||||||
shortdesc: Updating a tile source by changing the URL.
|
shortdesc: Updating a tile source by changing the URL.
|
||||||
docs: >
|
docs: >
|
||||||
You can call <code>source.setUrl()</code> to update the URL for a tile source. Note that when you change the URL for a tile source, existing tiles will not be replaced until new tiles are loaded. If you are interested instead in clearing currently rendered tiles, you can call the <code>source.refresh()</code> method. Alternatively, you can use two separate sources if you want to remove rendered tiles and start over loading new tiles.
|
You can call <code>source.setUrl()</code> to update the URL for a tile source. Note that when you change the URL for a tile source, existing tiles will not be replaced until new tiles are loaded. If you are interested instead in clearing currently rendered tiles, you can call the <code>source.refresh()</code> method. Alternatively, you can use two separate sources if you want to remove rendered tiles and start over loading new tiles.
|
||||||
|
cloak:
|
||||||
|
- key: pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q
|
||||||
|
value: Your Mapbox access token from https://mapbox.com/ here
|
||||||
---
|
---
|
||||||
<div id="map" class="map"></div>
|
<div id="map" class="map"></div>
|
||||||
<button class="switcher" value="0">January</button>
|
<button class="switcher" value="0">January</button>
|
||||||
|
|||||||
@@ -3,11 +3,13 @@ import View from '../src/ol/View.js';
|
|||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
import TileLayer from '../src/ol/layer/Tile.js';
|
||||||
import XYZ from '../src/ol/source/XYZ.js';
|
import XYZ from '../src/ol/source/XYZ.js';
|
||||||
|
|
||||||
|
const key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q';
|
||||||
|
const baseUrl = 'https://{a-c}.tiles.mapbox.com/v4';
|
||||||
const urls = [
|
const urls = [
|
||||||
'https://{a-c}.tiles.mapbox.com/v3/mapbox.blue-marble-topo-jan/{z}/{x}/{y}.png',
|
baseUrl + '/mapbox.blue-marble-topo-jan/{z}/{x}/{y}.png?access_token=' + key,
|
||||||
'https://{a-c}.tiles.mapbox.com/v3/mapbox.blue-marble-topo-bathy-jan/{z}/{x}/{y}.png',
|
baseUrl + '/mapbox.blue-marble-topo-bathy-jan/{z}/{x}/{y}.png?access_token=' + key,
|
||||||
'https://{a-c}.tiles.mapbox.com/v3/mapbox.blue-marble-topo-jul/{z}/{x}/{y}.png',
|
baseUrl + '/mapbox.blue-marble-topo-jul/{z}/{x}/{y}.png?access_token=' + key,
|
||||||
'https://{a-c}.tiles.mapbox.com/v3/mapbox.blue-marble-topo-bathy-jul/{z}/{x}/{y}.png'
|
baseUrl + '/mapbox.blue-marble-topo-bathy-jul/{z}/{x}/{y}.png?access_token=' + key
|
||||||
];
|
];
|
||||||
|
|
||||||
const source = new XYZ();
|
const source = new XYZ();
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ const map = new Map({
|
|||||||
layers: [
|
layers: [
|
||||||
new TileLayer({
|
new TileLayer({
|
||||||
source: new TileJSON({
|
source: new TileJSON({
|
||||||
url: 'https://api.tiles.mapbox.com/v3/mapbox.world-light.json?secure',
|
url: 'https://api.tiles.mapbox.com/v4/mapbox.world-light.json?secure&access_token=' + key,
|
||||||
crossOrigin: 'anonymous'
|
crossOrigin: 'anonymous'
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -5,5 +5,8 @@ shortdesc: Example of a map with a semi-transparent layer.
|
|||||||
docs: >
|
docs: >
|
||||||
This example will display a tiled MaxBox layer semi-transparently over an OSM background. The OSM layer is changed to back and white by using a CSS filter.
|
This example will display a tiled MaxBox layer semi-transparently over an OSM background. The OSM layer is changed to back and white by using a CSS filter.
|
||||||
tags: "transparent, osm, tilejson"
|
tags: "transparent, osm, tilejson"
|
||||||
|
cloak:
|
||||||
|
- key: pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q
|
||||||
|
value: Your Mapbox access token from https://mapbox.com/ here
|
||||||
---
|
---
|
||||||
<div id="map" class="map"></div>
|
<div id="map" class="map"></div>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {fromLonLat} from '../src/ol/proj.js';
|
|||||||
import OSM from '../src/ol/source/OSM.js';
|
import OSM from '../src/ol/source/OSM.js';
|
||||||
import TileJSON from '../src/ol/source/TileJSON.js';
|
import TileJSON from '../src/ol/source/TileJSON.js';
|
||||||
|
|
||||||
|
const key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q';
|
||||||
|
|
||||||
const map = new Map({
|
const map = new Map({
|
||||||
layers: [
|
layers: [
|
||||||
@@ -14,7 +15,7 @@ const map = new Map({
|
|||||||
}),
|
}),
|
||||||
new TileLayer({
|
new TileLayer({
|
||||||
source: new TileJSON({
|
source: new TileJSON({
|
||||||
url: 'https://api.tiles.mapbox.com/v3/mapbox.va-quake-aug.json?secure',
|
url: 'https://api.tiles.mapbox.com/v4/mapbox.va-quake-aug.json?secure&access_token=' + key,
|
||||||
crossOrigin: 'anonymous',
|
crossOrigin: 'anonymous',
|
||||||
// this layer has transparency, so do not fade tiles:
|
// this layer has transparency, so do not fade tiles:
|
||||||
transition: 0
|
transition: 0
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ docs: >
|
|||||||
progress. This example registers listeners for these events and
|
progress. This example registers listeners for these events and
|
||||||
renders a tile loading progress bar at the bottom of the map.</p>
|
renders a tile loading progress bar at the bottom of the map.</p>
|
||||||
tags: "tile, events, loading"
|
tags: "tile, events, loading"
|
||||||
|
cloak:
|
||||||
|
- key: pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q
|
||||||
|
value: Your Mapbox access token from https://mapbox.com/ here
|
||||||
---
|
---
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<div id="map" class="map"></div>
|
<div id="map" class="map"></div>
|
||||||
|
|||||||
@@ -77,8 +77,9 @@ Progress.prototype.hide = function() {
|
|||||||
|
|
||||||
const progress = new Progress(document.getElementById('progress'));
|
const progress = new Progress(document.getElementById('progress'));
|
||||||
|
|
||||||
|
const key = 'pk.eyJ1IjoidHNjaGF1YiIsImEiOiJjaW5zYW5lNHkxMTNmdWttM3JyOHZtMmNtIn0.CDIBD8H-G2Gf-cPkIuWtRg';
|
||||||
const source = new TileJSON({
|
const source = new TileJSON({
|
||||||
url: 'https://api.tiles.mapbox.com/v3/mapbox.world-bright.json?secure',
|
url: 'https://api.tiles.mapbox.com/v4/mapbox.world-bright.json?secure&access_token=' + key,
|
||||||
crossOrigin: 'anonymous'
|
crossOrigin: 'anonymous'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ docs: >
|
|||||||
250 ms. To disable this behavior, set the <code>transition</code> option
|
250 ms. To disable this behavior, set the <code>transition</code> option
|
||||||
of the tile source to 0.
|
of the tile source to 0.
|
||||||
tags: "fade, transition"
|
tags: "fade, transition"
|
||||||
|
cloak:
|
||||||
|
- key: pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q
|
||||||
|
value: Your Mapbox access token from https://mapbox.com/ here
|
||||||
---
|
---
|
||||||
<div id="map" class="map"></div>
|
<div id="map" class="map"></div>
|
||||||
<label>
|
<label>
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ import View from '../src/ol/View.js';
|
|||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
import TileLayer from '../src/ol/layer/Tile.js';
|
||||||
import XYZ from '../src/ol/source/XYZ.js';
|
import XYZ from '../src/ol/source/XYZ.js';
|
||||||
|
|
||||||
const url = 'https://{a-c}.tiles.mapbox.com/v3/mapbox.world-bright/{z}/{x}/{y}.png';
|
const key = 'pk.eyJ1IjoidHNjaGF1YiIsImEiOiJjaW5zYW5lNHkxMTNmdWttM3JyOHZtMmNtIn0.CDIBD8H-G2Gf-cPkIuWtRg';
|
||||||
|
const url = 'https://{a-c}.tiles.mapbox.com/v4/mapbox.world-bright/{z}/{x}/{y}.png?access_token=' + key;
|
||||||
|
|
||||||
const withTransition = new TileLayer({
|
const withTransition = new TileLayer({
|
||||||
source: new XYZ({url: url})
|
source: new XYZ({url: url})
|
||||||
|
|||||||
@@ -5,5 +5,8 @@ shortdesc: Demonstrates rendering of features from a TopoJSON topology.
|
|||||||
docs: >
|
docs: >
|
||||||
This example uses a vector layer with `ol/format/TopoJSON` for rendering features from [TopoJSON](https://github.com/mbostock/topojson/wiki).
|
This example uses a vector layer with `ol/format/TopoJSON` for rendering features from [TopoJSON](https://github.com/mbostock/topojson/wiki).
|
||||||
tags: "topojson, vector, style"
|
tags: "topojson, vector, style"
|
||||||
|
cloak:
|
||||||
|
- key: pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q
|
||||||
|
value: Your Mapbox access token from https://mapbox.com/ here
|
||||||
---
|
---
|
||||||
<div id="map" class="map"></div>
|
<div id="map" class="map"></div>
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ import TileJSON from '../src/ol/source/TileJSON.js';
|
|||||||
import VectorSource from '../src/ol/source/Vector.js';
|
import VectorSource from '../src/ol/source/Vector.js';
|
||||||
import {Fill, Stroke, Style} from '../src/ol/style.js';
|
import {Fill, Stroke, Style} from '../src/ol/style.js';
|
||||||
|
|
||||||
|
const key = 'pk.eyJ1IjoidHNjaGF1YiIsImEiOiJjaW5zYW5lNHkxMTNmdWttM3JyOHZtMmNtIn0.CDIBD8H-G2Gf-cPkIuWtRg';
|
||||||
const raster = new TileLayer({
|
const raster = new TileLayer({
|
||||||
source: new TileJSON({
|
source: new TileJSON({
|
||||||
url: 'https://api.tiles.mapbox.com/v3/mapbox.world-dark.json?secure'
|
url: 'https://api.tiles.mapbox.com/v4/mapbox.world-dark.json?secure&access_token=' + key
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user