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