Commit f1de8360891e7cb1952b9b51897fe58480ebc691
Adding features
- Annotations are now posted as a (s)tweet.
- myVector.js 79 ------------------------------+++++++++++++++++++++++++++++++++++++++++++++++++
| | | | 1 | var map, vectorLayer; | 1 | var map, vectorLayer; |
---|
2 | var mapBounds = new OpenLayers.Bounds( 0.0, -4668.0, 31110.0, 0.0); | 2 | var mapBounds = new OpenLayers.Bounds( 0.0, -4668.0, 31110.0, 0.0); |
---|
3 | var mapMinZoom = 0; | 3 | var mapMinZoom = 0; |
---|
4 | var mapMaxZoom = 7; | | var mapMaxZoom = 7; |
---|
| | 4 | var mapMaxZoom = 7; | 5 | var boxes; | 5 | var boxes; |
---|
6 | var box_extents = [ | 6 | var box_extents = [ |
---|
7 | [3759.0000, -1614.33337, 4079.0000, -1274.33337], | 7 | [3759.0000, -1614.33337, 4079.0000, -1274.33337], |
---|
… | | … | |
---|
14 | var ans = { | 14 | var ans = { |
---|
15 | ans: [], | 15 | ans: [], |
---|
16 | count: 0 | 16 | count: 0 |
---|
17 | | | |
---|
| | 17 | | 18 | }; | 18 | }; |
---|
| | 19 | var user; |
---|
19 | // avoid pink tiles | 20 | // avoid pink tiles |
---|
20 | OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3; | 21 | OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3; |
---|
21 | OpenLayers.Util.onImageLoadErrorColor = "transparent"; | 22 | OpenLayers.Util.onImageLoadErrorColor = "transparent"; |
---|
… | | … | |
---|
52 | {"jewelery":"Pendant"}, | 52 | {"jewelery":"Pendant"}, |
---|
53 | {"Material":"Silver"} | 53 | {"Material":"Silver"} |
---|
54 | ], | 54 | ], |
---|
55 | "size": "50px X 90px" | | "size": "50px X 90px" |
---|
| | 55 | "size": "50px X 90px" | 56 | }; | 56 | }; |
---|
57 | onMyFeatureSelect(map,myjson,3751,-1802) | 57 | onMyFeatureSelect(map,myjson,3751,-1802) |
---|
58 | } | 58 | } |
---|
… | | … | |
---|
132 | numZoomLevels: 8 | 132 | numZoomLevels: 8 |
---|
133 | }; | 133 | }; |
---|
134 | map = new OpenLayers.Map('map', options); | 134 | map = new OpenLayers.Map('map', options); |
---|
135 | $.get("http://192.168.100.56:82/fetch", function(data){ | | $.get("http://192.168.100.56:82/fetch", function(data){ |
---|
| | 135 | $.get(config.indexer+"/fetch", function(data){ | 136 | return; | 136 | return; |
---|
137 | if (data.length != 0) | 137 | if (data.length != 0) |
---|
138 | { | 138 | { |
---|
… | | … | |
---|
145 | | 145 | |
---|
146 | } | 146 | } |
---|
147 | | 147 | |
---|
148 | }); | | }); |
---|
| | 148 | }); | 149 | var layer = new OpenLayers.Layer.TMS( "TMS Layer","", | 149 | var layer = new OpenLayers.Layer.TMS( "TMS Layer","", |
---|
150 | { url: '', serviceVersion: '.', layername: '.', alpha: true, | 150 | { url: '', serviceVersion: '.', layername: '.', alpha: true, |
---|
151 | type: 'png', getURL: overlay_getTileURL | | type: 'png', getURL: overlay_getTileURL |
---|
152 | }); | | }); |
---|
| | 151 | type: 'png', getURL: overlay_getTileURL | | | 152 | }); |
---|
153 | boxes = new OpenLayers.Layer.Vector( "Boxes" ); | 153 | boxes = new OpenLayers.Layer.Vector( "Boxes" ); |
---|
154 | map.addLayers([layer, boxes]); | 154 | map.addLayers([layer, boxes]); |
---|
155 | | | |
---|
| | 155 | | 156 | boxes.events.register('featureadded', boxes, myfeatureadded); | 156 | boxes.events.register('featureadded', boxes, myfeatureadded); |
---|
157 | box2 = new OpenLayers.Layer.Vector( "Boxes" ); | 157 | box2 = new OpenLayers.Layer.Vector( "Boxes" ); |
---|
158 | for (var i = 0; i < box_extents.length; i++) { | 158 | for (var i = 0; i < box_extents.length; i++) { |
---|
159 | ext = box_extents[i]; | 159 | ext = box_extents[i]; |
---|
160 | bounds = OpenLayers.Bounds.fromArray(ext); | 160 | bounds = OpenLayers.Bounds.fromArray(ext); |
---|
161 | | | |
---|
| | 161 | | 162 | box = new OpenLayers.Feature.Vector(bounds.toGeometry()); | 162 | box = new OpenLayers.Feature.Vector(bounds.toGeometry()); |
---|
163 | box2.addFeatures(box); | 163 | box2.addFeatures(box); |
---|
164 | } | 164 | } |
---|
… | | … | |
---|
166 | for (var i = 0; i < box_extents1.length; i++) { | 166 | for (var i = 0; i < box_extents1.length; i++) { |
---|
167 | ext = box_extents1[i]; | 167 | ext = box_extents1[i]; |
---|
168 | bounds = OpenLayers.Bounds.fromArray(ext); | 168 | bounds = OpenLayers.Bounds.fromArray(ext); |
---|
169 | | | |
---|
| | 169 | | 170 | box = new OpenLayers.Feature.Vector(bounds.toGeometry()); | 170 | box = new OpenLayers.Feature.Vector(bounds.toGeometry()); |
---|
171 | box3.addFeatures(box); | 171 | box3.addFeatures(box); |
---|
172 | } | 172 | } |
---|
173 | map.addLayers([box2, box3]); | 173 | map.addLayers([box2, box3]); |
---|
174 | | | |
---|
| | 174 | | 175 | selectControl = new OpenLayers.Control.SelectFeature(box3, | 175 | selectControl = new OpenLayers.Control.SelectFeature(box3, |
---|
176 | {onSelect: onFeatureSelect}); | 176 | {onSelect: onFeatureSelect}); |
---|
177 | | | |
---|
| | 177 | | 178 | drawControls = { | 178 | drawControls = { |
---|
179 | box : new OpenLayers.Control.DrawFeature(boxes, | 179 | box : new OpenLayers.Control.DrawFeature(boxes, |
---|
180 | OpenLayers.Handler.RegularPolygon, { | 180 | OpenLayers.Handler.RegularPolygon, { |
---|
… | | … | |
---|
187 | select: selectControl | 187 | select: selectControl |
---|
188 | }; | 188 | }; |
---|
189 | | 189 | |
---|
190 | map.zoomToExtent( mapBounds ); | | map.zoomToExtent( mapBounds ); |
---|
| | 190 | map.zoomToExtent( mapBounds ); | 191 | for(var key in drawControls){ | 191 | for(var key in drawControls){ |
---|
192 | map.addControl(drawControls[key]); | 192 | map.addControl(drawControls[key]); |
---|
193 | } | 193 | } |
---|
194 | drawControls['select'].activate(); | 194 | drawControls['select'].activate(); |
---|
195 | addLabel('3759.0000','-1274.33337','Face'); | 195 | addLabel('3759.0000','-1274.33337','Face'); |
---|
196 | addLabel('3719','-1771','Jewelery'); | 196 | addLabel('3719','-1771','Jewelery'); |
---|
197 | addLabel('4263.0000','-1345.33337', 'Video'); | | addLabel('4263.0000','-1345.33337', 'Video'); |
---|
| | 197 | addLabel('4263.0000','-1345.33337', 'Video'); | 198 | map.addControl(new OpenLayers.Control.PanZoomBar()); | 198 | map.addControl(new OpenLayers.Control.PanZoomBar()); |
---|
199 | map.addControl(new OpenLayers.Control.MousePosition()); | 199 | map.addControl(new OpenLayers.Control.MousePosition()); |
---|
200 | map.addControl(new OpenLayers.Control.MouseDefaults()); | 200 | map.addControl(new OpenLayers.Control.MouseDefaults()); |
---|
… | | … | |
---|
207 | { | 207 | { |
---|
208 | var renderer = OpenLayers.Util.getParameters(window.location.href).renderer; | 208 | var renderer = OpenLayers.Util.getParameters(window.location.href).renderer; |
---|
209 | renderer = (renderer) ? [renderer] : OpenLayers.Layer.Vector.prototype.renderers; | 209 | renderer = (renderer) ? [renderer] : OpenLayers.Layer.Vector.prototype.renderers; |
---|
210 | | | |
---|
| | 210 | | 211 | vectorLayer = new OpenLayers.Layer.Vector("Simple Geometry", { | 211 | vectorLayer = new OpenLayers.Layer.Vector("Simple Geometry", { |
---|
212 | styleMap: new OpenLayers.StyleMap({'default':{ | 212 | styleMap: new OpenLayers.StyleMap({'default':{ |
---|
213 | strokeColor: "#000", | 213 | strokeColor: "#000", |
---|
… | | … | |
---|
220 | // label with \n linebreaks | 220 | // label with \n linebreaks |
---|
221 | label : "${name}\n", | 221 | label : "${name}\n", |
---|
222 | //\nage: ${age}", | 222 | //\nage: ${age}", |
---|
223 | | | |
---|
| | 223 | | 224 | fontColor: "#000", | 224 | fontColor: "#000", |
---|
225 | fontSize: "16px", | 225 | fontSize: "16px", |
---|
226 | fontFamily: "Georgia, Serif", | 226 | fontFamily: "Georgia, Serif", |
---|
… | | … | |
---|
247 | } | 247 | } |
---|
248 | function makeBoxes(x) | 248 | function makeBoxes(x) |
---|
249 | { | 249 | { |
---|
250 | | | |
---|
| | 250 | | 251 | bounds = new OpenLayers.Bounds(x['left'], x['bottom'], x['right'], x['top']); | 251 | bounds = new OpenLayers.Bounds(x['left'], x['bottom'], x['right'], x['top']); |
---|
252 | box = new OpenLayers.Feature.Vector(bounds.toGeometry()); | 252 | box = new OpenLayers.Feature.Vector(bounds.toGeometry()); |
---|
253 | box3.addFeatures(box); | 253 | box3.addFeatures(box); |
---|
254 | addLabel(x['left'],x['top'],x['name']); | 254 | addLabel(x['left'],x['top'],x['name']); |
---|
255 | } | | } |
---|
| | 255 | } | 256 | // function onmouse(data){ | 256 | // function onmouse(data){ |
---|
257 | // console.log(data); | 257 | // console.log(data); |
---|
258 | // } | 258 | // } |
---|
… | | … | |
---|
260 | { | 260 | { |
---|
261 | var renderer = OpenLayers.Util.getParameters(window.location.href).renderer; | 261 | var renderer = OpenLayers.Util.getParameters(window.location.href).renderer; |
---|
262 | renderer = (renderer) ? [renderer] : OpenLayers.Layer.Vector.prototype.renderers; | 262 | renderer = (renderer) ? [renderer] : OpenLayers.Layer.Vector.prototype.renderers; |
---|
263 | | | |
---|
| | 263 | | 264 | vectorLayer = new OpenLayers.Layer.Vector("Simple Geometry", { | 264 | vectorLayer = new OpenLayers.Layer.Vector("Simple Geometry", { |
---|
265 | styleMap: new OpenLayers.StyleMap({'default':{ | 265 | styleMap: new OpenLayers.StyleMap({'default':{ |
---|
266 | strokeColor: "#000", | 266 | strokeColor: "#000", |
---|
… | | … | |
---|
273 | // label with \n linebreaks | 273 | // label with \n linebreaks |
---|
274 | label : "${name}\n", | 274 | label : "${name}\n", |
---|
275 | //\nage: ${age}", | 275 | //\nage: ${age}", |
---|
276 | | | |
---|
| | 276 | | 277 | fontColor: "#000", | 277 | fontColor: "#000", |
---|
278 | fontSize: "16px", | 278 | fontSize: "16px", |
---|
279 | fontFamily: "Georgia, Serif", | 279 | fontFamily: "Georgia, Serif", |
---|
… | | … | |
---|
293 | align: 'cm', | 293 | align: 'cm', |
---|
294 | favColor: 'blue', | 294 | favColor: 'blue', |
---|
295 | }; | 295 | }; |
---|
296 | labelFeature.attributes['name'] = prompt("Enter a name"); | | labelFeature.attributes['name'] = prompt("Enter a name"); |
---|
| | 296 | labelFeature.attributes['name'] = prompt("Enter a label for the annotation.."); | | | 297 | user = prompt("Enter your name"); |
---|
297 | if(labelFeature.attributes['name']) | 298 | if(labelFeature.attributes['name']) |
---|
298 | { | 299 | { |
---|
299 | topValue = myObj.feature.geometry.bounds.top; | 300 | topValue = myObj.feature.geometry.bounds.top; |
---|
… | | … | |
---|
337 | var y = Math.round((bounds.bottom - this.maxExtent.bottom) / (res * this.tileSize.h)); | 337 | var y = Math.round((bounds.bottom - this.maxExtent.bottom) / (res * this.tileSize.h)); |
---|
338 | var z = this.map.getZoom(); | 338 | var z = this.map.getZoom(); |
---|
339 | if (x >= 0 && y >= 0) { | 339 | if (x >= 0 && y >= 0) { |
---|
340 | return this.url + z + "/" + x + "/" + y + "." + this.type; | | return this.url + z + "/" + x + "/" + y + "." + this.type; |
---|
| | 340 | return this.url + z + "/" + x + "/" + y + "." + this.type; | 341 | } else { | 341 | } else { |
---|
342 | return "http://www.maptiler.org/img/none.png"; | 342 | return "http://www.maptiler.org/img/none.png"; |
---|
343 | } | 343 | } |
---|
… | | … | |
---|
359 | return 0; | 359 | return 0; |
---|
360 | } | 360 | } |
---|
361 | | 361 | |
---|
362 | function resize() { | | function resize() { |
---|
363 | var map = document.getElementById("map"); | | var map = document.getElementById("map"); |
---|
364 | var header = document.getElementById("header"); | | var header = document.getElementById("header"); |
---|
365 | var subheader = document.getElementById("subheader"); | | var subheader = document.getElementById("subheader"); |
---|
| | 362 | function resize() { | | | 363 | var map = document.getElementById("map"); |
---|
| | 364 | var header = document.getElementById("header"); |
---|
| | 365 | var subheader = document.getElementById("subheader"); |
---|
366 | map.style.height = (getWindowHeight()-180) +"px"; | 366 | map.style.height = (getWindowHeight()-180) +"px"; |
---|
367 | map.style.width = (getWindowWidth()-60) + "px"; | 367 | map.style.width = (getWindowWidth()-60) + "px"; |
---|
368 | //header.style.width = (getWindowWidth()-60) + "px"; | 368 | //header.style.width = (getWindowWidth()-60) + "px"; |
---|
369 | subheader.style.width = (getWindowWidth()-60) + "px"; | 369 | subheader.style.width = (getWindowWidth()-60) + "px"; |
---|
370 | if (map.updateSize) { map.updateSize(); }; | 370 | if (map.updateSize) { map.updateSize(); }; |
---|
371 | } | | } |
---|
| | 371 | } | 372 | function allowPan(element) { | 372 | function allowPan(element) { |
---|
373 | var stop = !element.checked; | 373 | var stop = !element.checked; |
---|
374 | for(var key in drawControls){ | 374 | for(var key in drawControls){ |
---|
… | | … | |
---|
379 | onresize=function(){ resize();}; | 379 | onresize=function(){ resize();}; |
---|
380 | function publish() | 380 | function publish() |
---|
381 | { | 381 | { |
---|
382 | $.post("http://192.168.100.56:82/submit", JSON.stringify(myJSON), function(data) { | | $.post("http://192.168.100.56:82/submit", JSON.stringify(myJSON), function(data) { |
---|
383 | $('#posted').show(); | | $('#posted').show(); |
---|
384 | }); | | }); |
---|
| | 382 | if(myJSON.length < 1){ | | | 383 | return;} |
---|
| | 384 | for(var i in myJSON){ |
---|
| | 385 | jString = JSON.stringify(myJSON[i]).replace(/\{/g, '').replace(/\}[,]*/g, '').replace(/\[/g, '').replace(/\][,]/g, ''). |
---|
| | 386 | replace(/\"/g, ''); |
---|
| | 387 | myJSON[i].text = ' annotated '+window.location.href+"#[top="+myJSON[i].top+",bottom="+myJSON[i].bottom+",left="+myJSON[i].left+",right="+myJSON[i].right+"] as "+myJSON[i].name+" "+jString+" #swtr"; //The string which gets posted as a tweet. |
---|
| | 388 | myJSON[i].text = encodeURIComponent(myJSON[i].text); |
---|
| | 389 | myJSON[i].user = user; // User need not know the modification to the JSON. |
---|
| | 390 | myJSON[i].title = 'Annotation for '+window.location.href; |
---|
| | 391 | } |
---|
| | 392 | $.post(config.indexer+'/submit', JSON.stringify(myJSON),function(){ |
---|
| | 393 | $.post(config.postTweetUrl, {"data":JSON.stringify(myJSON)}, function(data) { |
---|
| | 394 | $('#posted').show(); |
---|
| | 395 | myJSON = []; |
---|
| | 396 | }); |
---|
| | 397 | }); |
---|
| | 398 | } |
---|
| | 399 | var config = { |
---|
| | 400 | 'postTweetUrl':'http://127.0.0.1:5000/add', |
---|
| | 401 | 'indexer':'http://192.168.100.56:82' |
---|
385 | } | 402 | } |
---|