-
Notifications
You must be signed in to change notification settings - Fork 0
/
CampusMap.html
executable file
·1350 lines (1056 loc) · 44.9 KB
/
CampusMap.html
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
<!DOCTYPE html>
<!---------------------------------------------------------------------------
This is the HSU Web Map. It contains:
- Raster tiled background
- Point layer for all the point data in the legend/menu
- Polyline layer for the polyline data (bus routes, accessible routes)
- Polygon layer for the buildings
The web page contains two "sliding" DIVs: the MenuBox and the InfoBox.
These are controlled by the MenuButtons and InfoButtons respectively.
----------------------------------------------------------------------------->
<html>
<!---------------------------------------------------------------------------
1. HTML Header
----------------------------------------------------------------------------->
<head>
<!---------------------------------------------------------------------------
1.1 Title and metadata tags
----------------------------------------------------------------------------->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Humboldt State University Map</title>
<!-- This is the icon for the Campus Map Tab -->
<link rel="shortcut icon" href="images/favicon.png" type="image/x-icon"/>
<!---------------------------------------------------------------------------
1.2 Style sheets
----------------------------------------------------------------------------->
<!--- Main styles for menu, footter, basically everything except the MenuBox and InfoBox --->
<link rel="stylesheet" type="text/css" href="css/Main.css"/>
<!-- Menu and Info Box styles -->
<link rel="stylesheet" type="text/css" href="css/SlideBoxes.css"/>
<!-- Styles for the map and its contents -->
<link rel="stylesheet" type="text/css" href="css/CanvasMap_HSU.css">
<!-----------------------------------------------------------------------------
1.3 JavaScript includes
----------------------------------------------------------------------------->
<script src="js/SearchUtil.js"></script> <!-- search utility -->
<script src='js/BuildingPhraseList.js'></script> <!--- building phrase list -->
<script src='Building_Images/buildinghtml.js'></script> <!--- HTML for info popups -->
<script src="CanvasMap/lib/jquery-2.1.0.js"></script>
<script src="CanvasMap/lib/hammer.js"></script>
<!--
<script src="CanvasMap/js/CanvasMap.js"></script>
-->
<script src="CanvasMap/js/CMBase.js"></script>
<script src="CanvasMap/js/CMItem.js"></script>
<script src="CanvasMap/js/CMItemRect.js"></script>
<script src="CanvasMap/js/CMDataset.js"></script>
<script src="CanvasMap/js/CMDatasetGeoJSON.js"></script>
<script src="CanvasMap/js/CMUtilities.js"></script>
<script src="CanvasMap/js/CMDialog.js"></script>
<script src="CanvasMap/js/CMView.js"></script>
<script src="CanvasMap/js/CMScene.js"></script>
<script src="CanvasMap/js/CMLayer.js"></script>
<script src="CanvasMap/js/CMLayerRaster.js"></script>
<script src="CanvasMap/js/CMLayerDataset.js"></script>
<script src="CanvasMap/js/CMDatasetPyramid.js"></script>
<script src="CanvasMap/js/CMTile.js"></script>
<script src="CanvasMap/js/CMUtilityBezier.js"></script>
<script src="CanvasMap/js/CMDialogSettings.js"></script>
<script src="CanvasMap/js/CMScaleBar.js"></script>
<script src="CanvasMap/js/CMProjector.js"></script>
<script src="CanvasMap/js/CMProjectorGoogleMaps.js"></script>
<script src="CanvasMap/js/CMProjectorUTM.js"></script>
<script src="CanvasMap/js/CMView2D.js"></script>
<script src="CanvasMap/js/CMPanelTool.js"></script>
<script src="CanvasMap/js/CMPanelTabs.js"></script>
<script src="CanvasMap/js/CMPanelFooter.js"></script>
<script src="CanvasMap/js/CMPanelLayerList.js"></script>
<script src="CanvasMap/js/CMPanelBackgrounds.js"></script>
<script src="CanvasMap/js/CMPanelSearch.js"></script>
<script src="CanvasMap/js/CMPanelAttributes.js"></script>
<script src="CanvasMap/js/CMViewItems.js"></script>
<script src="CanvasMap/js/CMItemPoly.js"></script>
<script src="CanvasMap/js/CMItemPolyArrow.js"></script>
<script src="CanvasMap/js/CMLayerItems.js"></script>
<script src="CanvasMap/js/CMPanelTime.js"></script>
<script src="CanvasMap/js/CMPanelSettings.js"></script>
<script src="CanvasMap/js/CMMainContainer.js"></script>
<script>
//****************************************************************
// 2. JavaScript code
//****************************************************************
//****************************************************************
// 2.1 Global variables
//****************************************************************
// paths for each of the data sets
var ThePointFilePath="Spatial_Data/Points_Dec_12.js";
//var ThePointFilePath="Spatial_Data/Points_Nov_13.js";
//var ThePolylineFilePath="Spatial_Data/Polylines_Nov29_2016.js";
var ThePolylineFilePath="Spatial_Data/Polylines_Dec11_2017.js";
var TheBuildingOverlayFilePath="Spatial_Data/BuildingOverlay_Dec_14.js";
// global for the canvas map object
var TheCanvasMap=null;
var TileFolderPath="Spatial_Data/Tiles300/";
var TileFolderPath150="Spatial_Data/Tiles150/";
var TileFolderPath75="Spatial_Data/Tiles75/";
var BuildingNamesFilePath="Spatial_Data/BuildingLabels_Dec20_2016.js";
var Layer_Buildings=null;
var Layer_Polylines=null;
var Layer_Points=null;
var Layer_BuildingsEAP=null;
// status flag for the info box to indicate when it is open and when it is closed
var InfoOpen=false;
var MenuOpen=false;
// these contain the entries for the accordian and the accordian can only be udpate
// once all the entries are recieved
var ReceivedPoints=false;
var ReceivedPolylines=false;
var Types=[];
var NumTypes=0;
var Subtypes=[]; // array indexed first by TypeIndex
var NumSubtypes=[];
var Entries=[]; // indexed by TypeIndex and then SubtypeIndex
var NumNamedEntries=[]; // indexed by TypeIndex and then SubtypeIndex
/**
* This is the text at the top of the accordion. Because the accordion is a single div (I tried making it two) we have to have
* this as a variable so we can put it together with the other data
*/
var CurrentHTML=" \
<h3 style='color: #f6f3af; margin-left: 35px; margin-right: 18px; margin-top: 35px; margin-bottom: 25px;'>SEARCH...</h3> \
<h5 style='color: white; margin-left: 35px; margin-right: 35px; margin-top: -20px;'>Search for services, buildings, departments, and/or event spaces by their abbreviation, partial or full name. Ex. KBR is Kate Buchanan Room</h5> \
<form id='searchbox' method='get' > \
<input id='SearchText' type='text' size='15' placeholder='TYPE HERE' onkeypress='EnterPressed()' /> <!-- onkeypress='classSearch()' --> \
<input id='SearchButton' type='button' value='SEARCH' onClick='DoSearch()'/> <!-- onclick='classSearch()' --> \
</form> \
<div id='SearchResultsContainer' class='SearchResultsContainer' style='margin-top: 24px; margin-bottom: 25px;' > </div> \
<div id='SearchResults' class='ResultStyles'></div> \
<div class='break3'> <hr /> </div> \
";
/*
<h3 style='color: #f6f3af; margin-left: 35px; margin-right: 18px; margin-top: 35px; margin-bottom: 25px;'>Search for Services and Buildings</h3> \
<h3 style='color: #f6f3af; margin-left: 35px; margin-right: 18px; margin-top: 35px; margin-bottom: 25px;'>FIND CLASSES / SPRING 2016</h3> \
<h5 style='color: white; margin-left: 35px; margin-right: 35px; margin-top: 20px;'> \
Search for class buildings by department abbreviation and class number. Ex: Geography 105 is GEOG 105 \
</h5> \
*/
//****************************************************************
// 2.2 Global Functions
//****************************************************************
/**
* Updates the contents of the accordion (within the MenuBox)
* This is called after the Points and Polylines are recieved and processed
*/
function UpdateAccordion()
{
if (ReceivedPoints&&ReceivedPolylines)
{
//****************************************************************
// Create the HTML for the accordion from the arrays
var TheHTML="";
for (var TypeIndex=0;TypeIndex<NumTypes;TypeIndex++)
{
var TypeName=Types[TypeIndex];
TheHTML+="<a class='accordion-title' href='#'>"+TypeName+
"<img class='arrowimage' src='images/arrow-01.png' alt='arrow'></a>";
TheHTML+="<div id='accordion' class='accordion-content'>";
var TheNumSubtypes=NumSubtypes[TypeIndex];
for (var SubtypeIndex=0;SubtypeIndex<TheNumSubtypes;SubtypeIndex++)
{
var SubtypeName=Subtypes[TypeIndex][SubtypeIndex];
if (SubtypeName==="AccessiblePath")
{
var test=12;
}
var TheNumNamedEntries=NumNamedEntries[TypeIndex][SubtypeIndex];
if (TheNumNamedEntries==0) // no named entries, just show one checkbox for all entries
{
// get the legend icon from the first entry
var LegendIconFilePath=Entries[TypeIndex][SubtypeIndex][0].LegendIconFilePath;
var LayerName=Entries[TypeIndex][SubtypeIndex][0].LayerName;
TheHTML+=
"\t\t<div class='CheckBoxHeight'>"
+"<input type='checkbox' name='"+SubtypeName+"' id='"+SubtypeName+"' "
+"onclick='EntryChanged(this,\""+LayerName+"\","+TypeIndex+","+SubtypeIndex+","+(-1)+")'>"
+"<span class='CheckboxText'>"+SubtypeName+"</span>";
if (LegendIconFilePath!="")
{
TheHTML+="<img class='CheckBoxImages' src='"+LegendIconFilePath+"' alt='"+SubtypeName+"'>"
+"</img>";
}
TheHTML+="</input>"
+"</div>";
}
else // have named entires, show each entry
{
var MenuSubtypeIconFilePath=Entries[TypeIndex][SubtypeIndex][0].MenuSubtypeIconFilePath;
TheHTML+="\t\t<div class='CheckBoxTitle'><strong>"+SubtypeName+"</strong>";
if (MenuSubtypeIconFilePath!="")
{
TheHTML+="<img class='CheckBoxImages' src='"+MenuSubtypeIconFilePath+"' alt='"+SubtypeName+"'></img>";
}
TheHTML+="</div>";
// add the entries below the subtype line
var NumEntries=Entries[TypeIndex][SubtypeIndex].length;
for (var EntryIndex=0;EntryIndex<NumEntries;EntryIndex++)
{
// get the legend icon
var LegendIconFilePath=Entries[TypeIndex][SubtypeIndex][EntryIndex].LegendIconFilePath;
var LayerName=Entries[TypeIndex][SubtypeIndex][EntryIndex].LayerName;
EntryName=Entries[TypeIndex][SubtypeIndex][EntryIndex].Name;
var EntryID="Entry_"+TypeIndex+"_"+SubtypeIndex+"_"+EntryIndex;
TheHTML+=
"<div class='CheckBoxHeight'>"
+"<input type='checkbox' name='"+EntryName+"' id='"+EntryID+"' "
+"onclick='EntryChanged(this,\""+LayerName+"\","+TypeIndex+","+SubtypeIndex+","+EntryIndex+")'>"
+"<span class='CheckboxText'>"+EntryName+"</span>";
if (LegendIconFilePath!="")
{
TheHTML+="<img class='CheckBoxImages' src='"+LegendIconFilePath+"' alt='"+EntryName+"'></img>";
}
TheHTML+="</input>"
+"</div>";
}
}
}
TheHTML+="</div>";
}
// set the HTML into the accordion
var AccordionELement=document.getElementById("AccordionContainer");
AccordionELement.innerHTML=CurrentHTML+TheHTML;
/**
* jQuery accordion control. This relies on style definitions
*/
jQuery(".accordion .accordion-content").slideUp();
jQuery(".accordion .accordion-title").click(function(){
jQuery(this).next(".accordion .accordion-content").slideToggle("fast");
});
}
}
//****************************************************************
// 2.3 OnLoad Function
//****************************************************************
function AddToEntries(LayerType,TheLayer,FeautureIndex,Name,Type,Subtype,LegendIconFilePath,MenuSubtypeIconFilePath)
{
// see if the type already exists
if (Subtype==="AccessiblePath")
{
var j=12;
}
var TypeIndex=Types.indexOf(Type);
var SubtypeIndex=0;
if (TypeIndex==-1) // add to the array
{
TypeIndex=NumTypes;
Types[NumTypes]=Type;
NumTypes+=1;
Subtypes[TypeIndex]=[];
NumSubtypes[TypeIndex]=0;
Entries[TypeIndex]=[];
NumNamedEntries[TypeIndex]=[];
}
var SubtypeIndex=Subtypes[TypeIndex].indexOf(Subtype);
if (SubtypeIndex==-1) // // have to allocate the array the first time
{
SubtypeIndex=NumSubtypes[TypeIndex];
Subtypes[TypeIndex].push(Subtype);
NumSubtypes[TypeIndex]+=1;
Entries[TypeIndex][SubtypeIndex]=[];
NumNamedEntries[TypeIndex][SubtypeIndex]=0;
}
Entries[TypeIndex][SubtypeIndex].push({
Name:Name,
FeatureIndex:FeautureIndex,
LegendIconFilePath:LegendIconFilePath,
MenuSubtypeIconFilePath:MenuSubtypeIconFilePath,
TheLayer:TheLayer,
LayerName:LayerType
});
if ((Name!="")&&(Name!==undefined)) NumNamedEntries[TypeIndex][SubtypeIndex]+=1;
}
/**
* Initialize the map for use.
* Called after the specified information has loaded.
*/
function OnLoad()
{
//***************************************************************************
// 2.3.1 Initialize the map and its main elements
//***************************************************************************
TheCanvasMap=new CMMainContainer(); // creates the CanvasMap object
// TheCanvasMap.SetHorizontalMargin(0);
// TheCanvasMap.SetMapBottomOffset(0);
// TheCanvasMap.SetMapRightOffset(0);
TheCanvasMap.SetImageFolder("CanvasMap/Images/");
TheCanvasMap.SimpleMap(); // turn off all the map elements except the canvas container
// initialize the map
TheCanvasMap.Initialize(); // sets up the view, scene, and event handlers for the map
TheCanvasMap.TheScene.IncrementRepaintBlocks();
TheCanvasMap.TheScene.SetSettingGroup("Fill",{
fillStyle:"rgba(255,255,255,0.5)"
});
//***************************************************************************
// 2.3.2 Setup the projector
//***************************************************************************
var TheProjector=new CMProjectorUTM();
TheProjector.SetDatum(CMProjector.WGS_84);
TheProjector.SetZone(10);
TheCanvasMap.SetProjector(TheProjector);
//***************************************************************************
// 2.3.3 Add layers to the map
//***************************************************************************
// get the container to add items to the map
var TheCanvasElement=TheCanvasMap.GetElement(CMMainContainer.CANVAS_CONTAINER);
//*****************************************************
// ADD FIRST SET OF BACKGROUND TILES (300 PPI)
var Layer_Campus=new CMLayerDataset();
TheCanvasMap.AddLayer(Layer_Campus);
Layer_Campus.SetURL(TileFolderPath,false,CMDataset.PYRAMID);
Layer_Campus.SetSetting("Layer","MinZoom",2);
Layer_Campus.SetSetting("Layer","MaxZoom",2);
Layer_Campus.SetName("Campus0");
Checked=""; // reset the checked flag so only the first layer is selected
//*****************************************************
// ADD FIRST SET OF BACKGROUND TILES (150 PPI)
var Layer_Campus2=new CMLayerDataset();
TheCanvasMap.AddLayer(Layer_Campus2);
Layer_Campus2.SetURL(TileFolderPath150,false,CMDataset.PYRAMID);
Layer_Campus2.SetSetting("Layer","MinZoom",1);
Layer_Campus2.SetSetting("Layer","MaxZoom",1);
Layer_Campus2.SetName("Campus2");
Checked=""; // reset the checked flag so only the first layer is selected
//*****************************************************
// ADD FIRST SET OF BACKGROUND TILES (75 PPI)
var Layer_Campus3=new CMLayerDataset();
TheCanvasMap.AddLayer(Layer_Campus3);
Layer_Campus3.SetURL(TileFolderPath75,false,CMDataset.PYRAMID);
Layer_Campus3.SetSetting("Layer","MinZoom",0);
Layer_Campus3.SetSetting("Layer","MaxZoom",0);
Layer_Campus3.SetName("Campus3");
Checked=""; // reset the checked flag so only the first layer is selected
//*****************************************************
// Add the forgound layers to the map
if (true)
{
// get the name and URL for the layerCMLayerGeoJSON
var URL=TheBuildingOverlayFilePath;
// create and add the layer
Layer_Buildings=new CMLayerDataset();
Layer_Buildings.SetName("Buildings");
Layer_Buildings.SetSettingAttribute("Layer","InfoText","HTML");
Layer_Buildings.SetSettingGroup("Style",{
fillStyle:"rgba(0,0,255,0.0)" ,
strokeStyle:"rgba(255,0,0,0.0)"
});
Layer_Buildings.SetSettingGroup("MouseOverStyle",{
fillStyle:"rgba(229,240,211,0.5)",
strokeStyle:"rgba(182,83,0,0.65)",
lineWidth:1
});
Layer_Buildings.SetSettingGroup("SelectedStyle",{
fillStyle:"rgba(229,240,211,0.65)",
//strokeStyle:"rgba(30,130,76,0.8)",
strokeStyle:"rgba(255,0,0,0.8)",
lineWidth:1
});
TheCanvasMap.AddLayer(Layer_Buildings);
Layer_Buildings.ShowInfoWindow=function(FeatureIndex,TheView,RefX,RefY)
{
var TheFeatures=this.TheData.features;
var TheFeature=TheFeatures[FeatureIndex];
var Properties=TheFeature.properties;
var TheHTML=this.GetFeatureProperty(CMLayer.INFO,FeatureIndex,null);
if (TheHTML!=null)
{
// var TheHTML=Properties[this.GetHTMLAttribute()];
var InfoWindow=TheView.CreateInfoWindow("CMLayerGeoJSON.InfoWindow",RefX,RefY,this.GetInfoWindowWidth(),30,TheHTML);
CMMainContainer.SetPopupWindow(InfoWindow);
}
};
Layer_Buildings.SetURL(URL,false);
}
//*****************************************************
// Add the forgound layers to the map
if (true)
{
// create and add the layer
Layer_BuildingsEAP=new CMLayerDataset();
Layer_BuildingsEAP.SetName("Buildings");
Layer_BuildingsEAP.SetSettingAttribute("Layer","InfoText","HTML");
Layer_BuildingsEAP.SetSettingGroup("Style",{
fillStyle:"rgba(0,0,255,0.0)" ,
strokeStyle:"rgba(0,0,255,0.0)"
});
// jjg - not sure what this is, was set to "Feature style"
Layer_BuildingsEAP.SetSettingGroup("Style",{fillStyle:"rgba(0,0,0,0)",strokeStyle:"rgba(0,0,0,0)",lineWidth:2});
TheCanvasMap.AddLayer(Layer_BuildingsEAP);
Layer_BuildingsEAP.SetURL(URL,false);
}
//*****************************************************
// Add the forgound layers to the map
if (true)
{
// get the name and URL for the layer
var URL=ThePolylineFilePath; //
// create and add the layer
Layer_Polylines=new CMLayerDataset();
Layer_Polylines.SetName("Polylines");
Layer_Polylines.SetSettingAttribute("Layer","InfoText","TYPE");
Layer_Polylines.MouseMove=function()
{
return(false);
}
Layer_Polylines.OnLoad=function()
{
var TheDataset=this.GetDataset();
var NumFeatures=TheDataset.GetNumAttributeRows();
var Types=[];
var NumTypes=0;
var Subtypes=[]; // array indexed first by TypeIndex
var NumSubtypes=[];
var Entries=[]; // indexed by TypeIndex and then SubtypeIndex
var NumNamedEntries=[]; // indexed by TypeIndex and then SubtypeIndex
for (var j=0;j<NumFeatures;j++)
{
var Name=TheDataset.GetAttributeCellByHeading("NAME",j);
var Type=TheDataset.GetAttributeCellByHeading("TYPE",j);
var Subtype=TheDataset.GetAttributeCellByHeading("SUBTYPE",j);
// setup the legend icon file path
var MapIconFileName=TheDataset.GetAttributeCellByHeading("ICON",j);
var MapIconFilePath="";
if (MapIconFileName!="") MapIconFilePath="images/"+MapIconFileName;
// set the icon for the point into the layer
this.SetFeatureSetting("IconImage","URL",j,MapIconFilePath);
// prevent all points from painting
this.SetFeatureSetting("Layer","MinZoom",j,1000);
this.SetFeatureSetting("Layer","MaxZoom",j,-1000);
// setup the style (this is temporary until it's in the file
var StrokeStyle=null;
if (Type==="TRANSPORTATION")
{
if (Subtype=="Red")
{
// StrokeStyle={strokeStyle:"rgba(255,0,0,1)",lineWidth:2};
this.SetFeatureSetting("Style","strokeStyle",j,"rgba(255,0,0,1)");
this.SetFeatureSetting("Style","lineWidth",j,2);
}
else if (Subtype=="Gold")
{
// StrokeStyle={strokeStyle:"rgba(218,165,32,1)",lineWidth:2};
this.SetFeatureSetting("Style","strokeStyle",j,"rgba(218,165,32,1)");
this.SetFeatureSetting("Style","lineWidth",j,2);
}
}
else // probably ADA accessible
{
// StrokeStyle={strokeStyle:"rgba(0,0,255,1)",lineWidth:2}; // blue
this.SetFeatureSetting("Style","strokeStyle",j,"rgba(0,0,255,1)");
this.SetFeatureSetting("Style","lineWidth",j,2);
}
/* if (StrokeStyle!=null)
{
this.SetFeatureSetting("Style","strokeStyle",j,StrokeStyle);
}
*/ // setup the icon for the menu
var MenuIconFileName=TheDataset.GetAttributeCellByHeading("MenuIcon",j);
if (MenuIconFileName==undefined) MenuIconFileName=MapIconFileName;
var MenuIconFilePath="";
if (MenuIconFileName!="") MenuIconFilePath="images/"+ MenuIconFileName;
AddToEntries("Polyline",this,j,Name,Type,Subtype,MenuIconFilePath);
}
ReceivedPolylines=true;
UpdateAccordion();
}
TheCanvasMap.AddLayer(Layer_Polylines);
Layer_Polylines.SetURL(URL,false);
}
//*****************************************************
// Add the forgound layers to the map
if (true)
{
// get the name and URL for the layer
var URL=ThePointFilePath;
// create and add the layer
Layer_Points=new CMLayerDataset();
Layer_Points.SetName("Points");
Layer_Points.SetSettingAttribute("Layer","InfoText","Name");
Layer_Points.SetSettingGroup("Style",{
fillStyle:"rgba(0,0,255,0.1)"
});
Layer_Points.MouseMove=function()
{
return(false);
}
Layer_Points.OnLoad=function()
{
var TheDataset=this.GetDataset();
var NumFeatures=TheDataset.GetNumAttributeRows();
for (var j=0;j<NumFeatures;j++)
{
var Name=TheDataset.GetAttributeCellByHeading("NAME",j);
var Type=TheDataset.GetAttributeCellByHeading("TYPE",j);
var Subtype=TheDataset.GetAttributeCellByHeading("SUBTYPE",j);
if (Subtype=="Faculty & Staff")
{
var thing="hi";
}
// setup the map icon file path
var MapIconFileName=TheDataset.GetAttributeCellByHeading("ICON",j);
if (MapIconFileName=="FS6.png")
{
var Test="hi";
}
var MapIconFilePath="";
if (MapIconFileName!="") MapIconFilePath="images/"+MapIconFileName;
// setup the icon for the menu
var MenuIconFileName=TheDataset.GetAttributeCellByHeading("MenuIcon",j);
var MenuIconFilePath="";
if (MenuIconFileName!="") MenuIconFilePath="images/"+ MenuIconFileName;
// setup the icon for the menu
var MenuSubtypeIconFileName=TheDataset.GetAttributeCellByHeading("MenuSubtypeIcon",j);
var MenuSubtypeIconFilePath="";
if (MenuSubtypeIconFileName!="") MenuSubtypeIconFilePath="images/"+ MenuSubtypeIconFileName;
// set the icon for the point into the layer
this.SetFeatureIconImage(j,MapIconFilePath,-9,-9);
// prevent all points from painting
this.SetFeatureSetting("Layer","MinZoom",j,1000);
this.SetFeatureSetting("Layer","MaxZoom",j,-1000);
AddToEntries("Points",this,j,Name,Type,Subtype,MenuIconFilePath,MenuSubtypeIconFilePath);
}
ReceivedPoints=true;
UpdateAccordion();
}
TheCanvasMap.AddLayer(Layer_Points);
Layer_Points.SetURL(URL,false);
}
//*****************************************************
// Add the forgound building name layers to the map
//*****************************************************
var URL=BuildingNamesFilePath;
if (true)
{
// get the name and URL for the layer
//*****************************************************
// Add a white halo for the labels for the top step
// create and add the layer
var Layer_BuildingLabels=new CMLayerDataset();
Layer_BuildingLabels.SetName("BuildingLabels");
// make the points invisible
Layer_BuildingLabels.SetSettingGroup("Style",{
fillStyle:"rgba(0,0,255,0.0)",
strokeStyle:"rgba(0,0,255,0.0)"
});
// write out the labels with a wide line to make a white halo
Layer_BuildingLabels.SetSettingAttribute("Text","Text","Name");
Layer_BuildingLabels.SetSettingGroup("Text",{
font:"bold 9px Lato",
fillStyle:"rgba(0,0,0,1)",
strokeStyle:"rgba(255,255,255,0.6)",
//lineWidth:1.5,
});
// make this layer only appear on the top step
Layer_BuildingLabels.SetSetting("Layer","MinZoom",0);
Layer_BuildingLabels.SetSetting("Layer","MaxZoom",0);
Layer_BuildingLabels.SetClickable(false);
Layer_BuildingLabels.MouseMove=function() { return(false); }
TheCanvasMap.AddLayer(Layer_BuildingLabels);
Layer_BuildingLabels.SetURL(URL,false);
}
//*****************************************************
// Add the labels for the top step
if (true)
{
// create and add the layer
var Layer_BuildingLabels=new CMLayerDataset();
Layer_BuildingLabels.SetName("BuildingLabels");
// make the points invisible
Layer_BuildingLabels.SetSettingGroup("Style",{
fillStyle:"rgba(0,0,255,0.0)",
strokeStyle:"rgba(0,0,255,0.0)"
});
// write out the labels in black above
Layer_BuildingLabels.SetSettingAttribute("Text","Text","Name");
Layer_BuildingLabels.SetSettingGroup("Text",{
font:"bold 9px Lato",
fillStyle:"rgba(0,0,0,1)",
//strokeStyle:"rgba(0,0,0,1)",
lineWidth:.2
});
// make this layer only appear on the top step
Layer_BuildingLabels.SetSetting("Layer","MinZoom",0);
Layer_BuildingLabels.SetSetting("Layer","MaxZoom",0);
Layer_BuildingLabels.SetClickable(false);
Layer_BuildingLabels.MouseMove=function() { return(false); }
TheCanvasMap.AddLayer(Layer_BuildingLabels);
Layer_BuildingLabels.SetURL(URL,false);
}
//*****************************************************
// Add the labels for when we are more zoomed in (steps 1 and 2)
if (true)
{
// create and add the layer
Layer_BuildingLabels=new CMLayerDataset();
Layer_BuildingLabels.SetName("BuildingLabels");
Layer_BuildingLabels.SetSettingAttribute("Layer","InfoText","Name");
// make the points invisible
Layer_BuildingLabels.SetSettingGroup("Style",{
fillStyle:"rgba(0,0,255,0.0)",
strokeStyle:"rgba(0,0,255,0.0)" ,
lineWidth:0.5
});
//
Layer_BuildingLabels.SetSettingAttribute("Text","Text","Labels_2");
Layer_BuildingLabels.SetSettingGroup("Text",{
font:"bold 11px Lato",
fillStyle:"rgba(255,255,255,1)",
strokeStyle:"rgba(255,255,255,0.6)",
lineWidth:1.5,
});
// make this layer only appear on the second and third steps
Layer_BuildingLabels.SetSetting("Layer","MinZoom",1);
Layer_BuildingLabels.SetSetting("Layer","MaxZoom",2);
Layer_BuildingLabels.SetClickable(false);
Layer_BuildingLabels.MouseMove=function() { return(false); }
TheCanvasMap.AddLayer(Layer_BuildingLabels);
Layer_BuildingLabels.SetURL(URL,false);
}
//*****************************************************
// Add the labels for when we are more zoomed in (steps 2 and 2)
if (true)
{
// create and add the layer
Layer_BuildingLabels=new CMLayerDataset();
Layer_BuildingLabels.SetName("BuildingLabels");
Layer_BuildingLabels.SetSettingAttribute("Layer","InfoText","Name");
Layer_BuildingLabels.SetSettingGroup("Style",{
fillStyle:"rgba(0,0,255,0.0)",
strokeStyle:"rgba(0,0,255,0.0)"
});
Layer_BuildingLabels.SetSettingAttribute("Text","Text","Labels_2");
Layer_BuildingLabels.SetSettingGroup("Text",{
font:"bold 11px Lato",
fillStyle:"rgba(0,0,0,1)",
strokeStyle:"rgba(0,0,0,1)",
lineWidth:0.5
});
Layer_BuildingLabels.SetSetting("Layer","MinZoom",1);
Layer_BuildingLabels.SetSetting("Layer","MaxZoom",2);
Layer_BuildingLabels.SetClickable(false);
Layer_BuildingLabels.MouseMove=function() { return(false); }
TheCanvasMap.AddLayer(Layer_BuildingLabels);
Layer_BuildingLabels.SetURL(URL,false);
}
//***************************************************************************
// 2.3.5 Start the map
//***************************************************************************
TheCanvasMap.StartMap(false);
//***************************************************************************
// 2.3.6 Position and size the map
//***************************************************************************
// add the resize function to the window
window.addEventListener("resize", function() {
TheCanvasMap.Resize();
ResizeElements();
});
// resize the elements to make them fit the window the first time
ResizeElements();
// call the resize function to setup the map for the first time
TheCanvasMap.Resize();
// limit the bounds of the map
var TheBounds =
{
XMin: 408016, // left side (usually wester most edge)
XMax: 410572, // right side (usually eastern most edge)
YMin: 4524761, // bottom side (usually southern most edge)
YMax: 4526248 // top side (usually northern most edge)
}
var TheView=TheCanvasMap.GetView();
//TheView.SetSetting("View2D","MaxBounds",TheBounds);
TheView.SetSetting("View2D","MaxBounds",{
Xs:[408016,410572], // min,max
Ys:[4524761,4526248] // Min,max
});
//TheCanvasMap.TheView.SetMaxBounds(TheBounds)OnLoad
TheView.ZoomToBounds(TheBounds); // 1 to 4 pixels per meter
// This is the zoom range that limits the map zoom
TheView.SetSetting("View2D","MinZoom",0);
TheView.SetSetting("View2D","MaxZoom",2);
//TheView.SetZoomRange(0,2); // 1 to 4 pixels per meter
TheView.ZoomTo(0); // start at 1 pixel per meter
// get view and then position us off the coast of the US
var TheCoordinate=TheProjector.ProjectFromGeographic(-124.0778,40.8755);
TheView.SetRefCenter(TheCoordinate.Easting,TheCoordinate.Northing);
TheCanvasMap.TheScene.DecrementRepaintBlocks();
}
//***************************************************************************
// 2.4 Other Event handlers and their support functions
//***************************************************************************
/**
* Function for when the user checks a box to zoom into a feature in the accordion
*
* Note: This is old code from when the buildings were in the accordian
*
* @param TheButton - name of the button that was pressed which matches the name of the feature in buildings
*/
/*
function ZoomTo(TheButton)
{
var ID=TheButton.id;
ID=ID.toLowerCase();
var NumRows=Layer_Buildings.GetNumAttributeRows();
for (var i=0;i<NumRows;i++)
{
var Value=Layer_Buildings.GetAttributeCellByHeading("Name",i);
if (Value=="Alder")
{
Layer_Buildings.SetFeatureProperty(CMLayer.FEATURE_STYLE,i,{fillStyle:"rgba(255,0,0,1)"} );
var TheBounds=Layer_Buildings.FeatureBounds[i];
TheCanvasMap.ZoomToBounds(TheBounds);
Layer_Buildings.Repaint();
}
}
var TheAttributeValues=Layer_Buildings.GetAttributeArrayByHeading("name");
var j=12;
}*/
/**
* Called when one of the checkboxes in the menu is checked. In other words,
* when the user makes a set of features visible or not
*/
function EntryChanged(TheCheckBox,LayerName,TypeIndex,SubtypeIndex,EntryIndex)
{
// get the correct layer
var TheLayer=Layer_Points;
if (LayerName=="Polyline")
{
TheLayer=Layer_Polylines;
}
//
var ZoomRange=[-1000,1000];
var TheDataset=TheLayer.GetDataset();
if (TheCheckBox.checked) // making visible
{
var FeatureBounds=null;
if (EntryIndex!=-1) // a specific entry was checked
{
var FeatureIndex=Entries[TypeIndex][SubtypeIndex][EntryIndex].FeatureIndex;
//TheLayer.SetFeatureSetting(CMLayer.ZOOM_RANGE,FeatureIndex,[-1000,1000]);
TheLayer.SetFeatureSetting("Layer","MinZoom",FeatureIndex,-1000);
TheLayer.SetFeatureSetting("Layer","MaxZoom",FeatureIndex,1000);
FeatureBounds=TheDataset.GetFeatureBounds(FeatureIndex);
}
else // a subtype was checked
{
var EntriesForSubtype=Entries[TypeIndex][SubtypeIndex];
// var FirstFeatureIndex=EntriesForSubtype[0].FeatureIndex;
// FeatureBounds=null; //TheLayer.FeatureBounds[0]; // start with the firest features bounds
// FeatureBounds=CMUtilities.CloneBounds(FeatureBounds);
for (var i=0;i<EntriesForSubtype.length;i++) // go through each of the entries in the sub type
{
var FeatureIndex=EntriesForSubtype[i].FeatureIndex;
// make the feature visible
TheLayer.SetFeatureSetting("Layer","MinZoom",FeatureIndex,-1000);
TheLayer.SetFeatureSetting("Layer","MaxZoom",FeatureIndex,1000);
// get the features bounds
var NewBounds=TheDataset.GetFeatureBounds(FeatureIndex);
if (FeatureBounds==null)
{
FeatureBounds=NewBounds;
}
else
{
// add the features bounds to the overall bounds
FeatureBounds=CMUtilities.AddToBounds(FeatureBounds,NewBounds);
}
if (LayerName!="Polyline") // must be points
{
var EAPID=TheDataset.GetAttributeCellByHeading("EAP_GRP",FeatureIndex); // emergency assembly point (EAP)
var EAPCOLOR=TheDataset.GetAttributeCellByHeading("EAP_COLOR",FeatureIndex);
if (EAPID!="") // clicked on an EAP entry
{
EAPID=parseInt(EAPID);// convert to int to match the values in the Buildings layer
// get the color as a 0-255 formated RGBA string
var RGBColor=CMUtilities.GetRGBFromHex(EAPCOLOR);
// setup the colors for the EAP outline and fill
var StokeColor="rgba("+RGBColor.Red+","+RGBColor.Green+","+RGBColor.Blue+",0.8)";
var FillColor="rgba(229,240,211,0.5)";
// get all the EAP values from the buildings
var TheArray=Layer_BuildingsEAP.GetDataset().GetAttributeArrayByHeading("EAP_GRP");