Add EPSG:4326 example
This commit is contained in:
@@ -0,0 +1,47 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||||
|
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
|
||||||
|
<link rel="stylesheet" href="style.css" type="text/css">
|
||||||
|
<style type="text/css">
|
||||||
|
html, body, #map {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
#text {
|
||||||
|
position: absolute;
|
||||||
|
top: 8px;
|
||||||
|
right: 8px;
|
||||||
|
z-index: 20000;
|
||||||
|
background-color: white;
|
||||||
|
padding: 0 0.5em 0.5em 0.5em;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
@media only screen and (max-width: 600px) {
|
||||||
|
#text {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<title>EPSG:4326 example</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="map">
|
||||||
|
<div id="text">
|
||||||
|
<h1 id="title">EPSG:4326 example</h1>
|
||||||
|
<div id="shortdesc">Example of a epsg-4326 map.</div>
|
||||||
|
<div id="docs">
|
||||||
|
<p>See the
|
||||||
|
<a href="epsg-4326.js" target="_blank">epsg-4326.js source</a>
|
||||||
|
to see how this is done.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="tags">epsg4326</div>
|
||||||
|
<script src="loader.js?id=epsg-4326" type="text/javascript"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
goog.require('goog.debug.Console');
|
||||||
|
goog.require('goog.debug.Logger');
|
||||||
|
goog.require('goog.debug.Logger.Level');
|
||||||
|
goog.require('ol.Collection');
|
||||||
|
goog.require('ol.Coordinate');
|
||||||
|
goog.require('ol.Map');
|
||||||
|
goog.require('ol.Projection');
|
||||||
|
goog.require('ol.RendererHint');
|
||||||
|
goog.require('ol.View2D');
|
||||||
|
goog.require('ol.layer.TileLayer');
|
||||||
|
goog.require('ol.source.TiledWMS');
|
||||||
|
|
||||||
|
|
||||||
|
if (goog.DEBUG) {
|
||||||
|
goog.debug.Console.autoInstall();
|
||||||
|
goog.debug.Logger.getLogger('ol').setLevel(goog.debug.Logger.Level.INFO);
|
||||||
|
}
|
||||||
|
|
||||||
|
var epsg4326 = ol.Projection.getFromCode('EPSG:4326');
|
||||||
|
|
||||||
|
// We give the single image source a set of resolutions. This prevents the
|
||||||
|
// source from requesting images of arbitrary resolutions.
|
||||||
|
var projectionExtent = epsg4326.getExtent();
|
||||||
|
var maxResolution = Math.max(
|
||||||
|
projectionExtent.maxX - projectionExtent.minX,
|
||||||
|
projectionExtent.maxY - projectionExtent.minY) / 256;
|
||||||
|
var resolutions = new Array(10);
|
||||||
|
for (var i = 0; i < 10; ++i) {
|
||||||
|
resolutions[i] = maxResolution / Math.pow(2.0, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
var layers = new ol.Collection([
|
||||||
|
new ol.layer.TileLayer({
|
||||||
|
source: new ol.source.TiledWMS({
|
||||||
|
url: 'http://vmap0.tiles.osgeo.org/wms/vmap0',
|
||||||
|
crossOrigin: null,
|
||||||
|
params: {
|
||||||
|
'LAYERS': 'basic',
|
||||||
|
'FORMAT': 'image/jpeg'
|
||||||
|
},
|
||||||
|
projection: epsg4326
|
||||||
|
})
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
|
||||||
|
var map = new ol.Map({
|
||||||
|
layers: layers,
|
||||||
|
// The OSgeo server does not set cross origin headers, so we cannot use WebGL
|
||||||
|
renderers: [ol.RendererHint.CANVAS, ol.RendererHint.DOM],
|
||||||
|
target: 'map',
|
||||||
|
view: new ol.View2D({
|
||||||
|
projection: epsg4326,
|
||||||
|
center: new ol.Coordinate(0, 0),
|
||||||
|
zoom: 2
|
||||||
|
})
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user