Files
openlayers/examples/tissot.js
Tim Schaub 1110da37e1 Move ol.Sphere#circle to ol.geom.Polygon.circular
Previously, ol.geom.Polygon was a transitive dependency of ol.proj (since ol.proj requires ol.sphere.NORMAL, and all spheres were capable of generating circular polygons).  Instead, ol.proj should be lower-level.  Since it deals only with coordinate arrays, it shouldn't depend on all of the geometry code.

By adding a static `circular` function to `ol.geom.Polygon`, the dependency tree makes more sense.  If you want to create a polygon that approximates a circle on a sphere, you require `ol.geom.Polygon` and `ol.Sphere` (or one of the constants).

This makes room for geometries to have a `transform` method that takes projection-like arguments (meaning that `ol.geom.Geometry` will require `ol.proj`).
2014-05-02 11:25:44 -06:00

46 lines
1.0 KiB
JavaScript

goog.require('ol.Feature');
goog.require('ol.Map');
goog.require('ol.View2D');
goog.require('ol.geom.Polygon');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.source.TileWMS');
goog.require('ol.source.Vector');
goog.require('ol.sphere.WGS84');
var vectorSource = new ol.source.Vector();
var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.TileWMS({
url: 'http://vmap0.tiles.osgeo.org/wms/vmap0',
params: {
'VERSION': '1.1.1',
'LAYERS': 'basic',
'FORMAT': 'image/jpeg'
}
})
}),
new ol.layer.Vector({
source: vectorSource
})
],
renderer: 'canvas',
target: 'map',
view: new ol.View2D({
projection: 'EPSG:4326',
center: [0, 0],
zoom: 2
})
});
var radius = 800000;
for (var x = -180; x < 180; x += 30) {
for (var y = -90; y < 90; y += 30) {
var circle = ol.geom.Polygon.circular(ol.sphere.WGS84, [x, y], radius, 64);
vectorSource.addFeature(new ol.Feature(circle));
}
}