Merge pull request #749 from openlayers/webgl-vector

Skeleton WebGL vector support
This commit is contained in:
Tom Payne
2013-06-17 07:08:33 -07:00
24 changed files with 1889 additions and 12 deletions

View File

@@ -0,0 +1,55 @@
<!doctype html>
<html lang="en">
<head>
<meta 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="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<title>Ten thousand points example</title>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="example-list.html">OpenLayers 3 Examples</a>
<ul class="nav pull-right">
<li><iframe class="github-watch-button" src="http://ghbtns.com/github-btn.html?user=openlayers&repo=ol3&type=watch&count=true"
allowtransparency="true" frameborder="0" scrolling="0" height="20" width="90"></iframe></li>
<li><a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-hashtags="openlayers">&nbsp;</a></li>
<li><div class="g-plusone-wrapper"><div class="g-plusone" data-size="medium" data-annotation="none"></div></div></li>
</ul>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div id="map" class="map"></div>
</div>
</div>
<div class="row-fluid">
<div class="span4">
<h4 id="title">Ten thousand points example</h4>
<p id="shortdesc">Example of a map with ten thousand points.</p>
<div id="docs">
<p>See the <a href="ten-thousand-points.js" target="_blank">ten-thousand-points.js source</a> to see how this is done.</p>
</div>
<div id="tags">points, vector, openstreetmap</div>
</div>
</div>
</div>
<script src="loader.js?id=ten-thousand-points" type="text/javascript"></script>
<script src="../resources/social-links.js" type="text/javascript"></script>
</body>
</html>

View File

@@ -0,0 +1,68 @@
goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.control.MousePosition');
goog.require('ol.control.defaults');
goog.require('ol.geom2.LineStringCollection');
goog.require('ol.geom2.PointCollection');
goog.require('ol.layer.TileLayer');
goog.require('ol.layer.VectorLayer2');
goog.require('ol.source.OSM');
goog.require('ol.source.VectorSource2');
// WARNING
// This example is an experimental testbed for WebGL vector work. The function
// calls used here are internal and low-level and are not representative of the
// final API.
var pointCollection = ol.geom2.PointCollection.createEmpty(101 * 101);
var i, j, x, y;
for (i = 0; i < 101; ++i) {
for (j = 0; j < 101; ++j) {
x = 20000000 * (i - 50) / 50;
y = 20000000 * (j - 50) / 50;
pointCollection.add([x, y]);
}
}
var k = 1000000;
var lineStringCollection = ol.geom2.LineStringCollection.pack([
[[-20 * k, -20 * k], [20 * k, 20 * k]],
[[-20 * k, 20 * k], [20 * k, -20 * k]],
[[0 * k, 15 * k],
[10 * k, 5 * k],
[5 * k, 5 * k],
[5 * k, -15 * k],
[-5 * k, -15 * k],
[-5 * k, 5 * k],
[-10 * k, 5 * k],
[0 * k, 15 * k]]
]);
var map = new ol.Map({
controls: ol.control.defaults({}, [
new ol.control.MousePosition({
undefinedHTML: '&nbsp;'
})
]),
layers: [
new ol.layer.TileLayer({
source: new ol.source.OSM()
}),
new ol.layer.VectorLayer2({
source: new ol.source.VectorSource2({
lineStringCollections: [lineStringCollection],
projection: 'EPSG:3857',
pointCollections: [pointCollection]
})
})
],
renderer: ol.RendererHint.WEBGL,
target: 'map',
view: new ol.View2D({
center: [0, 0],
zoom: 0
})
});