Permalink
Browse files

Merge pull request #218 from openlayers/vector

  • Loading branch information...
ahocevar committed Mar 12, 2013
2 parents f75d3ab + 84154d7 commit 76d1a0c30e89bbe860ba5710776ea036bae7cfb2
Showing with 6,860 additions and 39 deletions.
  1. +2 −0 base.json
  2. +2 −0 build/ol-simple.json
  3. +2 −0 build/ol-whitespace.json
  4. +2 −0 build/ol.json
  5. +52 −0 examples/style-rules.html
  6. +136 −0 examples/style-rules.js
  7. +52 −0 examples/vector-layer.html
  8. +71 −0 examples/vector-layer.js
  9. +31 −29 externs/geojson.js
  10. +38 −0 src/objectliterals.exports
  11. +70 −0 src/ol/expression.js
  12. +7 −0 src/ol/feature.exports
  13. +112 −0 src/ol/feature.js
  14. +39 −0 src/ol/filter/extentfilter.js
  15. +7 −0 src/ol/filter/filter.exports
  16. +24 −0 src/ol/filter/filter.js
  17. +42 −0 src/ol/filter/geometryfilter.js
  18. +63 −0 src/ol/filter/logicalfilter.js
  19. +79 −0 src/ol/geom/abstractcollection.js
  20. +14 −0 src/ol/geom/base.js
  21. +1 −0 src/ol/geom/expression.exports
  22. +6 −0 src/ol/geom/geometry.exports
  23. +71 −0 src/ol/geom/geometry.js
  24. +48 −0 src/ol/geom/geometrycollection.js
  25. +35 −0 src/ol/geom/linearring.js
  26. +149 −0 src/ol/geom/linestring.js
  27. +72 −0 src/ol/geom/multilinestring.js
  28. +77 −0 src/ol/geom/multipoint.js
  29. +73 −0 src/ol/geom/multipolygon.js
  30. +105 −0 src/ol/geom/point.js
  31. +90 −0 src/ol/geom/polygon.js
  32. +163 −0 src/ol/geom/sharedvertices.js
  33. +3 −0 src/ol/layer/vectorlayer.exports
  34. +360 −0 src/ol/layer/vectorlayer.js
  35. +66 −0 src/ol/parser/featureparser.js
  36. +3 −0 src/ol/parser/geojson.exports
  37. +285 −0 src/ol/parser/geojson.js
  38. +8 −0 src/ol/parser/parser.js
  39. +4 −0 src/ol/parser/xml.js
  40. +6 −2 src/ol/renderer/canvas/canvasmaprenderer.js
  41. +404 −0 src/ol/renderer/canvas/canvasvectorlayerrenderer.js
  42. +441 −0 src/ol/renderer/canvas/canvasvectorrenderer.js
  43. +1 −0 src/ol/source/vectorsource.exports
  44. +25 −0 src/ol/source/vectorsource.js
  45. +213 −0 src/ol/structs/rtree.js
  46. +9 −0 src/ol/style.exports
  47. +160 −0 src/ol/style/icon.js
  48. +128 −0 src/ol/style/line.js
  49. +33 −0 src/ol/style/point.js
  50. +189 −0 src/ol/style/polygon.js
  51. +46 −0 src/ol/style/rule.js
  52. +230 −0 src/ol/style/shape.js
  53. +70 −0 src/ol/style/style.js
  54. +33 −0 src/ol/style/symbolizer.js
  55. +74 −8 test/jasmine-extensions.js
  56. +78 −0 test/spec/ol/expression.test.js
  57. +201 −0 test/spec/ol/feature.test.js
  58. +37 −0 test/spec/ol/filter/extentfilter.test.js
  59. +51 −0 test/spec/ol/filter/geometryfilter.test.js
  60. +79 −0 test/spec/ol/geom/geometrycollection.test.js
  61. +45 −0 test/spec/ol/geom/linearring.test.js
  62. +103 −0 test/spec/ol/geom/linestring.test.js
  63. +88 −0 test/spec/ol/geom/multilinestring.test.js
  64. +74 −0 test/spec/ol/geom/multipoint.test.js
  65. +92 −0 test/spec/ol/geom/multipolygon.test.js
  66. +106 −0 test/spec/ol/geom/point.test.js
  67. +89 −0 test/spec/ol/geom/polygon.test.js
  68. +202 −0 test/spec/ol/geom/sharedvertices.test.js
  69. +195 −0 test/spec/ol/layer/vectorlayer.test.js
  70. +228 −0 test/spec/ol/parser/geojson.test.js
  71. +181 −0 test/spec/ol/parser/geojson/countries.json
  72. +17 −0 test/spec/ol/source/vectorsource.test.js
  73. +62 −0 test/spec/ol/structs/rtree.test.js
  74. +79 −0 test/spec/ol/style/line.test.js
  75. +95 −0 test/spec/ol/style/polygon.test.js
  76. +33 −0 test/spec/ol/style/rule.test.js
  77. +126 −0 test/spec/ol/style/shape.test.js
  78. +73 −0 test/spec/ol/style/style.test.js
