-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patholpcmap.py
More file actions
6038 lines (5908 loc) · 312 KB
/
olpcmap.py
File metadata and controls
6038 lines (5908 loc) · 312 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import cgi,logging,random
#from google.appengine.ext import webapp
#from google.appengine.ext.webapp.util import run_wsgi_app
#from google.appengine.ext import db
from google.appengine.api import memcache,users,mail
from google.appengine.api.urlfetch import fetch,GET,POST
from datetime import datetime
from geomodel import GeoModel
import geotypes
class OpenMap(webapp.RequestHandler):
def get(self):
self.response.out.write('''<!DOCTYPE html>
<html>
<head id="head">
<title>olpcMAP.net in OpenLayers</title>
<script type="text/javascript" src="http://openlayers.org/api/OpenLayers.js"></script>
<link rel='stylesheet' type='text/css' href='http://mapmeld.appspot.com/mapmeldStyles.css'/>
<script type='text/javascript'>
var map,countries,people,orgs,infoWindow,geocoder,myPoints,specialRegion,isEditor,lastSText,approxd,dragFeature,newMrkrs,popup,style_blue,mapMrks;
function init(){
joinNetwork=true;
var proj_4326=new OpenLayers.Projection('EPSG:4326');
var proj_900913=new OpenLayers.Projection('EPSG:900913');
map = new OpenLayers.Map({
div: "map",
allOverlays: true,
units: "mi",
projection: proj_900913,
'displayProjection': proj_4326
});
var osm = new OpenLayers.Layer.OSM();
map.addLayers([osm]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.setCenter(new OpenLayers.LonLat(-20,30).transform(map.displayProjection, map.projection),3);
orgs=[
{name:"Moving Windmills",website:"http://williamkamkwamba.typepad.com",
pts:[
{name:"William Kamkwamba's Primary School",details:"1 XO,brought by William from TED in Arusha after telling the world about his homemade windmill. Inspiring story. <a href='http://williamkamkwamba.typepad.com/williamkamkwamba/2008/03/bringing-an-olp.html' target='_blank'>William's OLPC blog post</a>",pt:[-12.9829,33.6831],photo:"http://williamkamkwamba.typepad.com/williamkamkwamba/images/2008/03/21/img_0005.jpg"}
]},
{name:"OLPC Canada",website:"http://www.olpccanada.com",
ajax:[
{name:"OLPC Canada",pt:[55.786613,-98.885193],query:"/json?country=Canada",icon:"http://lib.store.yahoo.net/lib/yhst-91918294864082/canada-flag.gif"}
],
pts:[]},
{name:"OLPC Australia",website:"http://www.olpc.org.au",video:"http://youtube.com/watch?v=68p4kmKilyI",
ajax:[{name:"Sydney Center",pt:[-26.4312,121.6406],query:"/json?country=Australia"}],
pts:[]},
{name:"DBF OLPC India",website:"http://www.digitalbridgefoundation.org/",
pts:[
{name:"St. Anthony School,Dugawar,UP",details:"<a href='http://wiki.laptop.org/go/Oeuvre_des_pains' target='_blank'>School wiki page</a>",pt:[28.7168,78.5552],photo:"http://wiki.laptop.org/images/3/3c/OeuvreDesPains-Belgium-P1030833.JPG"},
{name:"Auroville,TN",details:"<a href='http://wiki.laptop.org/go/OLPC_India/Auroville' target='_blank'>School wiki page</a>",pt:[12.0093,79.8102],photo:"http://wiki.laptop.org/images/4/44/The_Joy_of_Exploration.JPG"},
{name:"Khairat School",pt:[18.917492,73.299408],details:"OLPC India's first pilot site<br/><br/><a href='http://wiki.laptop.org/go/OLPC_India/Khairat_school' target='_blank'>School wiki page</a>",photo:"http://wiki.laptop.org/images/b/b8/P1060290.JPG"},
{name:"Kikarwali",details:"India Foundation for Children Education and Care<br/><br/><a href='http://picasaweb.google.com/darshan2008/OLPCDeploymentProjectAtKikarwaliRajasthanIndiaOnMarch242010' target='_blank'>School Deployment Photos</a>",pt:[28.423199,75.60751],photo:"http://lh5.ggpht.com/_TKLjoqnmIB8/S6tmt8NyDhI/AAAAAAAAArA/6rZbCfBKDLQ/s512/DSC_0320.jpg"},
{name:"Parikrma Center for Learning,Bangalore",details:"30 XO laptops were deployed at this center,run by the <a href='http://www.parikrmafoundation.org' target='_blank'>Parikrma Foundation</a><br/><br/><a href='http://wiki.laptop.org/go/OLPC_India/DBF/Bangalore.Parikrma' target='_blank'>School-specific wiki page</a>",pt:[12.942348,77.585542],photo:"http://wiki.laptop.org/images/7/7b/Olpc-bangalore8.JPG"},
{name:"Aradhna School, Bangalore",details:"<a href='http://wiki.laptop.org/go/OLPC_India/DBF/Bangalore.Parikrma' target='_blank'>School wiki page</a>",pt:[12.885608,77.591865],photo:"http://wiki.laptop.org/images/6/66/Olpc-bangalore7.JPG"},
{name:"Holy Mother School,Nashik",details:"<a href='http://wiki.laptop.org/go/OLPC_India/Nashik' target='_blank'>School wiki page</a>",pt:[20.00574,73.748186],photo:"http://wiki.laptop.org/images/9/9e/P1010444.jpg"},
{name:"Mandal Parishad Primary School",details:"<a href='http://wiki.laptop.org/go/OLPC_India/DBF/Hyderabad-Mandal_Parishad_Primary_School' target='_blank'>School wiki page</a>",pt:[17.445319,78.38625],photo:"http://wiki.laptop.org/images/d/d5/DSC09954.JPG"},
{name:"Our Lady of Merces High School",details:"wiki page under development",pt:[15.277893,73.924255]}
]},
{name:"OLPC Mongolia",website:"http://www.laptop.gov.mn",
pts:[
{name:"Alag-Erdene soum",details:"one of three schools in Khovsgol district",pt:[50.1167,100.045]},
{name:"Khatgal soum",details:"one of three schools in Khovsgol district",pt:[50.4425,100.1603],photo:"http://farm4.static.flickr.com/3233/2915260637_f5f0375063.jpg",details:"Photo CC-BY Elana Langer"},
{name:"21 Ulanbaatar Schools",pt:[47.920484,106.925125],photo:"http://upload.wikimedia.org/wikipedia/commons/3/37/OLPC_Class_-_Mongolia_Ulaanbaatar.JPG"},
{name:"Khankh soum",details:"one of three schools in Khovsgol district",pt:[51.5023,100.6674]}
]},
{name:"OLPC Asia",website:"http://www.olpc.asia/index.html",
pts:[
{name:"Dujiangyan School,Sichuan",pt:[30.998285,103.619785],photo:"http://farm5.static.flickr.com/4138/4900464912_786490fed5_z.jpg",details:"Photo CC-BY OLPC"}
]},
{name:"Digital Literacy Project",website:"http://www.digiliteracy.org",
pts:[
{name:"Cambridge Friends School",details:"This XO pilot program is one of the first in the Boston area. CFS is an independent K-8 Quaker school. The XO is being introduced into the existing curriculum.",pt:[42.387,-71.1311],photo:"http://seeta.in/wiki/images/1/1e/DigiLit_at_CFS.JPG"},
{name:"Mission Hill School",details:"This pilot program is DigiLit's first collaboration with the Boston Public School System. The program is designed to help this charter school's 4th and 5th grades grow to a 1:1 laptop ratio",pt:[42.3306,-71.0993],photo:"http://seeta.in/wiki/images/3/3d/DigiLit_at_Mission_Hill.jpg"},
{name:"Nicaragua Project",details:"In January 2010,DigiLit worked with the IADB to set up an XO laptop library at the Nicaraguan Deaf Association in Managua. We are exploring how to close the education technology gap for these students.",pt:[12.1452,-86.2806],photo:"http://seeta.in/wiki/images/0/0d/DigiLit_in_Nicaragua_1.jpg"}
]},
{name:"Waveplace",website:"http://waveplace.org",
pts:[
{name:"Buenos Aires,Nicaragua",
details:"Our first pilot in Spanish,Waveplace worked with Campo Alegria to teach at arural elementary school without electricity. The government of Nicaragua was so impressed,they asked us to train 300 teachers throughout the country.<br/><a href='http://waveplace.org/locations/nicaragua' target='_blank'>Link</a>",
pt:[11.455799,-85.759277],
photo:"http://waveplace.com/mu/waveplace/item/tp166.jpg"},
{name:"St. John,US Virgin Islands",
details:"Waveplace started our journey at Guy H. Benjamin Elementary School in Coral Bay with twenty fourth graders who received the world's first 20 production XOs from OLPC. The pilot was a true learning experience for all.<br/><a href='http://waveplace.org/locations/usvi' target='_blank'>Link</a>",
pt:[18.360798,-64.74402],
photo:"http://waveplace.com/mu/waveplace/item/tp16.jpg"},
{name:"St. Vincent Pilot",
details:"<a href='http://waveplace.com/mu/waveplace/item/tp53' target='_blank'>Link</a> - please help us add details",
pt:[13.235935,-61.180115],
photo:"http://waveplace.com/mu/waveplace/item/tp51.jpg"},
{name:"Port-au-Prince,Haiti",
details:"Our first pilot in Haiti,taught in French,Waveplace trained teachers and orphans at Mercy & Sharing Foundation's John Branchizio School in Port-au-Prince. It was here we first felt our mission have a clear effect.<br/><a href='http://waveplace.com/mu/locations/haiti' target='_blank'>Link</a>",
pt:[18.693001,-72.353511],
photo:"http://waveplace.com/mu/waveplace/item/tp81.jpg"},
{name:"Petite Rivere de Nippes,Haiti",
details:"Partnering with the American Haitian Foundation,Waveplace trained four local mentors and three from the island of Lagonav. Petite Rivere remains our longest active pilot location in Haiti,with laptop classes continuing to this day.<br/><a href='http://waveplace.com/mu/locations/haiti' target='_blank'>Link</a>",
pt:[18.473992,-73.23349],
photo:"http://waveplace.com/mu/waveplace/item/tp2.jpg"},
{name:"Cambridge",
details:"<a href='http://waveplace.com/news/blog/archive/000850.jsp' target='_blank'>Link</a> - please help us add details",
pt:[42.371988,-71.086693],
photo:"http://waveplace.com/images/xoPrep.jpg"}
]},
{name:"OLPC Papua New Guinea",website:"http://www.olpc.org.pg/",video:"http://www.youtube.com/watch?v=woS3wDpoMiU",
pts:[
{name:"North Wahgi",pt:[-5.684658,144.49665],details:"250 XO laptops funded by PNGSDP",photo:"http://www.olpc.org.pg/images/stories/jim_taylor_primary1.jpg"},
{name:"Gaire",pt:[-9.676569,147.417297],details:"53 XO laptops,saturated 3rd grade class",photo:"http://wiki.laptop.org/images/d/d3/PNG-Nov08-2.jpg"},
{name:"Dreikikir",pt:[-3.57516,142.76946],details:"Dreikikir Admin Primary School is located in East Sepik Province,near Wewak. This school is participating in the EU-funded Improvement of Rural Primary Education Facilities (IRPEF) project,based in Madang. The IRPEF is collaborating with the Department of Education and OLPC Oceania to implement the trial."}
]},
{name:"OLPC Alabama",website:"http://wiki.laptop.org/go/OLPC Birmingham",video:"http://youtube.com/watch?v=inxOg-dt6rw",
pts:[
{name:"Birmingham",pt:[33.5271,-86.8229],details:"15000 XOs deployed? <a href='http://blog.laptop.org/2010/05/21/updates-from-alabama'>Latest update</a>",photo:"http://blog.laptop.org/wp-content/uploads/2010/05/westend-camp.jpg"}
]},
{name:"OLPC South Carolina",website:"http://www.laptopsc.org",video:"http://youtube.com/watch?v=y3VLAUtv9Rw",
ajax:[
{name:"South Carolina",pt:[33.767732,-80.507812],query:"/json?state=SouthCarolina"}
],
pts:[
]},
{name:"Gureghian Family",
pts:[
{name:"Chester Community Charter School",pt:[39.847031,-75.357971],details:"Deployment of 1400 laptops for students grades 3-8<br/><br/><a href='http://webcache.googleusercontent.com/search?q=cache:0yNNTyovLIcJ:wiki.laptop.org/images/9/9a/CCCS_12.10.08_Final.doc+olpc+chester&cd=1&hl=en&ct=clnk&gl=us' target='_blank'>Project Page</a>"}
]},
{name:"Amagezi Gemaanyi Youth Association",website:"http://amagezigemaanyi.blogspot.com",
pts:[
{name:"Lubya Youth Education Centre",details:"Community center in Kampala; received XO laptops through Contributors Program project by USC",pt:[0.3289,32.5527],photo:"http://1.bp.blogspot.com/_3doFkXas3vs/TEy34ipYQbI/AAAAAAAABkU/XlMIvb3KrxA/S390/agya-olpc4.jpg"}
]},
{name:"SEETA",website:"http://wiki.sugarlabs.org/go/Sugar_on_a_Stick_in_Delhi_India",
pts:[
{name:"Veda Vyasa DAV School",details:"Sugar on a Stick deployment in Delhi,India<br/>Our goal is to measure student learning improvements - students have a digital portfolio of their work and achievements. We will be publishing a case study in fall 2010 with a professor in Boston University's School of Education<br/><a href='http://theteamgoestoindia.wordpress.com' target='_blank'>Blog</a>",pt:[28.6384,77.0617]}
]},
{name:"OLE Nepal",website:"http://www.olenepal.org",video:"",
pts:[],
ajax:[{name:"OLE Nepal",pt:[27.3728,85.1897],query:"/json?country=Nepal"}]},
{name:"TecnoTzotzil",website:"http://sites.google.com/tecnotzotzil",
pts:[
{name:"4 San Cristobal De Las Casas Schools",details:"SoaS deployment with 44 students,using Intel Classmate PCs. Photo CC-BY Jose I. Icaza",pt:[16.7404,-92.6307],photo:"http://farm3.static.flickr.com/2600/3979066854_e9fdf5c530.jpg"}
]},
{name:"Educa Libre",website:"http://educalibre.cl",
pts:[
{name:"Florence Nightingale School",details:"SoaS deployment with 25 K-3 students in Macul,Chile. Acer netbooks and some PCs",pt:[-33.4871,-70.6048],photo:"http://educalibre.cl/wp-content/uploads/2010/07/alumno_piloto_memorice3.jpg"}
]},
{name:"United Action for Children",website:"http://www.unitedactionforchildren.org/",
pts:[
{name:"UPenn OLPCorps",details:"Students and teachers trained to use Scratch,Write,and more<br/><br/><a href='http://upennuac.blogspot.com/' target='_blank'>Blog</a>",pt:[4.061536,9.448242],photo:"http://1.bp.blogspot.com/_iSJqZVkttQc/SpM7e6-Qh_I/AAAAAAAAACc/YLR726R5GP0/s320/5848_237169645060_875880060_8375546_6766219_n%5B1%5D.jpg"}
]},
{name:"Ethiopia Engineering Capacity Building",website:"http://www.ecbp.biz/",
pts:[
{name:"OLPCorps:Dalarna U. and Royal IT",details:"<br/><br/><a href='http://wiki.laptop.org/go/OLPCorps_DKTH_ETHIO_PROPOSAL' target='_blank'>Wiki Page</a>",photo:"",pt:[7.939556,39.122314]}
]},
{name:"OLPCorps",
pts:[
{name:"OLPCorps:Harvard and MIT",pt:[-24.20689,16.167669]}
]},
{name:"GMin",website:"http://www.gmin.org/",
pts:[
{name:"OLPCorps Sahn Malen",details:"Princeton University and University of Maryland students<br/><br/><a href='http://olpcsm.blogspot.com/' target='_blank'>Wiki Page</a>",photo:"http://3.bp.blogspot.com/_I7lfwYcs8Jo/Sn871AI5K6I/AAAAAAAABpc/gzJ2XA-bed8/s400/DSC02252.JPG",pt:[8.063479,-11.42252]}
]},
{name:"ONE",website:"http://www.one.org",video:"http://www.youtube.com/watch?v=lPUXj7EqGWw",
pts:[
{name:"OLPCorps Senegal",details:"Students from U. Miami and U. Minnesota teamed up for this deployment<br/><br/><a href='http://www.one.org/blog/?p=7703' target='_blank'>Report from ONE.org</a><br/><br/><a href='http://africaxo.blogspot.com/' target='_blank'>Blog</a>",photo:"http://farm4.static.flickr.com/3500/3833004781_f0533a4c32.jpg",pt:[14.26638,-16.34697]}
]},
{name:"Intenge Development Foundation",website:"http://olpcorpsnamibiangoma.wordpress.com/idf-ngo-community-based-organization-in-caprivi/",
pts:[
{name:"OLPCorps Namibia-Ngoma",details:"<br/><br/><a href='http://olpcorpsnamibiangoma.wordpress.com/' target='_blank'>Blog</a>",pt:[-20.131298,19.510431]}
]},
{name:"One Here One There",website:"http://onehereonethere.org",
pts:[
{name:"OLPCorps IU",details:"Students from Indiana University. Installed an electric generator and ran a short student newspaper-writing project.<br/><br/><a href='http://2009iuohot.blogspot.com/' target='_blank'>Blog</a>",pt:[-24.153019,29.351349]}
]},
{name:"OLPCorps",
pts:[
{name:"OLPCorps:Niger",details:"University of Lagos,Royal Holloway University of London,and University of Salford students",pt:[8.762429,5.799923]},
{name:"OLPCorps:Sierrа Leone",details:"Tulane University and UC Davis students",pt:[8.760054,-12.572136]},
{name:"OLPCorps:U of Education,Winneba",pt:[6.14128,-1.670179]},
{name:"OLPCorps:U. Kinhasa",pt:[-1.710866,28.959188]},
{name:"OLPCorps:U of Ibadan",details:"This project is targeted at empowering people with disabilities by improving their access to technology.<br/><br/><a href='http://abledisableinxo.blogspot.com' target='_blank'>Blog</a>",photo:"http://4.bp.blogspot.com/_HbCc4VF-oTw/Splp_fs_JvI/AAAAAAAAADs/xI-fu0xLxWw/s320/teaching.jpg",pt:[9.277909,10.195785]},
{name:"OLPCorps:CUNY Baruch",pt:[8.407168,0.087891]},
{name:"OLPCorps:Soweto",details:"Deployment with detailed updates for the Global Post<br/><br/><a href='http://oplokhii.blogspot.com' target='_blank'>Blog</a>",pt:[-26.194877,27.993164],photo:"http://3.bp.blogspot.com/_jBm2wqTTQu8/SpX-ytitHwI/AAAAAAAAAQ4/PnIoAZ7bGME/s320/IMG_9629.JPG"},
{name:"OLPCorps:Mauritaniа",details:"Students from Cornell University",pt:[14.349548,-16.918945]},
{name:"OLPCorps:Ungana Foundation",details:"Students from Utah State University supported the Ungana Foundation's effort to extend and support OLPC Rwanda<br/><br/><a href='http://unganafoundation.blogspot.com/'>Blog</a>",photo:"http://1.bp.blogspot.com/_EkMPu5bJnVU/Sqav0piu-cI/AAAAAAAAAPI/C3ZKbTbPpFA/s400/P1010406.JPG",pt:[-1.83406,29.486618]},
{name:"OLPCorps:Heritage Nigeriа",details:"Students from Texas A&M University<br/><br/><a href='http://olpcheritagenigeria.blogspot.com/' target='_blank'>Blog</a>",pt:[6.509768,3.537598],photo:"http://2.bp.blogspot.com/_ytQa4_LpsOk/SnfG0uka1-I/AAAAAAAAAFk/A5D3QoWvDkQ/s320/IMG_1478.JPG"},
{name:"OLPCorps:Zimbаbwe",details:"Students from Macalester College,Midlands State University,and University of Zimbabwe - installed solar and then national grid power<br/><br/><a href='http://olpcorpszimbabwe09.blogspot.com' target='_blank'>Blog</a>",pt:[-17.137838,31.072083]},
{name:"OLPCorps:Madagascаr",details:"Students from GWU and U Maryland<br/><br/><a href='http://ampitso.wordpress.com/' target='_blank'>Blog</a>",photo:"http://ampitso.smugmug.com/photos/638764729_UCofq-M.jpg",pt:[-13.57024,49.306641]},
{name:"OLPCorps:Laval University",details:"<br/><br/><a href='http://collabo.fse.ulaval.ca/olpc/' target='_blank'>Website</a>",photo:"http://collabo.fse.ulaval.ca/olpc/images/teach.jpg",pt:[3.387307,12.877007]},
{name:"OLPCorps:Tanzaniа",details:"Students from Tumaini University.<br/><br/>The school was connected to the internet<br/><br/><a href='http://mot-tumaini.blogspot.com/' target='_blank'>Blog</a>",photo:"http://4.bp.blogspot.com/_z6OVkOJNvTQ/SpvI0dyRxGI/AAAAAAAAAO4/ukhEnWkZXEg/s320/IMG0011A.jpg",pt:[-7.794677,35.690117]},
{name:"OLPCorps:Vutakakа",details:"Students from U. Washington and the New School<br/><br/><a href='http://vutakakaolpc.blogspot.com/' target='_blank'>Blog</a>",photo:"http://4.bp.blogspot.com/_C_wadBS6-ek/SmX5aiSypyI/AAAAAAAAIzg/XKbSjGgYCoo/s320/100_0057.jpg",pt:[-3.513421,39.835739]},
{name:"OLPCorps:Kampalа",details:"Still operating (though not online). Supported by MIT and Wellesley College<br/><br/><a href='http://uganda-olpc.blogspot.com/' target='_blank'>Blog</a>",photo:"http://2.bp.blogspot.com/_Sm-Wjgh0ZWk/SlCq2EOvw2I/AAAAAAAAABU/Xm_8bmDF7tY/s320/olpc_kps_10.JPG",pt:[0.29663,32.640381]},
{name:"OLPCorps:GTech",details:"Students from Grahamstown and Gettysburg <a href='http://picasaweb.google.com/aimeegeorge/PicsFromGTECHSouthAfrica?feat=email#' target='_blank'>Photos Page</a><br/><br/><a href='http://gtech-olpc.blogspot.com/' target='_blank'>Blog</a>",photo:"http://lh3.ggpht.com/_7PSu0kxiZPQ/SrrntMYgpLI/AAAAAAAABFY/41saWNP1JNw/s640/P1080072.JPG",pt:[-33.315037,26.548634]},
{name:"OLPCorps:Kwame Nkrumah U.",pt:[7.227441,-0.747414]}
]}
];
myPoints=[];''')
myResults = None
results = None
hiddenGeoResults = None
directGeo = 1
mapImgUrl = None
try:
if(self.request.get('llcenter') != ''):
directGeo = 0
ctr_lat = self.request.get('llcenter').replace('%20','').split(',')[0]
ctr_lng = self.request.get('llcenter').replace('&20','').split(',')[1]
radius = float(self.request.get('km-distance'))
# MongoDB
results = db.GeoRefUsermadeMapPoint.find({ 'loc': { 'geoNear' : [float(ctr_lat),float(ctr_lng)], '$maxDistance': 1000 * radius } } ).limit(100)
if(self.request.get('map') == ''):
self.response.out.write(' var specialRegion=new google.maps.Circle({center:new google.maps.LatLng('+ cgi.escape(ctr_lat) +',' + cgi.escape(ctr_lng) + '),radius:'+str(1000*radius)+'});\n map.fitBounds(specialRegion.getBounds());\n')
elif(self.request.get('map') == 'image'):
mapImgUrl = "http://maps.google.com/maps/api/staticmap?sensor=false&maptype=terrain¢er=" + ctr_lat + "," + ctr_lng
# MongoDB
hiddenGeoResults = db.GeoRefMapPoint.find({ 'loc': { 'geoNear' : [float(ctr_lat),float(ctr_lng)], '$maxDistance': 1000 * radius } } ).limit(100)
elif((self.request.get('map') == 'quick') or (self.request.get('map') == 'fast')):
self.response.out.write('center=['+ ctr_lat + "," + ctr_lng + '];\nrad="'+str(radius)+'";\n')
elif(self.request.get('llregion') != ''):
directGeo = 0
ne_lat = self.request.get('llregion').replace('%20','').split(',')[0]
ne_lng = self.request.get('llregion').replace('%20','').split(',')[1]
sw_lat = self.request.get('llregion').replace('%20','').split(',')[2]
sw_lng = self.request.get('llregion').replace('%20','').split(',')[3]
# MongoDB - LL and UR
results = db.GeoRefUsermadeMapPoint.find({ 'loc': { '$within' : { [[float(sw_lat), float(sw_lng)], [float(ne_lat), float(ne_lng)]] } } } ).limit(100)
if(self.request.get('map') == ''):
self.response.out.write(' var specialRegion=new google.maps.Rectangle({bounds:new google.maps.LatLngBounds(new google.maps.LatLng('+ cgi.escape(sw_lat) +',' + cgi.escape(sw_lng) + '),new google.maps.LatLng(' + cgi.escape(ne_lat) +',' + cgi.escape(ne_lng) + '))});\n map.fitBounds(specialRegion.getBounds());\n')
elif(self.request.get('map') == 'image'):
mapImgUrl = "http://maps.google.com/maps/api/staticmap?sensor=false&maptype=terrain&visible=" + ne_lat + "," + ne_lng + "|" + sw_lat + "," + sw_lng
# MongoDB
hiddenGeoResults = db.GeoRefMapPoint.find({ 'loc': { '$within' : { [[float(sw_lat), float(sw_lng)], [float(ne_lat), float(ne_lng)]] } } } ).limit(100)
elif((self.request.get('map') == 'quick') or (self.request.get('map') == 'fast')):
self.response.out.write('center=['+ str((float(ne_lat)+float(sw_lat))/2) + "," + str((float(ne_lng)+float(sw_lng))/2) + '];box="' + ne_lat +"," + ne_lng + "," + sw_lat + "," + sw_lng + '";\n')
elif(self.request.get('llregions') != ''):
# &llregions=llregion1|llregion2
directGeo = 0
llregions = self.request.get('llregions').split('|')
minlat=90
minlng=180
maxlat=-90
maxlng=-180
for llregion in llregions:
llregion=llregion.replace('%20','').split(',')
ne_lat=float(llregion[0])
if(ne_lat<minlat):
minlat=ne_lat
if(ne_lat>maxlat):
maxlat=ne_lat
ne_lng=float(llregion[1])
if(ne_lng<minlng):
minlng=ne_lng
if(ne_lng>maxlng):
maxlng=ne_lng
sw_lat=float(llregion[2])
if(sw_lat<minlat):
minlat=sw_lat
if(sw_lat>maxlat):
maxlat=sw_lat
sw_lng=float(llregion[3])
if(sw_lng<minlng):
minlng=sw_lng
if(sw_lng>maxlng):
maxlng=sw_lng
if(results is None):
# MongoDB
results = db.GeoRefUsermadeMapPoint.find({ 'loc': { '$within' : { [[sw_lat, sw_lng], [ne_lat, ne_lng]] } } } ).limit(100)
else:
# MongoDB
results=results+db.GeoRefUsermadeMapPoint.find({ 'loc': { '$within' : { [[sw_lat, sw_lng], [ne_lat, ne_lng]] } } } ).limit(100)
if(self.request.get('map')=='image'):
if(hiddenGeoResults is None):
# MongoDB
hiddenGeoResults = db.GeoRefMapPoint.find({ 'loc': { '$within' : { [[float(sw_lat), float(sw_lng)], [float(ne_lat), float(ne_lng)]] } } } ).limit(100)
else:
# MongoDB
hiddenGeoResults = hiddenGeoResults + db.GeoRefMapPoint.find({ 'loc': { '$within' : { [[float(sw_lat), float(sw_lng)], [float(ne_lat), float(ne_lng)]] } } } ).limit(100)
if(self.request.get('map') == ''):
self.response.out.write(' var specialRegion=new google.maps.Rectangle({bounds:new google.maps.LatLngBounds(new google.maps.LatLng('+ str(minlat) +',' + str(minlng) + '),new google.maps.LatLng(' + str(maxlat) +',' + str(maxlng) + '))});\n map.fitBounds(specialRegion.getBounds());\n')
elif(self.request.get('map') == 'image'):
mapImgUrl = "http://maps.google.com/maps/api/staticmap?sensor=false&maptype=terrain&visible=" + str(maxlat) + "," + str(maxlng) + "|" + str(minlat) + "," + str(minlng)
elif((self.request.get('map') == 'quick') or (self.request.get('map') == 'fast')):
self.response.out.write('center=['+ str((ne_lat+sw_lat)/2) + "," + str((ne_lng+sw_lng)/2) + '];box="' + str(maxlat) +"," + str(maxlng) + "," + str(minlat) + "," + str(minlng) + '";\n')
elif(self.request.get('center') != ''):
directGeo = 0
ctr_lat = None
ctr_lng = None
suggestCtr = memcache.get("center:" + cgi.escape(self.request.get('center')))
if(suggestCtr is not None):
# center was in memcache
ctr_lat = suggestCtr.split(",")[0]
ctr_lng = suggestCtr.split(",")[1]
else:
llcenter = fetch("http://where.yahooapis.com/geocode?appid=M0hEoK7i&flags=CJ&q=" + self.request.get('center'), payload=None, method=GET, headers={}, allow_truncated=False, follow_redirects=True).content
ctr_lat = llcenter[llcenter.find('latitude')+11:len(llcenter)]
ctr_lat = ctr_lat[0:ctr_lat.find('"')]
ctr_lng = llcenter[llcenter.find('longitude')+12:len(llcenter)]
ctr_lng = ctr_lng[0:ctr_lng.find('"')]
memcache.add("center:" + cgi.escape(self.request.get('center')),ctr_lat + "," + ctr_lng,500000)
radius = float(self.request.get('km-distance'))
# MongoDB
results = db.GeoRefUsermadeMapPoint.find({ 'loc': { 'geoNear' : [float(ctr_lat),float(ctr_lng)], '$maxDistance': 1000 * radius } } ).limit(100)
if(self.request.get('map') == ''):
self.response.out.write(' var specialRegion=new google.maps.Circle({center:new google.maps.LatLng('+ cgi.escape(ctr_lat) +',' + cgi.escape(ctr_lng) + '),radius:'+str(1000*radius)+'});\n map.fitBounds(specialRegion.getBounds());\n')
elif(self.request.get('map') == 'image'):
mapImgUrl = "http://maps.google.com/maps/api/staticmap?sensor=false&maptype=terrain¢er=" + ctr_lat + "," + ctr_lng
# MongoDB
hiddenGeoResults = db.GeoRefMapPoint.find({ 'loc': { 'geoNear' : [float(ctr_lat),float(ctr_lng)], '$maxDistance': 1000 * radius } } ).limit(100)
elif((self.request.get('map') == 'quick') or (self.request.get('map') == 'fast')):
self.response.out.write('center=['+ ctr_lat + "," + ctr_lng + '];\nrad="'+str(radius)+'";')
elif(self.request.get('region') != ''):
directGeo = 0
ne_lat=None
ne_lng=None
sw_lat=None
sw_lng=None
suggestRgn = memcache.get("region:" + cgi.escape(self.request.get('region')))
if(suggestRgn is not None):
# center was in memcache
suggestRgn=suggestRgn.split(",")
ne_lat = suggestRgn[0]
ne_lng = suggestRgn[1]
sw_lat = suggestRgn[2]
sw_lng = suggestRgn[3]
else:
llregion = fetch("http://where.yahooapis.com/geocode?appid=M0hEoK7i&flags=CJX&q=" + self.request.get('region'), payload=None, method=GET, headers={}, allow_truncated=False, follow_redirects=True).content
ne_lat = llregion[llregion.find('north')+8:len(llregion)]
ne_lat = ne_lat[0:ne_lat.find('"')]
ne_lng = llregion[llregion.find('east')+7:len(llregion)]
ne_lng = ne_lng[0:ne_lng.find('"')]
sw_lat = llregion[llregion.find('south')+8:len(llregion)]
sw_lat = sw_lat[0:sw_lat.find('"')]
sw_lng = llregion[llregion.find('west')+7:len(llregion)]
sw_lng = sw_lng[0:sw_lng.find('"')]
memcache.add("region:" + cgi.escape(self.request.get('region')),ne_lat + "," + ne_lng + "," + sw_lat + "," + sw_lng,500000)
# need MongoDB
results = GeoRefUsermadeMapPoint.bounding_box_fetch(
GeoRefUsermadeMapPoint.all(),
geotypes.Box(float(ne_lat),float(ne_lng),float(sw_lat),float(sw_lng)),
max_results=100
)
if(self.request.get('map') == ''):
self.response.out.write(' var specialRegion=new google.maps.Rectangle({bounds:new google.maps.LatLngBounds(new google.maps.LatLng('+ cgi.escape(sw_lat) +',' + cgi.escape(sw_lng) + '),new google.maps.LatLng(' + cgi.escape(ne_lat) +',' + cgi.escape(ne_lng) + '))});\n map.fitBounds(specialRegion.getBounds());\n')
elif(self.request.get('map') == 'image'):
mapImgUrl = "http://maps.google.com/maps/api/staticmap?sensor=false&maptype=terrain&visible=" + ne_lat + "," + ne_lng + "|" + sw_lat + "," + sw_lng
# need MongoDB
hiddenGeoResults = GeoRefMapPoint.bounding_box_fetch(
GeoRefMapPoint.all(),
geotypes.Box(float(ne_lat),float(ne_lng),float(sw_lat),float(sw_lng)),
max_results=100
)
elif((self.request.get('map') == 'quick') or (self.request.get('map') == 'fast')):
self.response.out.write('center=['+ str((float(ne_lat)+float(sw_lat))/2) + "," + str((float(ne_lng)+float(sw_lng))/2) + '];\nbox="'+ne_lat+","+ne_lng+","+sw_lat+","+sw_lng+'"\n')
elif(self.request.get('go') != ''):
directGeo = 0
ne_lat=None
ne_lng=None
sw_lat=None
sw_lng=None
suggestRgn = memcache.get("region:" + cgi.escape(self.request.get('go')))
if(suggestRgn is not None):
# center was in memcache
suggestRgn=suggestRgn.split(",")
ne_lat = suggestRgn[0]
ne_lng = suggestRgn[1]
sw_lat = suggestRgn[2]
sw_lng = suggestRgn[3]
else:
llregion = fetch("http://where.yahooapis.com/geocode?appid=M0hEoK7i&flags=CJX&q=" + self.request.get('go'), payload=None, method=GET, headers={}, allow_truncated=False, follow_redirects=True).content
ne_lat = llregion[llregion.find('north')+8:len(llregion)]
ne_lat = ne_lat[0:ne_lat.find('"')]
ne_lng = llregion[llregion.find('east')+7:len(llregion)]
ne_lng = ne_lng[0:ne_lng.find('"')]
sw_lat = llregion[llregion.find('south')+8:len(llregion)]
sw_lat = sw_lat[0:sw_lat.find('"')]
sw_lng = llregion[llregion.find('west')+7:len(llregion)]
sw_lng = sw_lng[0:sw_lng.find('"')]
memcache.add("region:" + cgi.escape(self.request.get('go')),ne_lat + "," + ne_lng + "," + sw_lat + "," + sw_lng,500000)
# need MongoDB
results = GeoRefUsermadeMapPoint.bounding_box_fetch(
GeoRefUsermadeMapPoint.all(),
geotypes.Box(float(ne_lat),float(ne_lng),float(sw_lat),float(sw_lng)),
max_results=100
)
if(self.request.get('map') == ''):
self.response.out.write(' var specialRegion=new google.maps.Rectangle({bounds:new google.maps.LatLngBounds(new google.maps.LatLng('+ cgi.escape(sw_lat) +',' + cgi.escape(sw_lng) + '),new google.maps.LatLng(' + cgi.escape(ne_lat) +',' + cgi.escape(ne_lng) + '))});\n map.fitBounds(specialRegion.getBounds());\n')
elif(self.request.get('map') == 'image'):
mapImgUrl = "http://maps.google.com/maps/api/staticmap?sensor=false&maptype=terrain&visible=" + ne_lat + "," + ne_lng + "|" + sw_lat + "," + sw_lng
# need MongoDB
hiddenGeoResults = GeoRefMapPoint.bounding_box_fetch(
GeoRefMapPoint.all(),
geotypes.Box(float(ne_lat),float(ne_lng),float(sw_lat),float(sw_lng)),
max_results=100
)
elif((self.request.get('map') == 'quick') or (self.request.get('map') == 'fast')):
self.response.out.write('center=['+ str((float(ne_lat)+float(sw_lat))/2) + "," + str((float(ne_lng)+float(sw_lng))/2) + '];\nbox="'+ne_lat+","+ne_lng+","+sw_lat+","+sw_lng+'"\n')
elif((self.request.get('km-distance') != '') and (self.request.get('id') != '')):
directGeo = 0
# MongoDB
ctrPoint = db.GeoRefUsermadeMapPoint.find_one({'id': long(self.request.get('id'))})
radius = float(self.request.get('km-distance'))
# MongoDB
results = db.GeoRefUsermadeMapPoint.find({ 'loc': { 'geoNear' : [float(ctrPoint.location.lat),float(ctrPoint.location.lon)], '$maxDistance': 1000 * radius } } ).limit(100)
if(self.request.get('map') == ''):
self.response.out.write(' var specialRegion=new google.maps.Circle({center:new google.maps.LatLng('+ str(ctrPoint.location.lat) +',' + str(ctrPoint.location.lon) + '), radius:'+str(1000*radius)+'});\n map.fitBounds(specialRegion.getBounds());\n')
elif(self.request.get('map') == 'image'):
mapImgUrl = "http://maps.google.com/maps/api/staticmap?sensor=false&maptype=terrain¢er=" + str(ctrPoint.location.lat) +',' + str(ctrPoint.location.lon)
# need MongoDB
hiddenGeoResults = GeoRefMapPoint.proximity_fetch(
GeoRefMapPoint.all(),
geotypes.Point(float(ctrPoint.location.lat),float(ctrPoint.location.lon)),
max_results=100,
max_distance=1000 * radius
)
elif((self.request.get('map') == 'quick') or (self.request.get('map') == 'fast') ):
self.response.out.write('center=['+ str(ctrPoint.location.lat) + "," + str(ctrPoint.location.lon) + '];\nrad="' + str(radius) + '";')
except:
directGeo = 1
if(directGeo == 1):
oldPoints = memcache.get('oldPoints')
if(oldPoints is None):
oldr = Oldest()
oldPoints = oldr.snap()
newPoints = memcache.get('newPoints')
if(newPoints is None):
newr = Newest()
newPoints = newr.snap()
myResults = oldPoints + newPoints
if myResults is not None:
self.response.out.write(myResults)
# MongoDB
mapPoints = db.GeoRefUsermadeMapPoint.find().sort({"lastUpdate":1})
# MongoDB
results = mapPoints.fetch(30)
resultOut = u''
for pt in results:
resultOut = resultOut + u'pS({name:"'
usename = cgi.escape(pt.name)
if(usename.find("privatized") != -1):
fixname = usename.replace("privatized:","")
sndNames = 0
outname = ""
for letter in fixname:
if(sndNames == 0):
outname = outname + letter
elif(sndNames == -1):
outname = outname + letter
sndNames = 1
if(letter == " "):
sndNames = -1
outname = outname + " "
usename = outname
resultOut = resultOut + cgi.escape(usename).replace('"','\\"') + u'",id:"' + str(pt.key().id()) + u'",pt:[' + str(pt.location.lat) + "," + str(pt.location.lon) + u'],icon:"' + cgi.escape(pt.icon or "").replace('"','\\"') + u'",details:"'
resultOut = resultOut + cgi.escape(pt.details or "").replace('"','\\"').replace("<","<").replace(">",">").replace('\\n','<br/>').replace('\\r','<br/>').replace('\n','<br/>').replace('\r','<br/>') + '"'
if(pt.tabs is not None):
resultOut = resultOut + u',tabs:["' + '","'.join(pt.tabs) + '"]'
resultOut = resultOut + u',photo:"' + cgi.escape(pt.photo or "").replace('"','\\"') + u'",album:"' + cgi.escape(pt.album or "").replace('"','\\"') + u'",group:"' + cgi.escape(pt.group or "").replace('"','\\"').replace("<a","<a").replace("</a","</a").replace(">",">") + u'",icon:"' + cgi.escape(pt.icon or "") + u'"});\n'
self.response.out.write(resultOut)
else:
mapPoints = None
#mapPoints = GeoRefUsermadeMapPoint.gql("ORDER BY lastUpdate DESC")
if(results is None):
# MongoDB
mapPoints = db.GeoRefUsermadeMapPoint.find()
if mapPoints is not None:
# MongoDB
results = mapPoints.limit(200)
self.response.out.write(''' //point styles
var layer_style = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);
layer_style.fillOpacity = 0.2;
layer_style.graphicOpacity = 1;
//icon style
style_blue = OpenLayers.Util.extend({}, layer_style);
style_blue.strokeColor = "blue";
style_blue.fillColor = "blue";
style_blue.graphicName = "square";
style_blue.pointRadius = 12;
style_blue.strokeWidth = 0;
style_blue.rotation = 0;
style_blue.externalGraphic ="http://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=location|FF0000";
mapMrks=new OpenLayers.Layer.Vector("Markers", {style: layer_style});
newMrkrs = new OpenLayers.Layer.Vector("New Markers", {style: layer_style});
map.addLayer(newMrkrs);
dragFeature = new OpenLayers.Control.DragFeature(newMrkrs,{'onComplete': onCompleteMove} )
for(var myPt=0;myPt<myPoints.length;myPt++){
var point,pointFeature;
if(myPoints[myPt].icon.toLowerCase().indexOf("default") != -1){
myPoints[myPt].icon="";
}
if(myPoints[myPt].icon.length > 6){
point = new OpenLayers.Geometry.Point(myPoints[myPt].pt[1],myPoints[myPt].pt[0]).transform(map.displayProjection, map.projection);
var myStyle = OpenLayers.Util.extend({}, style_blue);
myStyle.externalGraphic=myPoints[myPt].icon;
pointFeature=new OpenLayers.Feature.Vector(point,null,myStyle);
pointFeature.attributes={title:myPoints[myPt].name,description:setupContent(myPt)};
mapMrks.addFeatures([pointFeature]);
}
else{
point = new OpenLayers.Geometry.Point(myPoints[myPt].pt[1],myPoints[myPt].pt[0]).transform(map.displayProjection, map.projection);
var myStyle = OpenLayers.Util.extend({}, style_blue);
myStyle.externalGraphic=randIcon();
pointFeature=new OpenLayers.Feature.Vector(point,null,myStyle);
pointFeature.attributes={title:myPoints[myPt].name,description:setupContent(myPt)};
mapMrks.addFeatures([pointFeature]);
}
myPoints[myPt].marker=pointFeature;
if(!myPoints[myPt].group){myPoints[myPt].group="";}
}
for(var mOrg=0;mOrg<orgs.length;mOrg++){
if(orgs[mOrg].ajax){
for(var mAj=0;mAj<orgs[mOrg].ajax.length;mAj++){
if(specialRegion){
if(orgs[mOrg].ajax[mAj].pt[0] > specialRegion.getBounds().getNorthEast().lat()){continue;}
if(orgs[mOrg].ajax[mAj].pt[0] < specialRegion.getBounds().getSouthWest().lat()){continue;}
if(orgs[mOrg].ajax[mAj].pt[1] > specialRegion.getBounds().getNorthEast().lng()){continue;}
if(orgs[mOrg].ajax[mAj].pt[1] < specialRegion.getBounds().getSouthWest().lng()){continue;}
}
var point = new OpenLayers.Geometry.Point(orgs[mOrg].ajax[mAj].pt[1],orgs[mOrg].ajax[mAj].pt[0]).transform(map.displayProjection, map.projection);
pointFeature = new OpenLayers.Feature.Vector(point,null,style_blue);
pointFeature.attributes={title:orgs[mOrg].ajax[mAj].name,description:"Click for Clusters",query:orgs[mOrg].ajax[mAj].query};
mapMrks.addFeatures([pointFeature]);
//icon:"http://mapmeld.appspot.com/cluster-icon.jpg"
}
}
if(orgs[mOrg].pts){
if(orgs[mOrg].pts.length>0){
for(var mPt=0;mPt<orgs[mOrg].pts.length;mPt++){
if(specialRegion){
if(orgs[mOrg].pts[mPt].pt[0] > specialRegion.getBounds().getNorthEast().lat()){continue;}
if(orgs[mOrg].pts[mPt].pt[0] < specialRegion.getBounds().getSouthWest().lat()){continue;}
if(orgs[mOrg].pts[mPt].pt[1] > specialRegion.getBounds().getNorthEast().lng()){continue;}
if(orgs[mOrg].pts[mPt].pt[1] < specialRegion.getBounds().getSouthWest().lng()){continue;}
}
orgs[mOrg].pts[mPt].id = "mOrg:" + mOrg + ":mPt:" + mPt;
orgs[mOrg].pts[mPt].group = orgs[mOrg].name;
var suggested=pU(orgs[mOrg].pts[mPt]);
if(suggested){
var point = new OpenLayers.Geometry.Point(orgs[mOrg].pts[mPt].pt[1],orgs[mOrg].pts[mPt].pt[0]).transform(map.displayProjection, map.projection);
var myStyle = OpenLayers.Util.extend({}, style_blue);
myStyle.externalGraphic=randIcon();
pointFeature = new OpenLayers.Feature.Vector(point,null,myStyle);
pointFeature.attributes={title:orgs[mOrg].pts[mPt].name,description:setupContent(myPoints.length-1)};
mapMrks.addFeatures([pointFeature]);
myPoints[myPoints.length-1].marker=pointFeature;
}
}
}
}
}
map.addLayer(mapMrks);
selectControl = new OpenLayers.Control.SelectFeature(mapMrks);
map.addControl(selectControl);
selectControl.activate();
mapMrks.events.on({
'featureselected': onFeatureSelect,
'featureunselected': onFeatureUnselect
});
if(gup("id")){
var ptID=gup("id");
for(var mPt=0;mPt<myPoints.length;mPt++){
if(myPoints[mPt].id==ptID){
if(!specialRegion){
map.setCenter(myPoints[mPt].marker.geometry.getBounds().getCenterLonLat(),12);
}
infoWindow.setContent(setupContent(mPt));
infoWindow.open(map,myPoints[mPt].marker);
break;
}
}
}
if(gup("q")){
searchAccept("geoq "+gup("q"));
}
}
function onPopupClose(evt) {
try{
selectControl.unselect(this.feature);
}catch(e){}
isEditor=false;
ekey=null;
}
function onFeatureSelect(evt) {
if(popup){map.removePopup(popup)}
var feature=evt.feature;
if(feature.attributes.query){
var jsonScript=document.createElement("script")
jsonScript.src="http://mapmeld.appspot.com/olpcMAP" + feature.attributes.query + "&format=ol-js";
$("head").appendChild(jsonScript);
mapMrks.removeFeatures([feature]);
return;
}
var center=feature.geometry.getBounds().getCenterLonLat();
lastOpen=feature;
var manyMarkers=getNearbyMarkers(center);
if(manyMarkers.length > 1){
var pageViewer;
pageViewer="<div style='min-width:280px;'><div style='margin-left:auto;margin-right:auto;'><br/>";
var tablesOn=false;
if(manyMarkers.length > 10){
tablesOn=true;
pageViewer+="<table><tr><td>";
}
pageViewer+="<ul>";
for(var mPt=0;mPt<manyMarkers.length;mPt++){
if((tablesOn)&&(mPt%10==0)&&(mPt!=0)){
if(mPt > 30){break;}
pageViewer+='</ul></td><td><ul>';
}
pageViewer+='<li><a href="#" onclick="searchAccept('+"'myPoint "+manyMarkers[mPt].id+"'"+')">'+manyMarkers[mPt].name+'</a></li>';
}
pageViewer+="</ul>";
if(tablesOn){
pageViewer+="</td></tr></table>";
}
pageViewer+="</div></div>";
popup = new OpenLayers.Popup.FramedCloud("featurePopup",
center,
new OpenLayers.Size(400,300),
"<h3>Many at this location: <a href='#' onclick='map.setCenter(new OpenLayers.LonLat(" + center.lon + ","+ center.lat + "),"+(map.getZoom()+2)+");'>Zoom</a></h3>" +
pageViewer,
null, true, onPopupClose);
}
else{
popup = new OpenLayers.Popup.FramedCloud("featurePopup",
center,
new OpenLayers.Size(400,300),
feature.attributes.description,
null, true, onPopupClose);
}
feature.popup = popup;
popup.feature = feature;
map.addPopup(popup);
}
function onFeatureUnselect(evt) {
feature = evt.feature;
if (feature.popup) {
popup.feature = null;
map.removePopup(feature.popup);
feature.popup.destroy();
feature.popup = null;
}
}
function p(pointData){
myPoints.push(pointData);
}
function randIcon(){
var randIcon;
var randIconI=Math.floor(Math.random()*18);
switch(randIconI){
case 0:
randIcon="http://google-maps-icons.googlecode.com/files/computer.png";
break;
case 1:
randIcon="http://google-maps-icons.googlecode.com/files/world.png";
break;
case 2:
randIcon="http://google-maps-icons.googlecode.com/files/industrialmuseum.png";
break;
case 3:
randIcon="http://google-maps-icons.googlecode.com/files/music-classical.png";
break;
case 4:
randIcon="http://google-maps-icons.googlecode.com/files/postal.png";
break;
case 5:
randIcon="http://google-maps-icons.googlecode.com/files/housesolarpanel.png";
break;
case 6:
randIcon="http://google-maps-icons.googlecode.com/files/park.png";
break;
case 7:
randIcon="http://google-maps-icons.googlecode.com/files/laboratory.png";
break;
case 8:
randIcon="http://google-maps-icons.googlecode.com/files/university.png";
break;
case 9:
randIcon="http://google-maps-icons.googlecode.com/files/daycare.png";
break;
case 10:
randIcon="http://google-maps-icons.googlecode.com/files/school.png";
break;
case 11:
randIcon="http://google-maps-icons.googlecode.com/files/bookstore.png";
break;
case 12:
randIcon="http://google-maps-icons.googlecode.com/files/workoffice.png";
break;
case 13:
randIcon="http://google-maps-icons.googlecode.com/files/photo.png";
break;
case 14:
randIcon="http://google-maps-icons.googlecode.com/files/bigcity.png";
break;
case 15:
randIcon="http://google-maps-icons.googlecode.com/files/places-unvisited.png";
break;
case 16:
randIcon="http://google-maps-icons.googlecode.com/files/amphitheater-tourism.png";
break;
case 17:
randIcon="http://google-maps-icons.googlecode.com/files/flowers.png";
break;
}
return randIcon;
}
function onCompleteMove(feature){}
function writeSearchCat(category,resultsList){
if(resultsList.length==0){return ""}
var searchCat='<div class="searchCat">' + category + '</div><ul class="searchList">';
for(var sR=0;sR<resultsList.length;sR++){
var provenName=resultsList[sR].name;
while(provenName.indexOf("<")!=-1){
provenName=provenName.replace("<","<");
}
if(resultsList[sR].href){
if(resultsList[sR].sharer){
searchCat+='<li><span onclick="searchAccept('+"'"+resultsList[sR].acceptance+"'"+')">' + provenName + ' <a href="' + resultsList[sR].href + '" target="_blank">(Link)</a></span>';
searchCat+='<br/><small><i>shared by <a href="#" onclick="searchAccept(' + "'" + 'byName ' + resultsList[sR].sharer + "');" + '">' + resultsList[sR].sharer + '</a></i></small>';
}
else{
searchCat+='<li onclick="searchAccept('+"'"+resultsList[sR].acceptance+"'"+')">' + provenName + ' <a href="' + resultsList[sR].href + '" target="_blank">(Link)</a>';
}
searchCat+='</li>';
}
else{
searchCat+='<li onclick="searchAccept('+"'"+resultsList[sR].acceptance+"'"+')">' + provenName + '</li>';
}
}
searchCat+="</ul>"
return searchCat;
}
function searchAccept(term){
if(term.indexOf("viewport")==0){
term=term.replace("viewport ","").split(",");
map.zoomToExtent(new OpenLayers.Bounds(term[3],term[2],term[1],term[0]).transform(map.displayProjection,map.projection));
}
else if(term.indexOf("byName")==0){
$("searchbox").value=term.replace("byName ","");
searchSearchBox();
}
else if(term.indexOf("latlng")==0){
term=term.replace("latlng","").replace(" ","").split(",");
map.setCenter(new OpenLayers.LonLat(term[1],term[0]),12);
map.setZoom(12);
}
else if(term.indexOf("myPoint")==0){
var ptID=term.replace("myPoint","").replace(" ","");
for(var mPt=0;mPt<myPoints.length;mPt++){
if(myPoints[mPt].id==ptID){
if(!specialRegion){
map.setCenter(myPoints[mPt].marker.geometry.getBounds().getCenterLonLat(),12);
}
var feature=myPoints[mPt].marker;
if(popup){map.removePopup(popup)}
popup = new OpenLayers.Popup.FramedCloud("featurePopup",
feature.geometry.getBounds().getCenterLonLat(),
new OpenLayers.Size(100,100),
feature.attributes.description,
null, true, onPopupClose);
feature.popup = popup;
popup.feature = feature;
map.addPopup(popup);
break;
}
}
}
else if(term.indexOf("geoq") != -1){
term = term.replace("geoq ","").replace("geoq","");
/*geocoder.geocode({'address':term},
function(results,status){
if(status==google.maps.GeocoderStatus.OK){
if(results[0].geometry.viewport){
map.fitBounds(results[0].geometry.viewport);
}
else{
map.setCenter(results[0].geometry.location,12);
map.setZoom(12);
}
}
}
);*/
}
else if(term.indexOf("mOrg")==0){
term=term.replace("mOrg ","");
uniqueGroup=orgs[term];
if(uniqueGroup.pts.length == 1){
map.setCenter(new OpenLayers.LonLat(uniqueGroup.pts[0].pt[1],uniqueGroup.pts[0].pt[0]),16);
approxd="<span class='topResult'>→"+uniqueGroup.name+"</span>";
}
else if(uniqueGroup.pts.length == 0){
map.setCenter(new OpenLayers.LonLat(uniqueGroup.ajax[0].pt[1],uniqueGroup.ajax[0].pt[0]),16);
var qScript=document.createElement("script");
qScript.src="http://mapmeld.appspot.com/olpcMAP" + uniqueGroup.ajax[0].query + "&format=ol-js&act=center";
document.body.appendChild(qScript);
approxd="<span class='topResult'>Loading "+uniqueGroup.name+"</span>";
}
else{
var northMost=uniqueGroup.pts[0].pt[0];
var southMost=uniqueGroup.pts[0].pt[0];
var eastMost=uniqueGroup.pts[0].pt[1];
var westMost=uniqueGroup.pts[0].pt[1];
for(var grpPt=1;grpPt<uniqueGroup.pts.length;grpPt++){
if(uniqueGroup.pts[grpPt].pt[0] > northMost){
northMost=uniqueGroup.pts[grpPt].pt[0];
}
else if(uniqueGroup.pts[grpPt].pt[0] < southMost){
southMost=uniqueGroup.pts[grpPt].pt[0];
}
if(uniqueGroup.pts[grpPt].pt[1] > eastMost){
eastMost=uniqueGroup.pts[grpPt].pt[1];
}
else if(uniqueGroup.pts[grpPt].pt[1] < westMost){
westMost=uniqueGroup.pts[grpPt].pt[1];
}
}
map.zoomToExtent(new OpenLayers.Bounds(eastMost,northMost,westMost,southMost).transform(map.displayProjection,map.projection));
approxd="<span class='topResult'>→"+uniqueGroup.name+"</span>";
}
}
try{$("approxd").innerHTML="Choose a result"}catch(e){}
}
function gup(nm){nm=nm.replace(/[\[]/,"\[").replace(/[\]]/,"\]");var rxS="[\?&]"+nm+"=([^&#]*)";var rx=new RegExp(rxS);var rs=rx.exec(window.location.href);if(!rs){return null;}else{return rs[1];}}
function searchSearchBox(){
makeSearch($("searchbox").value);
}
function makeSearch(search){
approxd=null;
joinNetwork=true;
searchCats="";
$("searchResBox").style.display="block";
var uniqueGroup = null;
var matchItems = [];
for(var grp=0;grp<orgs.length;grp++){
if(orgs[grp].name.toLowerCase().indexOf(search.toLowerCase()) != -1){
if(uniqueGroup==null){
uniqueGroup = orgs[grp];
}
else{
uniqueGroup = -1;
}
matchItems.push({name:orgs[grp].name,acceptance:"mOrg " + grp});
}
else if(orgs[grp].details!=null){
if(orgs[grp].details.toLowerCase().indexOf(search.toLowerCase()) != -1){
if(uniqueGroup==null){
uniqueGroup = orgs[grp];
}
else{
uniqueGroup = -1;
}
matchItems.push({name:orgs[grp].name,acceptance:"mOrg " + grp});
}
}
}
if((uniqueGroup != null) && (approxd==null)){
if(uniqueGroup!=-1){
if(uniqueGroup.pts.length==1){
map.setCenter(new OpenLayers.LonLat(uniqueGroup.pts[0].pt[1],uniqueGroup.pts[0].pt[0]).transform(map.projection,map.displayProjection));
map.setZoom(16);
approxd="<span class='topResult'>→"+uniqueGroup.name+"</span>";
}
else if(uniqueGroup.pts.length == 0){
map.setCenter(new OpenLayers.LonLat(uniqueGroup.ajax[0].pt[1],uniqueGroup.ajax[0].pt[0]).transform(map.projection,map.displayProjection));
map.setZoom(16);
var qScript=document.createElement("script");
qScript.src="http://mapmeld.appspot.com/olpcMAP" + uniqueGroup.ajax[0].query + "&format=js&act=center";
document.body.appendChild(qScript);
approxd="<span class='topResult'>Loading "+uniqueGroup.name+"</span>";
}
else{
var northMost=uniqueGroup.pts[0].pt[0];
var southMost=uniqueGroup.pts[0].pt[0];
var eastMost=uniqueGroup.pts[0].pt[1];
var westMost=uniqueGroup.pts[0].pt[1];
for(var grpPt=1;grpPt<uniqueGroup.pts.length;grpPt++){
if(uniqueGroup.pts[grpPt].pt[0] > northMost){
northMost=uniqueGroup.pts[grpPt].pt[0];
}
else if(uniqueGroup.pts[grpPt].pt[0] < southMost){
southMost=uniqueGroup.pts[grpPt].pt[0];
}
if(uniqueGroup.pts[grpPt].pt[1] > eastMost){
eastMost=uniqueGroup.pts[grpPt].pt[1];
}
else if(uniqueGroup.pts[grpPt].pt[1] < westMost){
westMost=uniqueGroup.pts[grpPt].pt[1];
}
}
/*map.fitBounds(new google.maps.LatLngBounds(
new google.maps.LatLng(southMost,westMost),
new google.maps.LatLng(northMost,eastMost)
));*/
approxd="<span class='topResult'>→"+uniqueGroup.name+"</span>";
}
}
}
searchCats+=writeSearchCat('Groups',matchItems);
var uniquePoint = null;
matchItems=[];
var buried=""; // buried gives name precedence, even if term appears in two items' details or group names
for(var mPt=0;mPt<myPoints.length;mPt++){
if( myPoints[mPt].name.toLowerCase().indexOf(search.toLowerCase()) != -1){
if(uniquePoint==null){
uniquePoint = myPoints[mPt];
uniquePoint.found = "name";
}
else if((uniquePoint != -1)||(buried=="group")||(buried=="details")){
if((uniquePoint.found == "details")||(uniquePoint.found == "group")||(buried=="group")||(buried=="details")){
uniquePoint = myPoints[mPt];
uniquePoint.found="name";
buried="";
}
else{
uniquePoint=-1;
buried="name";
}
}
matchItems.push({name:myPoints[mPt].name,acceptance:"myPoint " + myPoints[mPt].id});
}
else if((myPoints[mPt].group!=null)&&(myPoints[mPt].group.toLowerCase().indexOf(search.toLowerCase()) != -1)){
if(uniquePoint==null){
uniquePoint = myPoints[mPt];
uniquePoint.found="group";
}
else if((uniquePoint != -1)||(buried=="details")){
if((uniquePoint.found == "details")||(buried=="details")){
uniquePoint = myPoints[mPt];
uniquePoint.found="group";
buried="";
}
else if(uniquePoint.found == "group"){
uniquePoint=-1;
buried="group";
}
}
matchItems.push({name:myPoints[mPt].name,acceptance:"myPoint " + myPoints[mPt].id});
}
else if(myPoints[mPt].details!=null){
if(myPoints[mPt].details.toLowerCase().indexOf(search.toLowerCase()) != -1){
if(uniquePoint==null){
uniquePoint = myPoints[mPt];
uniquePoint.found = "details";
}
else if(uniquePoint != -1){
if(uniquePoint.found == "details"){
uniquePoint = -1;
buried="details";
}
}
matchItems.push({name:myPoints[mPt].name,acceptance:"myPoint " + myPoints[mPt].id});
}
}
}
if((uniquePoint!=null)&&(approxd==null)){
if(uniquePoint != -1){
approxd="<span class='topResult'>→"+uniquePoint.name+"</span>";
if(specialRegion==null){
map.setCenter(uniquePoint.marker.lonlat);
map.setZoom(12);
}
for(var mPt=0;mPt<myPoints.length;mPt++){
if(myPoints[mPt].id==uniquePoint.id){
infoWindow.setContent(setupContent(mPt));
break;
}
}
infoWindow.open(map,uniquePoint.marker);
}
}
searchCats+=writeSearchCat('Points',matchItems);
geocoder.geocode( { 'address':search},
function(results,status) {
if (status == google.maps.GeocoderStatus.OK){
if((approxd==null)&&(results[0].geometry!=null)&&(results[0].geometry.viewport!=null)){
map.fitBounds(results[0].geometry.viewport);
$("approxd").innerHTML="<span class='topResult'>→" + results[0].address_components[0].long_name + " on Google Maps</span>";
}
var googResList=[];
for(var googRes=0;googRes<results.length&&googRes<5;googRes++){
var googName=""
for(var gN=0;gN<results[googRes].address_components.length;gN++){
if(gN!=0){googName+=", ";}
googName+=results[googRes].address_components[gN].short_name;