summaryrefslogtreecommitdiff
path: root/misc/openlayers/examples/canvas.js
diff options
context:
space:
mode:
authorChris Schlaeger <chris@linux.com>2014-08-12 21:56:44 +0200
committerChris Schlaeger <chris@linux.com>2014-08-12 21:56:44 +0200
commitea346a785dc1b3f7c156f6fc33da634e1f1a627b (patch)
treeaf67530553d20b6e82ad60fd79593e9c4abf5565 /misc/openlayers/examples/canvas.js
parent59741cd535c47f25971bf8c32b25da25ceadc6d5 (diff)
downloadpostrunner-fb1989bda5d3e0a5472ba7644d57cae197733a8f.zip
Adding jquery, flot and openlayers to be included with the GEM.v0.0.4
Diffstat (limited to 'misc/openlayers/examples/canvas.js')
-rw-r--r--misc/openlayers/examples/canvas.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/misc/openlayers/examples/canvas.js b/misc/openlayers/examples/canvas.js
new file mode 100644
index 0000000..bb2f224
--- /dev/null
+++ b/misc/openlayers/examples/canvas.js
@@ -0,0 +1,57 @@
+var map, layer, styleMap;
+OpenLayers.ProxyHost = "proxy.cgi?url=";
+
+function init() {
+ map = new OpenLayers.Map({
+ div: "map",
+ projection: new OpenLayers.Projection("EPSG:900913"),
+ displayProjection: new OpenLayers.Projection("EPSG:4326")
+ });
+
+ var g = new OpenLayers.Layer.Google("Google Layer", {
+ sphericalMercator: true
+ });
+ map.addLayers([g]);
+
+ // prepare to style the data
+ styleMap = new OpenLayers.StyleMap({
+ strokeColor: "black",
+ strokeWidth: 2,
+ strokeOpacity: 0.5,
+ fillOpacity: 0.2
+ });
+
+ // create a color table for state FIPS code
+ var colors = ["red", "orange", "yellow", "green", "blue", "purple"];
+ var code, fips = {};
+ for(var i=1; i<=66; ++i) {
+ code = "0" + i;
+ code = code.substring(code.length - 2);
+ fips[code] = {fillColor: colors[i % colors.length]};
+ }
+ // add unique value rules with your color lookup
+ styleMap.addUniqueValueRules("default", "STATE_FIPS", fips);
+
+ // create a vector layer using the canvas renderer (where available)
+ var wfs = new OpenLayers.Layer.Vector("States", {
+ strategies: [new OpenLayers.Strategy.BBOX()],
+ protocol: new OpenLayers.Protocol.WFS({
+ version: "1.1.0",
+ srsName: "EPSG:900913",
+ url: "http://v2.suite.opengeo.org/geoserver/wfs",
+ featureType: "states",
+ featureNS: "http://usa.opengeo.org"
+ }),
+ styleMap: styleMap,
+ renderers: ["Canvas", "SVG", "VML"]
+ });
+ map.addLayer(wfs);
+
+ // if you want to use Geographic coords, transform to ESPG:900913
+ var ddBounds = new OpenLayers.Bounds(
+ -73.839111,40.287907,-68.214111,44.441624
+ );
+ map.zoomToExtent(
+ ddBounds.transform(map.displayProjection, map.getProjectionObject())
+ );
+}