View
@@ -39,7 +39,9 @@
"disambiguate-properties": true,
"externs": [
+ "//json.js",
"externs/bingmaps.js",
+ "externs/geojson.js",
"externs/proj4js.js",
"externs/tilejson.js"
],
View
@@ -13,7 +13,9 @@
"id": "ol-simple",
"externs": [
+ "//json.js",
"externs/bingmaps.js",
+ "externs/geojson.js",
"externs/proj4js.js",
"externs/tilejson.js"
],
View
@@ -14,7 +14,9 @@
"disambiguate-properties": false,
"externs": [
+ "//json.js",
"externs/bingmaps.js",
+ "externs/geojson.js",
"externs/proj4js.js",
"externs/tilejson.js"
],
View
@@ -13,8 +13,10 @@
"css-output-file": "build/ol.css",
"externs": [
+ "//json.js",
"build/src/external/externs/types.js",
"externs/bingmaps.js",
+ "externs/geojson.js",
"externs/proj4js.js",
"externs/tilejson.js"
],
View
@@ -0,0 +1,52 @@
+<!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="bootstrap/css/bootstrap.min.css" type="text/css">
+ <link rel="stylesheet" href="examples.css" type="text/css">
+ <link rel="stylesheet" href="bootstrap/css/bootstrap-responsive.min.css" type="text/css">
+ <title>Style with rules 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><a href="https://github.com/openlayers/ol3"><i class="icon-github"></i></a></li>
+ <li><a href="https://twitter.com/openlayers"><i class="icon-twitter"></i></a></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">Style with rules example</h4>
+ <p id="shortdesc">Draws features with rule based styles.</p>
+ <div id="docs">
+ <p>See the <a href="style-rules.js" target="_blank">style-rules.js source</a> to see how this is done.</p>
+ </div>
+ <div id="tags">vector, geojson, style</div>
+ </div>
+
+ </div>
+
+ </div>
+
+ <script src="loader.js?id=style-rules" type="text/javascript"></script>
+
+ </body>
+</html>
View
@@ -0,0 +1,136 @@
+goog.require('ol.Collection');
+goog.require('ol.Coordinate');
+goog.require('ol.Expression');
+goog.require('ol.Feature');
+goog.require('ol.Map');
+goog.require('ol.RendererHint');
+goog.require('ol.View2D');
+goog.require('ol.control.defaults');
+goog.require('ol.filter.Filter');
+goog.require('ol.geom.LineString');
+goog.require('ol.layer.Vector');
+goog.require('ol.parser.GeoJSON');
+goog.require('ol.projection');
+goog.require('ol.source.Vector');
+goog.require('ol.style.Line');
+goog.require('ol.style.Rule');
+goog.require('ol.style.Style');
+
+
+var style = new ol.style.Style({rules: [
+ new ol.style.Rule({
+ filter: new ol.filter.Filter(function(feature) {
+ return feature.get('where') == 'outer';
+ }),
+ symbolizers: [
+ new ol.style.Line({
+ strokeColor: new ol.Expression('color'),
+ strokeWidth: 4,
+ opacity: 1
+ })
+ ]
+ }),
+ new ol.style.Rule({
+ filter: new ol.filter.Filter(function(feature) {
+ return feature.get('where') == 'inner';
+ }),
+ symbolizers: [
+ new ol.style.Line({
+ strokeColor: '#013',
+ strokeWidth: 4,
+ opacity: 1
+ }),
+ new ol.style.Line({
+ strokeColor: new ol.Expression('color'),
+ strokeWidth: 2,
+ opacity: 1
+ })
+ ]
+ })
+]});
+
+var vector = new ol.layer.Vector({
+ style: style,
+ source: new ol.source.Vector({
+ projection: ol.projection.get('EPSG:3857')
+ })
+});
+
+vector.parseFeatures({
+ 'type': 'FeatureCollection',
+ 'features': [{
+ 'type': 'Feature',
+ 'properties': {
+ 'color': '#BADA55',
+ 'where': 'inner'
+ },
+ 'geometry': {
+ 'type': 'LineString',
+ 'coordinates': [[-10000000, -10000000], [10000000, 10000000]]
+ }
+ }, {
+ 'type': 'Feature',
+ 'properties': {
+ 'color': '#BADA55',
+ 'where': 'inner'
+ },
+ 'geometry': {
+ 'type': 'LineString',
+ 'coordinates': [[-10000000, 10000000], [10000000, -10000000]]
+ }
+ }, {
+ 'type': 'Feature',
+ 'properties': {
+ 'color': '#013',
+ 'where': 'outer'
+ },
+ 'geometry': {
+ 'type': 'LineString',
+ 'coordinates': [[-10000000, -10000000], [-10000000, 10000000]]
+ }
+ }, {
+ 'type': 'Feature',
+ 'properties': {
+ 'color': '#013',
+ 'where': 'outer'
+ },
+ 'geometry': {
+ 'type': 'LineString',
+ 'coordinates': [[-10000000, 10000000], [10000000, 10000000]]
+ }
+ }, {
+ 'type': 'Feature',
+ 'properties': {
+ 'color': '#013',
+ 'where': 'outer'
+ },
+ 'geometry': {
+ 'type': 'LineString',
+ 'coordinates': [[10000000, 10000000], [10000000, -10000000]]
+ }
+ }, {
+ 'type': 'Feature',
+ 'properties': {
+ 'color': '#013',
+ 'where': 'outer'
+ },
+ 'geometry': {
+ 'type': 'LineString',
+ 'coordinates': [[10000000, -10000000], [-10000000, -10000000]]
+ }
+ }]
+}, new ol.parser.GeoJSON(), ol.projection.get('EPSG:3857'));
+
+
+var map = new ol.Map({
+ layers: [vector],
+ controls: ol.control.defaults({
+ attribution: false
+ }),
+ renderer: ol.RendererHint.CANVAS,
+ target: 'map',
+ view: new ol.View2D({
+ center: new ol.Coordinate(0, 0),
+ zoom: 1
+ })
+});
View
@@ -0,0 +1,52 @@
+<!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="bootstrap/css/bootstrap.min.css" type="text/css">
+ <link rel="stylesheet" href="examples.css" type="text/css">
+ <link rel="stylesheet" href="bootstrap/css/bootstrap-responsive.min.css" type="text/css">
+ <title>Vector layer 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><a href="https://github.com/openlayers/ol3"><i class="icon-github"></i></a></li>
+ <li><a href="https://twitter.com/openlayers"><i class="icon-twitter"></i></a></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">Vector layer example</h4>
+ <p id="shortdesc">Example of a vector layer.</p>
+ <div id="docs">
+ <p>See the <a href="vector-layer.js" target="_blank">vector-layer.js source</a> to see how this is done.</p>
+ </div>
+ <div id="tags">vector, geojson, style</div>
+ </div>
+
+ </div>
+
+ </div>
+
+ <script src="loader.js?id=vector-layer" type="text/javascript"></script>
+
+ </body>
+</html>
View
@@ -0,0 +1,71 @@
+goog.require('ol.Collection');
+goog.require('ol.Coordinate');
+goog.require('ol.Feature');
+goog.require('ol.Map');
+goog.require('ol.RendererHint');
+goog.require('ol.View2D');
+goog.require('ol.geom.LineString');
+goog.require('ol.geom.Point');
+goog.require('ol.layer.TileLayer');
+goog.require('ol.layer.Vector');
+goog.require('ol.parser.GeoJSON');
+goog.require('ol.projection');
+goog.require('ol.source.MapQuestOpenAerial');
+goog.require('ol.source.Vector');
+goog.require('ol.style.Polygon');
+goog.require('ol.style.Rule');
+goog.require('ol.style.Style');
+
+
+var map;
+
+var raster = new ol.layer.TileLayer({
+ source: new ol.source.MapQuestOpenAerial()
+});
+
+var vector = new ol.layer.Vector({
+ source: new ol.source.Vector({
+ projection: ol.projection.get('EPSG:4326')
+ }),
+ style: new ol.style.Style({rules: [
+ new ol.style.Rule({
+ symbolizers: [
+ new ol.style.Polygon({
+ strokeStyle: '#696969',
+ strokeWidth: 1,
+ opacity: 1.5
+ })
+ ]
+ })
+ ]})
+});
+
+var geojson = new ol.parser.GeoJSON();
+var url = '../test/spec/ol/parser/geojson/countries.json';
+var xhr = new XMLHttpRequest();
+xhr.open('GET', url, true);
+
+
+/**
+ * onload handler for the XHR request.
+ */
+xhr.onload = function() {
+ if (xhr.status == 200) {
+ // this is silly to have to tell the layer the destination projection
+ var projection = map.getView().getProjection();
+ vector.parseFeatures(xhr.responseText, geojson, projection);
+ } else {
+ throw new Error('Data loading failed: ' + xhr.status);
+ }
+};
+xhr.send();
+
+map = new ol.Map({
+ layers: new ol.Collection([raster, vector]),
+ renderer: ol.RendererHint.CANVAS,
+ target: 'map',
+ view: new ol.View2D({
+ center: new ol.Coordinate(0, 0),
+ zoom: 1
+ })
+});
Oops, something went wrong.

0 comments on commit 76d1a0c

Please sign in to comment.