Merge branch 'master' into patch-4
This commit is contained in:
@@ -147,6 +147,7 @@ function updateView() {
|
||||
view.setCenter(getCenterWithHeading(c, -c[2], view.getResolution()));
|
||||
view.setRotation(-c[2]);
|
||||
marker.setPosition(c);
|
||||
map.render();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -232,6 +232,7 @@ const map = new Map({
|
||||
target: 'map',
|
||||
view: new View({
|
||||
center: [0, 1000000],
|
||||
zoom: 2
|
||||
zoom: 2,
|
||||
multiWorld: true
|
||||
})
|
||||
});
|
||||
|
||||
@@ -6,12 +6,12 @@ docs: >
|
||||
This example shows client-side raster reprojection capabilities from
|
||||
OSM (EPSG:3857) to arbitrary projection by searching
|
||||
in <a href="https://epsg.io/">EPSG.io</a> database.
|
||||
tags: "reprojection, projection, proj4js, epsg.io"
|
||||
tags: "reprojection, projection, proj4js, epsg.io, graticule"
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
<form class="form-inline">
|
||||
<label for="epsg-query">Search projection:</label>
|
||||
<input type="text" id="epsg-query" placeholder="4326, 27700, US National Atlas, Swiss, France, ..." class="form-control" size="50" />
|
||||
<input type="text" id="epsg-query" placeholder="4326, 27700, 3031, US National Atlas, Swiss, France, ..." class="form-control" size="50" />
|
||||
<button id="epsg-search" class="btn">Search</button>
|
||||
<span id="epsg-result"></span>
|
||||
<div>
|
||||
@@ -19,5 +19,9 @@ tags: "reprojection, projection, proj4js, epsg.io"
|
||||
Render reprojection edges
|
||||
<input type="checkbox" id="render-edges">
|
||||
</label>
|
||||
<label for="show-graticule">
|
||||
Show graticule
|
||||
<input type="checkbox" id="show-graticule" />
|
||||
</label>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -1,19 +1,34 @@
|
||||
import Map from '../src/ol/Map.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import {applyTransform} from '../src/ol/extent.js';
|
||||
import Graticule from '../src/ol/layer/Graticule.js';
|
||||
import TileLayer from '../src/ol/layer/Tile.js';
|
||||
import {get as getProjection, getTransform} from '../src/ol/proj.js';
|
||||
import {register} from '../src/ol/proj/proj4.js';
|
||||
import OSM from '../src/ol/source/OSM.js';
|
||||
import TileImage from '../src/ol/source/TileImage.js';
|
||||
import Stroke from '../src/ol/style/Stroke.js';
|
||||
import proj4 from 'proj4';
|
||||
|
||||
|
||||
const graticule = new Graticule({
|
||||
// the style to use for the lines, optional.
|
||||
strokeStyle: new Stroke({
|
||||
color: 'rgba(255,120,0,0.9)',
|
||||
width: 2,
|
||||
lineDash: [0.5, 4]
|
||||
}),
|
||||
showLabels: true,
|
||||
visible: false,
|
||||
wrapX: false
|
||||
});
|
||||
|
||||
const map = new Map({
|
||||
layers: [
|
||||
new TileLayer({
|
||||
source: new OSM()
|
||||
})
|
||||
}),
|
||||
graticule
|
||||
],
|
||||
target: 'map',
|
||||
view: new View({
|
||||
@@ -28,6 +43,7 @@ const queryInput = document.getElementById('epsg-query');
|
||||
const searchButton = document.getElementById('epsg-search');
|
||||
const resultSpan = document.getElementById('epsg-result');
|
||||
const renderEdgesCheckbox = document.getElementById('render-edges');
|
||||
const showGraticuleCheckbox = document.getElementById('show-graticule');
|
||||
|
||||
function setProjection(code, name, proj4def, bbox) {
|
||||
if (code === null || name === null || proj4def === null || bbox === null) {
|
||||
@@ -48,9 +64,15 @@ function setProjection(code, name, proj4def, bbox) {
|
||||
const newProj = getProjection(newProjCode);
|
||||
const fromLonLat = getTransform('EPSG:4326', newProj);
|
||||
|
||||
// very approximate calculation of projection extent
|
||||
const extent = applyTransform(
|
||||
[bbox[1], bbox[2], bbox[3], bbox[0]], fromLonLat);
|
||||
let worldExtent = [bbox[1], bbox[2], bbox[3], bbox[0]];
|
||||
newProj.setWorldExtent(worldExtent);
|
||||
|
||||
// approximate calculation of projection extent,
|
||||
// checking if the world extent crosses the dateline
|
||||
if (bbox[1] > bbox[3]) {
|
||||
worldExtent = [bbox[1], bbox[2], bbox[3] + 360, bbox[0]];
|
||||
}
|
||||
const extent = applyTransform(worldExtent, fromLonLat, undefined, 8);
|
||||
newProj.setExtent(extent);
|
||||
const newView = new View({
|
||||
projection: newProj
|
||||
@@ -98,7 +120,7 @@ searchButton.onclick = function(event) {
|
||||
|
||||
|
||||
/**
|
||||
* Handle change event.
|
||||
* Handle checkbox change event.
|
||||
*/
|
||||
renderEdgesCheckbox.onchange = function() {
|
||||
map.getLayers().forEach(function(layer) {
|
||||
@@ -110,3 +132,10 @@ renderEdgesCheckbox.onchange = function() {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle checkbox change event.
|
||||
*/
|
||||
showGraticuleCheckbox.onchange = function() {
|
||||
graticule.setVisible(showGraticuleCheckbox.checked);
|
||||
};
|
||||
|
||||
@@ -17,8 +17,8 @@ register(proj4);
|
||||
// and a world extent. These are required for the Graticule.
|
||||
const sphereMollweideProjection = new Projection({
|
||||
code: 'ESRI:53009',
|
||||
extent: [-9009954.605703328, -9009954.605703328,
|
||||
9009954.605703328, 9009954.605703328],
|
||||
extent: [-18019909.21177587, -9009954.605703328,
|
||||
18019909.21177587, 9009954.605703328],
|
||||
worldExtent: [-179, -89.99, 179, 89.99]
|
||||
});
|
||||
|
||||
@@ -37,6 +37,6 @@ const map = new Map({
|
||||
view: new View({
|
||||
center: [0, 0],
|
||||
projection: sphereMollweideProjection,
|
||||
zoom: 0
|
||||
zoom: 1
|
||||
})
|
||||
});
|
||||
|
||||
@@ -6,9 +6,9 @@ docs: >
|
||||
This example generates a `GetFeature` request which uses a `PropertyIsEqualTo`
|
||||
and a `PropertyIsLike` filter, and then posts the request to load the features
|
||||
that match the query.
|
||||
tags: "vector, WFS, GetFeature, filter"
|
||||
tags: "vector, WFS, GetFeature, filter, maptiler"
|
||||
cloak:
|
||||
- key: As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5
|
||||
value: Your Bing Maps Key from http://www.bingmapsportal.com/ here
|
||||
- key: get_your_own_D6rA4zTHduk6KOKTXzGB
|
||||
value: Get your own API key at https://www.maptiler.com/cloud/
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from '../src/ol/format/filter.js';
|
||||
import {WFS, GeoJSON} from '../src/ol/format.js';
|
||||
import {Tile as TileLayer, Vector as VectorLayer} from '../src/ol/layer.js';
|
||||
import BingMaps from '../src/ol/source/BingMaps.js';
|
||||
import XYZ from '../src/ol/source/XYZ.js';
|
||||
import VectorSource from '../src/ol/source/Vector.js';
|
||||
import {Stroke, Style} from '../src/ol/style.js';
|
||||
|
||||
@@ -23,10 +23,15 @@ const vector = new VectorLayer({
|
||||
})
|
||||
});
|
||||
|
||||
const key = 'get_your_own_D6rA4zTHduk6KOKTXzGB';
|
||||
const attributions = '<a href="https://www.maptiler.com/copyright/" target="_blank">© MapTiler</a> ' +
|
||||
'<a href="https://www.openstreetmap.org/copyright" target="_blank">© OpenStreetMap contributors</a>';
|
||||
|
||||
const raster = new TileLayer({
|
||||
source: new BingMaps({
|
||||
imagerySet: 'Aerial',
|
||||
key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5'
|
||||
source: new XYZ({
|
||||
attributions: attributions,
|
||||
url: 'https://api.maptiler.com/tiles/satellite/{z}/{x}/{y}.jpg?key=' + key,
|
||||
maxZoom: 20
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ title: WFS
|
||||
shortdesc: Example of using WFS with a BBOX strategy.
|
||||
docs: >
|
||||
This example loads new features from GeoServer WFS when the view extent changes.
|
||||
tags: "vector, WFS, bbox, loading, server"
|
||||
tags: "vector, WFS, bbox, loading, server, maptiler"
|
||||
cloak:
|
||||
- key: As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5
|
||||
value: Your Bing Maps Key from http://www.bingmapsportal.com/ here
|
||||
- key: get_your_own_D6rA4zTHduk6KOKTXzGB
|
||||
value: Get your own API key at https://www.maptiler.com/cloud/
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
|
||||
@@ -3,7 +3,7 @@ import View from '../src/ol/View.js';
|
||||
import GeoJSON from '../src/ol/format/GeoJSON.js';
|
||||
import {Tile as TileLayer, Vector as VectorLayer} from '../src/ol/layer.js';
|
||||
import {bbox as bboxStrategy} from '../src/ol/loadingstrategy.js';
|
||||
import BingMaps from '../src/ol/source/BingMaps.js';
|
||||
import XYZ from '../src/ol/source/XYZ.js';
|
||||
import VectorSource from '../src/ol/source/Vector.js';
|
||||
import {Stroke, Style} from '../src/ol/style.js';
|
||||
|
||||
@@ -30,10 +30,15 @@ const vector = new VectorLayer({
|
||||
})
|
||||
});
|
||||
|
||||
const key = 'get_your_own_D6rA4zTHduk6KOKTXzGB';
|
||||
const attributions = '<a href="https://www.maptiler.com/copyright/" target="_blank">© MapTiler</a> ' +
|
||||
'<a href="https://www.openstreetmap.org/copyright" target="_blank">© OpenStreetMap contributors</a>';
|
||||
|
||||
const raster = new TileLayer({
|
||||
source: new BingMaps({
|
||||
imagerySet: 'Aerial',
|
||||
key: 'As1HiMj1PvLPlqc_gtM7AqZfBL8ZL3VrjaS3zIb22Uvb9WKhuJObROC-qUpa81U5'
|
||||
source: new XYZ({
|
||||
attributions: attributions,
|
||||
url: 'https://api.maptiler.com/tiles/satellite/{z}/{x}/{y}.jpg?key=' + key,
|
||||
maxZoom: 20
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user