forked from openlayers/openlayers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openlayers#2967 from camptocamp/webgl-point
Add support for drawing points with WebGL
- Loading branch information
Showing
46 changed files
with
4,389 additions
and
1,727 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<!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="../css/ol.css" type="text/css"> | ||
<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>Icon sprites with WebGL example</title> | ||
</head> | ||
<body> | ||
|
||
<div class="navbar navbar-inverse navbar-fixed-top"> | ||
<div class="navbar-inner"> | ||
<div class="container"> | ||
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a> | ||
</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="span12"> | ||
<h4 id="title">Icon sprite with WebGL example</h4> | ||
<p id="shortdesc">Icon sprite with WebGL.</p> | ||
<div id="docs"> | ||
<p>See the <a href="icon-sprite-webgl.js" target="_blank">icon-sprite-webgl.js source</a> to see how this is done.</p> | ||
<p>In this example a sprite image is used for the icon styles. Using a sprite is required to get good performance with WebGL.</p> | ||
</div> | ||
<div id="tags">webgl, icon, sprite, vector, point</div> | ||
</div> | ||
|
||
</div> | ||
|
||
</div> | ||
|
||
<script src="../resources/jquery.min.js" type="text/javascript"></script> | ||
<script src="../resources/bootstrap/js/bootstrap.min.js" type="text/javascript"></script> | ||
<script src="../resources/example-behaviour.js" type="text/javascript"></script> | ||
<script src="loader.js?id=icon-sprite-webgl" type="text/javascript"></script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
goog.require('ol.Feature'); | ||
goog.require('ol.FeatureOverlay'); | ||
goog.require('ol.Map'); | ||
goog.require('ol.View'); | ||
goog.require('ol.geom.Point'); | ||
goog.require('ol.layer.Vector'); | ||
goog.require('ol.source.Vector'); | ||
goog.require('ol.style.Icon'); | ||
goog.require('ol.style.Style'); | ||
|
||
|
||
var iconInfo = [{ | ||
offset: [0, 0], | ||
opacity: 1.0, | ||
rotateWithView: true, | ||
rotation: 0.0, | ||
scale: 1.0, | ||
size: [55, 55] | ||
}, { | ||
offset: [110, 86], | ||
opacity: 0.75, | ||
rotateWithView: false, | ||
rotation: Math.PI / 2.0, | ||
scale: 1.25, | ||
size: [55, 55] | ||
}, { | ||
offset: [55, 0], | ||
opacity: 0.5, | ||
rotateWithView: true, | ||
rotation: Math.PI / 3.0, | ||
scale: 1.5, | ||
size: [55, 86] | ||
}, { | ||
offset: [212, 0], | ||
opacity: 1.0, | ||
rotateWithView: true, | ||
rotation: 0.0, | ||
scale: 1.0, | ||
size: [44, 44] | ||
}]; | ||
|
||
var i; | ||
|
||
var iconCount = iconInfo.length; | ||
var icons = new Array(iconCount); | ||
for (i = 0; i < iconCount; ++i) { | ||
var info = iconInfo[i]; | ||
icons[i] = new ol.style.Icon({ | ||
offset: info.offset, | ||
opacity: info.opacity, | ||
rotateWithView: info.rotateWithView, | ||
rotation: info.rotation, | ||
scale: info.scale, | ||
size: info.size, | ||
src: 'data/Butterfly.png' | ||
}); | ||
} | ||
|
||
var featureCount = 50000; | ||
var features = new Array(featureCount); | ||
var feature, geometry; | ||
var e = 25000000; | ||
for (i = 0; i < featureCount; ++i) { | ||
geometry = new ol.geom.Point( | ||
[2 * e * Math.random() - e, 2 * e * Math.random() - e]); | ||
feature = new ol.Feature(geometry); | ||
feature.setStyle( | ||
new ol.style.Style({ | ||
image: icons[i % (iconCount - 1)] | ||
}) | ||
); | ||
features[i] = feature; | ||
} | ||
|
||
var vectorSource = new ol.source.Vector({ | ||
features: features | ||
}); | ||
var vector = new ol.layer.Vector({ | ||
source: vectorSource | ||
}); | ||
|
||
// Use the "webgl" renderer by default. | ||
var renderer = exampleNS.getRendererFromQueryString(); | ||
if (!renderer) { | ||
renderer = 'webgl'; | ||
} | ||
|
||
var map = new ol.Map({ | ||
renderer: renderer, | ||
layers: [vector], | ||
target: document.getElementById('map'), | ||
view: new ol.View({ | ||
center: [0, 0], | ||
zoom: 5 | ||
}) | ||
}); | ||
|
||
var overlayFeatures = []; | ||
for (i = 0; i < featureCount; i += 30) { | ||
var clone = features[i].clone(); | ||
clone.setStyle(null); | ||
overlayFeatures.push(clone); | ||
} | ||
|
||
var featureOverlay = new ol.FeatureOverlay({ | ||
map: map, | ||
style: new ol.style.Style({ | ||
image: icons[iconCount - 1] | ||
}), | ||
features: overlayFeatures | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<!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="../css/ol.css" type="text/css"> | ||
<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>Symbols with WebGL example</title> | ||
</head> | ||
<body> | ||
|
||
<div class="navbar navbar-inverse navbar-fixed-top"> | ||
<div class="navbar-inner"> | ||
<div class="container"> | ||
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a> | ||
</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="span12"> | ||
<h4 id="title">Symbols with WebGL example</h4> | ||
<p id="shortdesc">Using symbols in an atlas with WebGL.</p> | ||
<div id="docs"> | ||
<p>When using symbol styles with WebGL, OpenLayers would render the symbol | ||
on a temporary image and would create a WebGL texture for each image. For a | ||
better performance, it is recommended to use atlas images (similar to | ||
image sprites with CSS), so that the number of textures is reduced. OpenLayers | ||
provides an <code>AtlasManager</code>, which when passed to the constructor | ||
of a symbol style, will create atlases for the symbols.</p> | ||
<p>See the <a href="symbol-atlas-webgl.js" target="_blank">symbol-atlas-webgl.js source</a> to see how this is done.</p> | ||
</div> | ||
<div id="tags">webgl, symbol, atlas, vector, point</div> | ||
</div> | ||
|
||
</div> | ||
|
||
</div> | ||
|
||
<script src="../resources/jquery.min.js" type="text/javascript"></script> | ||
<script src="../resources/bootstrap/js/bootstrap.min.js" type="text/javascript"></script> | ||
<script src="../resources/example-behaviour.js" type="text/javascript"></script> | ||
<script src="loader.js?id=symbol-atlas-webgl" type="text/javascript"></script> | ||
|
||
</body> | ||
</html> |
Oops, something went wrong.