Commit 2a0eb0139368e05a4bd1a3e352a494a16c64c52c

  • avatar
  • arvind
  • Thu Jun 07 13:50:18 IST 2012
JSON pretty print
  • myVector.js 125 --------------------------------------------------------------------------------------------------------+++++++++++++++++++++
  • openlayers.html 2 -+
  • Diff rendering mode:
  • inline
  • side by side

myVector.js

18 check1: false,18 check1: false,
19 check2: false,19 check2: false,
20 trigger: function() {20 trigger: function() {
21 // if(handler.check == false)
22 // {
23 // handler.check = true;
24 // myjson = {"temple":[
25 // {"period": "16th century"},
26 // {"location":"13.80338 - 77.61067"},
27 // {"sthapati":"Shivakumar"},
28 // {"innerloc": "MaharangaMandapa"}
29 // ],
30 // "size": "311110px X 4668 px",
31 // "narrative": "Narrative",
32 // "muralTradition": "XYZ",
33 // "muralTechnique": "Foo",
34 // "muralContent": "Bar"
35 // };
36 // var x = document.getElementById("content");
37 // for (var i in myjson)
38 // {
39 // if(i == "temple")
40 // {
41 // for(var y =0; y <myjson[i].length;y++)
42 // {
43 // for(var z in myjson[i][y])
44 // {
45 // x.innerHTML += z+': '+'<i>'+myjson[i][y][z]+'</i>; ';
46 // }
47 // }
48 // }
49 // else{
50 // x.innerHTML += i+': '+'<i>'+myjson[i]+'</i>; ';
51 // }
52 // }
53 // }
54 // else{
55 // var x = document.getElementById("content");
56 // x.innerHTML ='';
57 // handler.check = false;
58 // }
59 onMyFeatureSelect(map);
21 myjson = {"temple":[
22 {"period": "16th century"},
23 {"location":"13.80338 - 77.61067"},
24 {"sthapati":"Shivakumar"},
25 {"innerloc": "MaharangaMandapa"}
26 ],
27 "size": "311110px X 4668 px",
28 "narrative": "Narrative",
29 "muralTradition": "XYZ",
30 "muralTechnique": "Foo",
31 "muralContent": "Bar"
32 };
33 onMyFeatureSelect(map,myjson,15555, -2334);
60 },34 },
61 trigger1: function() {35 trigger1: function() {
62 if(handler.check1 == false)
63 {
64 handler.check1 = true;
65 myjson = {"face":[36 myjson = {"face":[
66 {"character":"Shiva"}37 {"character":"Shiva"}
67 ],38 ],
68 "size": "310px X 460px" // jewellery:earring; material: silver,39 "size": "310px X 460px" // jewellery:earring; material: silver,
69 };40 };
70 var x = document.getElementById("content1");
71 for (var i in myjson)
72 {
73 if(i == "face")
74 {
75 for(var y =0; y <myjson[i].length;y++)
76 {
77 for(var z in myjson[i][y])
78 {
79 x.innerHTML += z+': '+'<i>'+myjson[i][y][z]+'</i>; ';
80 }
81 }
82 }
83 else{
84 x.innerHTML += i+': '+'<i>'+myjson[i]+'</i>; ';
85 }
86 }
87 }
88 else{
89 var x = document.getElementById("content1");
90 x.innerHTML ='';
91 handler.check1 = false;
92 }
41 onMyFeatureSelect(map,myjson,3915,- 1438);
93 },42 },
94 trigger2: function() {43 trigger2: function() {
95 if(handler.check2 == false)
96 {
97 handler.check2 = true;
98 myjson = {"ornament":[44 myjson = {"ornament":[
99 {"jewelery":"Pendant"},45 {"jewelery":"Pendant"},
100 {"Material":"Silver"}46 {"Material":"Silver"}
101 ],47 ],
102 "size": "50px X 90px" 48 "size": "50px X 90px"
103 };49 };
104 var x = document.getElementById("content2");
105 for (var i in myjson)
106 {
107 if(i == "ornament")
108 {
109 for(var y =0; y <myjson[i].length;y++)
110 {
111 for(var z in myjson[i][y])
112 {
113 x.innerHTML += z+': '+'<i>'+myjson[i][y][z]+'</i>; ';
114 }
115 }
116 }
117 else{
118 x.innerHTML += i+': '+'<i>'+myjson[i]+'</i>; ';
119 }
120 }
121 }
122 else{
123 var x = document.getElementById("content2");
124 x.innerHTML ='';
125 handler.check2 = false;
50 onMyFeatureSelect(map,myjson,3751,-1802)
126 }51 }
127 }
12852
129};53};
130function onFeatureSelect(feature)54function onFeatureSelect(feature)
62 z.panMapIfOutOfView = true;62 z.panMapIfOutOfView = true;
63 map.addPopup(z);63 map.addPopup(z);
64}64}
65function onMyFeatureSelect(feature)
65function onMyFeatureSelect(feature, json, x, y)
66{66{
67// str = "";
68// x = 1;
67 z = new OpenLayers.Popup.FramedCloud(69 z = new OpenLayers.Popup.FramedCloud(
68 "test",70 "test",
69 new OpenLayers.LonLat(15555, -2334), // Always should be at the center of the map, not the center of viewport.
71 new OpenLayers.LonLat(x, y), // Always should be at the center of the map, not the center of viewport.
70 new OpenLayers.Size(640,480),72 new OpenLayers.Size(640,480),
71 "<pre><b><center>Temple</center></b>\n"+
72 "period: 16th century\n"+
73 "location: 13.80338 - 77.61067\n"+
74 "sthapati: Shivakumar\n"+
75 "innerloc: MaharangaMandapa\n"+
76 "size: 311110px X 4668 px\n"+
77 "narrative: Narrative\n"+
78 "muralTradition: XYZ\n"+
79 "muralTechnique: Foo\n"+
80 "muralContent: Bar</pre>"
73 "<pre>"+JSON.stringify(json,null,'\t')+"</pre>"
81 ,null,true);74 ,null,true);
82 feature.popup = z;75 feature.popup = z;
83 z.panMapIfOutOfView = true;76 z.panMapIfOutOfView = true;
226 console.log(labelFeature.attributes['name']);226 console.log(labelFeature.attributes['name']);
227 if(labelFeature.attributes['name'])227 if(labelFeature.attributes['name'])
228 {228 {
229 console.log("here");
229 //console.log(myObj.feature.geometry.bounds.top); Use this to get the bounds.
230 map.addLayer(vectorLayer);230 map.addLayer(vectorLayer);
231 vectorLayer.drawFeature(labelFeature);231 vectorLayer.drawFeature(labelFeature);
232 vectorLayer.addFeatures([labelFeature]);232 vectorLayer.addFeatures([labelFeature]);

openlayers.html

15 <script type="text/javascript" src="myVector.js"></script>15 <script type="text/javascript" src="myVector.js"></script>
16 </head>16 </head>
17 <body onload="init()">17 <body onload="init()">
18 <div id="header"><h1>world.png</h1></div>
18 <div id="header"><h1>Lepakshi Mural</h1></div>
19 <div id="subheader">Generated by <a href="http://www.maptiler.org/">MapTiler</a>/<a href="http://www.klokan.cz/projects/gdal2tiles/">GDAL2Tiles</a>, Copyright &copy; 2008 <a href="http://www.klokan.cz/">Klokan Petr Pridal</a>, <a href="http://www.gdal.org/">GDAL</a> &amp; <a href="http://www.osgeo.org/">OSGeo</a> <a href="http://code.google.com/soc/">GSoC</a>19 <div id="subheader">Generated by <a href="http://www.maptiler.org/">MapTiler</a>/<a href="http://www.klokan.cz/projects/gdal2tiles/">GDAL2Tiles</a>, Copyright &copy; 2008 <a href="http://www.klokan.cz/">Klokan Petr Pridal</a>, <a href="http://www.gdal.org/">GDAL</a> &amp; <a href="http://www.osgeo.org/">OSGeo</a> <a href="http://code.google.com/soc/">GSoC</a>
20 <!-- PLEASE, LET THIS NOTE ABOUT AUTHOR AND PROJECT SOMEWHERE ON YOUR WEBSITE, OR AT LEAST IN THE COMMENT IN HTML. THANK YOU -->20 <!-- PLEASE, LET THIS NOTE ABOUT AUTHOR AND PROJECT SOMEWHERE ON YOUR WEBSITE, OR AT LEAST IN THE COMMENT IN HTML. THANK YOU -->
21 </div>21 </div>