summaryrefslogtreecommitdiff
path: root/misc/openlayers/examples/fusiontables.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/fusiontables.js
parent59741cd535c47f25971bf8c32b25da25ceadc6d5 (diff)
downloadpostrunner-ea346a785dc1b3f7c156f6fc33da634e1f1a627b.zip
Adding jquery, flot and openlayers to be included with the GEM.v0.0.4
Diffstat (limited to 'misc/openlayers/examples/fusiontables.js')
-rw-r--r--misc/openlayers/examples/fusiontables.js51
1 files changed, 51 insertions, 0 deletions
diff --git a/misc/openlayers/examples/fusiontables.js b/misc/openlayers/examples/fusiontables.js
new file mode 100644
index 0000000..57ae6e5
--- /dev/null
+++ b/misc/openlayers/examples/fusiontables.js
@@ -0,0 +1,51 @@
+// change this to your api key
+var apikey = "AIzaSyD_1zzMAoZjuP-m4LyhieuYmqiVJTEajyI";
+
+var map = new OpenLayers.Map({
+ div: "map",
+ layers: [
+ new OpenLayers.Layer.OSM(),
+ new OpenLayers.Layer.Vector("Vectors", {
+ projection: new OpenLayers.Projection("EPSG:4326"),
+ strategies: [new OpenLayers.Strategy.Fixed()],
+ protocol: new OpenLayers.Protocol.Script({
+ url: "https://www.googleapis.com/fusiontables/v1/query",
+ params: {
+ sql: "select * from 1g5DrXcdotCiO_yffkdW0zhuJk0a1i80SPvERHI8",
+ key: apikey
+ },
+ format: new OpenLayers.Format.GeoJSON({
+ ignoreExtraDims: true,
+ read: function(json) {
+ var row, feature, atts = {}, features = [];
+ var cols = json.columns; // column names
+ for (var i = 0; i < json.rows.length; i++) {
+ row = json.rows[i];
+ feature = new OpenLayers.Feature.Vector();
+ atts = {};
+ for (var j = 0; j < row.length; j++) {
+ // 'location's are json objects, other types are strings
+ if (typeof row[j] === "object") {
+ feature.geometry = this.parseGeometry(row[j].geometry);
+ } else {
+ atts[cols[j]] = row[j];
+ }
+ }
+ feature.attributes = atts;
+ // if no geometry, not much point in continuing with this row
+ if (feature.geometry) {
+ features.push(feature);
+ }
+ }
+ return features;
+ }
+ })
+ }),
+ eventListeners: {
+ "featuresadded": function () {
+ this.map.zoomToExtent(this.getDataExtent());
+ }
+ }
+ })
+ ]
+});