summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristopher Baines <cb15g11@soton.ac.uk>2014-09-06 18:30:13 +0100
committerChristopher Baines <cb15g11@soton.ac.uk>2014-09-06 18:30:13 +0100
commit903dbcd6c4c4343355008aabe0b98afa52159313 (patch)
treeb33fedcfbabb96eeb2f940624c3edcccaf89439d /src
parent063c97feb6a9cafc822fab0b53e66ff1cd0c10a3 (diff)
downloadleaflet-soton-903dbcd6c4c4343355008aabe0b98afa52159313.tar
leaflet-soton-903dbcd6c4c4343355008aabe0b98afa52159313.tar.gz
Add panByURI method
Diffstat (limited to 'src')
-rw-r--r--src/leaflet-soton.js62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/leaflet-soton.js b/src/leaflet-soton.js
index e5bb696..baaafa9 100644
--- a/src/leaflet-soton.js
+++ b/src/leaflet-soton.js
@@ -882,6 +882,68 @@ SELECT * WHERE {\
throw "unable to handle " + feature.geometry.type;
}
},
+ panByURI: function(uri) {
+ var feature = LS.getFeatureByURI(uri);
+
+ if (feature === null) {
+ throw "can't find " + uri;
+ }
+
+ if (!("geometry" in feature)) {
+ throw "no location for " + uri;
+ }
+
+ if (feature.geometry.type === "Polygon") {
+ console.log(feature);
+
+ var center;
+ if ("center" in feature.properties) {
+ center = feature.properties.center;
+ } else {
+ center = feature.geometry.coordinates[0][0];
+ center = [center[1], center[0]];
+ }
+
+ this.panTo(center);
+
+ if ("level" in feature.properties) {
+ if (L.Util.isArray(feature.properties.level)) {
+ this.setLevel(feature.properties.level[0]);
+ } else {
+ this.setLevel(feature.properties.level);
+ }
+ }
+
+ this.closePopup();
+
+ return;
+ } else if (feature.geometry.type === "Point") {
+ this.panTo(L.GeoJSON.coordsToLatLng(feature.geometry.coordinates));
+
+ if ("level" in feature.properties) {
+ if (L.Util.isArray(feature.properties.level)) {
+ this.setLevel(feature.properties.level[0]);
+ } else {
+ this.setLevel(feature.properties.level);
+ }
+ } else {
+ // If this is a workstation
+ if (uri.indexOf("http://id.southampton.ac.uk/point-of-service/workstations") === 0) {
+ var room = LS.getRoomFor(uri);
+
+ if (room !== null) {
+ this.setLevel(room.properties.level);
+ }
+ }
+ }
+
+ this.closePopup();
+ return;
+ } else {
+ throw "unable to handle " + feature.geometry.type;
+ }
+
+ },
showInfo: function(content, latlng, options) {
options = options || {};