summaryrefslogtreecommitdiff
path: root/misc/openlayers/examples/utfgrid.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/utfgrid.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/utfgrid.js')
-rw-r--r--misc/openlayers/examples/utfgrid.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/misc/openlayers/examples/utfgrid.js b/misc/openlayers/examples/utfgrid.js
new file mode 100644
index 0000000..dc06c41
--- /dev/null
+++ b/misc/openlayers/examples/utfgrid.js
@@ -0,0 +1,61 @@
+var osm = new OpenLayers.Layer.OSM();
+
+var utfgrid = new OpenLayers.Layer.UTFGrid({
+ url: "utfgrid/world_utfgrid/${z}/${x}/${y}.json",
+ utfgridResolution: 4, // default is 2
+ displayInLayerSwitcher: false
+});
+
+var map = new OpenLayers.Map({
+ div: "map",
+ projection: "EPSG:900913",
+ controls: [],
+ layers: [osm, utfgrid],
+ center: [0, 0],
+ zoom: 1
+});
+
+var callback = function(infoLookup) {
+ var msg = "";
+ if (infoLookup) {
+ var info;
+ for (var idx in infoLookup) {
+ // idx can be used to retrieve layer from map.layers[idx]
+ info = infoLookup[idx];
+ if (info && info.data) {
+ msg += "[" + info.id + "] <strong>In 2005, " +
+ info.data.NAME + " had a population of " +
+ info.data.POP2005 + " people.</strong> ";
+ }
+ }
+ }
+ document.getElementById("attrs").innerHTML = msg;
+};
+
+var controls = {
+ move: new OpenLayers.Control.UTFGrid({
+ callback: callback,
+ handlerMode: "move"
+ }),
+ hover: new OpenLayers.Control.UTFGrid({
+ callback: callback,
+ handlerMode: "hover"
+ }),
+ click: new OpenLayers.Control.UTFGrid({
+ callback: callback,
+ handlerMode: "click"
+ })
+};
+for (var key in controls) {
+ map.addControl(controls[key]);
+}
+
+function toggleControl(el) {
+ for (var c in controls) {
+ controls[c].deactivate();
+ }
+ controls[el.value].activate();
+}
+
+// activate the control that responds to mousemove
+toggleControl({value: "move"});