summaryrefslogtreecommitdiff
path: root/misc/openlayers/examples/cartodb-geojson.html
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/cartodb-geojson.html
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/cartodb-geojson.html')
-rw-r--r--misc/openlayers/examples/cartodb-geojson.html71
1 files changed, 71 insertions, 0 deletions
diff --git a/misc/openlayers/examples/cartodb-geojson.html b/misc/openlayers/examples/cartodb-geojson.html
new file mode 100644
index 0000000..2d78970
--- /dev/null
+++ b/misc/openlayers/examples/cartodb-geojson.html
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Reading Features From CartoDB using GeoJSON</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <link rel="stylesheet" href="../theme/default/style.css" type="text/css">
+ <link rel="stylesheet" href="style.css" type="text/css">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
+ <meta name="apple-mobile-web-app-capable" content="yes">
+ <script src="../lib/OpenLayers.js"></script>
+ </head>
+ <body>
+ <h1 id="title">Reading Features From CartoDB using GeoJSON</h1>
+ <div id="tags">
+ protocol, script, cartodb
+ </div>
+ <p id="shortdesc">
+ Demonstrates how to load features on OpenLayers using CartoDB SQL API.
+ </p>
+ <div id="map" class="smallmap"></div>
+ <div id="docs">
+ <p>
+ <a href="http://cartodb.com/">CartoDB</a> is an Open Source
+ Geopatial Database on the cloud. It allows you to import your
+ data in shapefiles, KML, OpenStreeMap files, CSV, etc. and
+ then analyze and visualize it. Internally CartoDB uses PostGIS
+ 2.0 so all functionality in PostGIS can be used straight
+ away. CartoDB exposes two APIS. One
+ to <a href="http://developers.cartodb.com/documentation/cartodb-apis.html#maps_api">generate maps</a>
+ as tiles with interactivity, and another <a href="http://developers.cartodb.com/documentation/cartodb-apis.html#sql_api">SQL API</a>
+ to retrieve vector data using among other formats, GeoJSON. In
+ this example we do a very simple query to obtain all protected
+ areas in Costa Rica from a public table. You can adapt the SQL
+ to include where clauses or complicate geospatial queries.
+ </p>
+ <p>
+ View the source code of this page to see how this is done. And
+ check the table on CartoDB
+ for <a href="https://examples.cartodb.com/tables/costa_rica_pa/public#/map">Protected Areas in Costa Rica</a>
+ </p>
+ </div>
+ <script>
+ 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: "http://examples.cartodb.com/api/v2/sql",
+ params: {
+ q: "select * from costa_rica_pa LIMIT 50",
+ format: "geojson"
+ },
+ format: new OpenLayers.Format.GeoJSON({
+ ignoreExtraDims: true
+ }),
+ callbackKey: "callback"
+ }),
+ eventListeners: {
+ "featuresadded": function() {
+ this.map.zoomToExtent(this.getDataExtent());
+ }
+ }
+ })
+ ]
+ });
+ </script>
+ </body>
+</html>