-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap.html
More file actions
1089 lines (833 loc) · 36 KB
/
Copy pathmap.html
File metadata and controls
1089 lines (833 loc) · 36 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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Atlas of Hawaiʻi · Palapalaʻāina o Hawaiʻi</title>
<link rel="shortcut icon" href="icons/favicon_ah_navy.ico" />
<link href="css/main.css" rel="stylesheet" type="text/css">
<style type="text/css">
* {
margin: 0;
padding: 0;
}
a img, iframe {
border: 0;
}
body {
font-family: Arial, Helvetica, Verdana, sans-serif;
font-size: 85%;
}
form, fieldset {
border: 0;
}
table {
border-collapse: collapse;
border: 0;
}
#homelogo {
position: absolute;
top: 5px;
left: 5px;
border: 1px solid #0F1B28;
}
#header {
position: absolute;
top: 5px;
left: 332px;
right: 5px;
height: 26px;
padding: 6px 5px 0px 5px;
/*text-align: center;
font-size: 22px;*/
border: 1px solid #AAAAAA;
}
#zoomToText {
position: absolute;
top: 6px;
left: 332px;
right: 5px;
height: 26px;
padding: 6px 5px 0px 5px;
}
#title {
position: absolute;
top: 5px;
left: 42px;
right: 5px;
height: 26px;
width: 275px;
padding: 6px 5px 0px 5px;
border: 1px solid #AAAAAA;
/*text-align: center;*/
/*font-size: 22px;*/
/*font-weight: bolder;*/
/*font-family: Arial, Verdana, Arial, sans-serif;*/
}
#addressBox {
position: absolute;
top: 5px;
right: 5px;
height: 26px;
padding: 7px 5px 0px 5px;
}
#map {
position: absolute;
top: 42px;
left: 5px;
right: 210px;
bottom: 5px;
border: 1px solid #979797;
}
#dragZoomInfo {
position: absolute;
top: 47px;
left: 13px;
}
#sidebar {
position: absolute;
top: 42px;
right: 5px;
width: 190px;
bottom: 77px;
padding: 5px 5px 5px 5px;
/*background-color: #CCCCCC; */
border: 1px solid #777777;
overflow: auto;
/*font-family: "Times New Roman", Times, serif;*/
/*font-size: 14px;*/
/*font-style: normal;*/
}
#sidebar * {
margin-bottom: 5px;
}
#sidebar select {
margin-top: 5px;
}
#toolBox {
position: absolute;
right: 5px;
width: 200px;
bottom: 55px;
height: 17px;
border: 1px solid #777777;
overflow: auto;
text-align: center;
font-size: small;
}
#mapInfo {
position: absolute;
right: 5px;
width: 200px;
bottom: 5px;
height: 45px;
border: 1px solid #777777;
overflow: auto;
font-size: small;
}
#boundingBox {
position: absolute;
bottom: 25px;
text-align: center;
width: 200px;
/*font-family: "Times New Roman", Times, serif;*/
/*font-size: 15px;*/
}
#cursorPosition {
position: absolute;
bottom: 3px;
left: 5px;
right: 5px;
z-index: 2;
background-color: #FFCC00; /*#FF9900; */
/*background-color: #FFFFFF;*/
/*color: #000000;*/
text-align: center;
/*font-size: small;*/
/*font-size: 15px;*/
color: #0F1B28;
}
#max_display_text {
left: 4px;
top: 20px;
}
#max_display_selector {
width: 150px;
}
#welcomeMessage {
background: #FFCC00;
color: #000000;
border: 1px dashed #FFFFFF;
padding: 15px;
margin: 15px;
}
#welcomeMessage a:link {
color: #006699;
text-decoration: none;
}
#welcomeMessage a:visited {
color: #006699;
text-decoration: none;
}
#welcomeMessage a:hover {
color: #990033;
text-decoration: none;
}
#welcomeMessage a:active {
color: #990033;
text-decoration: none;
}
#welcomeMessage p {
margin: 0px 0px 8px 0px;
}
/* NOTE: .labelstyle used by planimeter.js and ruler.js for style of ELabel in elabel.js: */
.labelstyle {
color: #000000;
background-color: #FFFFFF;
font-weight: bold;
}
.niceborder {
border: 0px solid #000000;
margin: 3px;
padding-top: 2px;
padding-right: 2px;
padding-bottom: 4px;
padding-left: 2px;
}
</style>
<!--
This supplies the Google Maps API Key for John Maurer's homepage:
-->
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAKfKzHtniMnzunHIMxSVkPxQaLZwQxbrHWeSEzQ5oyC7vtQh23xSu92Qem5E5uIg-Elfocps16Em-8A" type="text/javascript"></script>
<!--
Add JavaScript code for Key DragZoom Google Map utility library.
Source: http://gmaps-utility-library.googlecode.com/svn/trunk/keydragzoom/
Key Drag Zoom v1.0
Authors: Nianwei Liu [nianwei at gmail dot com] & Gary Little [gary at luxcentral dot com]
NOTE: Put in document.write so loads after above Google Maps API.
-->
<script>document.write( '<script src="scripts/keyDragZoom.js"><\/script>' );</script>
<!--
Add JavaScript code to display a latitude/longitude graticule on the map.
Source: http://www.bdcc.co.uk/Gmaps/BdccGmapBits.htm
Author: Bill Chadwick
-->
<script src="scripts/latLonGraticule.js" type="text/javascript"></script>
<!--
Add JavaScript code to display circular rings showing distance from a point
on the map.
Source: http://www.bdcc.co.uk/Gmaps/BdccGmapBits.htm
Author: Bill Chadwick
-->
<script src="scripts/rangeRings.js" type="text/javascript"></script>
<!--
Add JavaScript code to display ELabels, which allows you to place text labels
or images or any other HTML elements on the map and have them move with the map,
like marker and polyline overlays.
Source: http://econym.org.uk/gmap/elabel.htm
Author: Mike Williams
-->
<script src="scripts/elabel.js" type="text/javascript"></script>
<!--
Add JavaScript code to create or remove a dynamic ruler on the map.
Source: http://koti.mbnet.fi/ojalesa/exam/ruler.html
Author: Esa Ilmari
NOTE: Requires above elabel.js for ELabels.
-->
<script src="scripts/ruler.js" type="text/javascript"></script>
<!--
Add JavaScript code to create or remove a dynamic area calculator (a.k.a.
planimeter) on the map.
Source:
Author:
Modified By: John Maurer (2009).
NOTE: Requires above elabel.js for ELabels.
-->
<script src="scripts/planimeter.js" type="text/javascript"></script>
<!--
Add JavaScript code for iBox inline pop-up window.
Source: http://www.ibegin.com/labs/ibox/
Author: iBegin
-->
<script src="scripts/ibox/ibox.js" type="text/javascript"></script>
<!--
Add JavaScript code for jQuery cluetip inline pop-up window.
Source:
Author:
-->
<script src="scripts/jquery/cluetip/lib/jquery-1.3.2.js" type="text/javascript"></script>
<!-- Need these?
<script src="scripts/jquery/cluetip/lib/jquery.hoverIntent.js" type="text/javascript"></script>
<script src="scripts/jquery/cluetip/old/jquery.dimensions.js" type="text/javascript"></script>
-->
<script src="scripts/jquery/cluetip/jquery.cluetip.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$('a.clue').cluetip({activation: 'click', attribute: 'href', closePosition: 'title', closeText: '<img src="icons/cross.png" alt="close window" title="close window"/>', sticky: true, width: 300});
});
</script>
<link rel="stylesheet" href="scripts/jquery/cluetip/jquery.cluetip.css" type="text/css" />
<!--
User-defined JavaScript functions:
-->
<script type="text/javascript">
/* Pre-load image icons: */
var ahLogoGold = new Image( 32, 32 );
ahLogoGold.src = "logos/ah_icon_simple_gold_32x32.png";
var ahLogoOlive = new Image( 32, 32 );
ahLogoOlive.src = "logos/ah_icon_simple_olive_32x32.png";
var nextImage = new Image( 19, 18 );
nextImage.src = "icons/next.png";
var nextHighlightImage = new Image( 19, 18 );
nextHighlightImage.src = "icons/nextHighlight.png";
var pauseImage = new Image( 13, 18 );
pauseImage.src = "icons/pause.png";
var pauseHighlightImage = new Image( 13, 18 );
pauseHighlightImage.src = "icons/pauseHighlight.png";
var playImage = new Image( 13, 18 );
playImage.src = "icons/play.png";
var playHighlightImage = new Image( 13, 18 );
playHighlightImage.src = "icons/playHighlight.png";
var prevImage = new Image( 19, 18 );
prevImage.src = "icons/prev.png";
var prevHighlightImage = new Image( 19, 18 );
prevHighlightImage.src = "icons/prevHighlight.png";
/* Global variables: */
// For storing Google Map:
var map;
// For storing Google Map address geocoder:
var geocoder;
// For storing ID of setInterval() function when looping through locations:
var loopIntervalID;
// For storing number of milliseconds to loop in the above setInterval():
var loopIntervalMilliseconds = 5000;
// Global variables to hold IDs for various tools overlays:
var latLonGraticuleID = 0;
var rangeRingsID = 0;
// For storing whether a marker has been single or double clicked:
var markerSingleClicked = false;
var markerDoubleClicked = false;
var clickTimeoutTest = 0;
// For storing KML/KMZ overlays...
var nwsOverlayTest;
var nws_1hour_precip;
var nws_composite_reflectivity;
var nws_longrange_reflectivity;
var nws_shortrange_reflectivity;
var nws_storm_relativemotion;
var nws_storm_totalprecip;
var nws_velocity;
var nws_warnings;
/*
This JavaScript function controls the Google Map that is displayed.
Author: John Maurer
*/
function loadGoogleMap() {
// Only create a Google Map if Google determines the browser is compatible:
if ( GBrowserIsCompatible() ) {
// Start a new Google Map and Geocoder:
map = new GMap2( document.getElementById( 'map' ) );
geocoder = new GClientGeocoder();
// Set starting map center, bounds, and zoom level; to
// fit the main islands of Hawaii:
var center = new GLatLng( 20.5453, -157.4780 );
var sw = new GLatLng( 18.5941, -160.4498 );
var ne = new GLatLng( 22.4364, -154.5996 );
var bounds = new GLatLngBounds( sw, ne );
var zoomLevel = map.getBoundsZoomLevel( bounds );
map.setCenter( center, zoomLevel );
// Set various features of the map:
map.setMapType( G_HYBRID_MAP );
//map.setMapType( G_SATELLITE_MAP );
map.addMapType( G_PHYSICAL_MAP );
map.addMapType( G_SATELLITE_3D_MAP );
map.addControl( new GLargeMapControl3D(), new GControlPosition( G_ANCHOR_TOP_LEFT, new GSize( 7, 24 ) ) );
map.addControl( new GMapTypeControl() );
map.addControl( new GScaleControl() );
//map.addControl( new GNavLabelControl(), new GControlPosition( G_ANCHOR_BOTTOM_RIGHT ) );
// Add draggable zoom box from keyDragZoom.js:
map.enableKeyDragZoom( {
key: "shift",
boxStyle: { border: "medium solid yellow", backgroundColor: "transparent", opacity: 1 },
paneStyle: { backgroundColor: "black", opacity: 0.1 }
}
);
map.enableDoubleClickZoom();
map.enableContinuousZoom();
map.enableScrollWheelZoom();
// Add an overview map:
//var overviewMap = new GOverviewMapControl()
//map.addControl( overviewMap );
//overviewMap.hide();
// Display the lat/long of the current cursor location when the
// mouse is over the map image:
GEvent.addListener( map, "mousemove", function( point ) {
// First, strip the latitude and longitude of the cursor location
// down to a reasonable number of decimals (Google supplies many by default!):
var numDecimals = 4;
// Get latitude and longitude and convert to strings:
var cursorLat = point.lat();
var cursorLatStr = cursorLat.toString();
var cursorLng = point.lng();
var cursorLngStr = cursorLng.toString();
// Get the string index of the decimal point for each:
var decimalPointIndexLat = cursorLatStr.indexOf( '.' );
var decimalPointIndexLng = cursorLngStr.indexOf( '.' );
// Get the substring that goes up to the number of decimals specified
// in numDecimals:
var cursorLatSubstr = cursorLatStr.substr( 0, decimalPointIndexLat + 1 + numDecimals );
var cursorLngSubstr = cursorLngStr.substr( 0, decimalPointIndexLng + 1 + numDecimals );
// Define and display the string that will be displayed using these two
// n-digit numbers:
var pointNumDecimals = cursorLatSubstr + ', ' + cursorLngSubstr;
document.getElementById( "cursorPosition" ).innerHTML = '<b>cursor:</b> ' + pointNumDecimals;
}
);
// When the mouse is not over the map image, display nothing:
GEvent.addListener( map, "mouseout", function() {
document.getElementById( "cursorPosition" ).innerHTML = '';
}
);
// Define various KML overlays:
// Give them a useless random parameter so that Google does not cache results; this will
// allow content that get refreshed to be refreshed in our map:
var date = new Date();
var junkParameter = ( date.getYear() + 1900 ).toString() + date.getMonth().toString() + date.getDate().toString() + date.getHours().toString() + date.getMinutes().toString() + date.getSeconds().toString();
// Doppler radar overlays:
nws_1hour_precip = new GGeoXml( "http://www2.hawaii.edu/~jmaurer/kml/doppler/nws_1hour_precip.kml?" + junkParameter );
nws_composite_reflectivity = new GGeoXml( "http://www2.hawaii.edu/~jmaurer/kml/doppler/nws_composite_reflectivity.kml?" + junkParameter );
nws_longrange_reflectivity = new GGeoXml( "http://www2.hawaii.edu/~jmaurer/kml/doppler/nws_longrange_reflectivity.kml?" + junkParameter );
nws_shortrange_reflectivity = new GGeoXml( "http://www2.hawaii.edu/~jmaurer/kml/doppler/nws_shortrange_reflectivity.kml?" + junkParameter );
nws_storm_relativemotion = new GGeoXml( "http://www2.hawaii.edu/~jmaurer/kml/doppler/nws_storm_relativemotion.kml?" + junkParameter );
nws_storm_totalprecip = new GGeoXml( "http://www2.hawaii.edu/~jmaurer/kml/doppler/nws_storm_totalprecip.kml?" + junkParameter );
nws_velocity = new GGeoXml( "http://www2.hawaii.edu/~jmaurer/kml/doppler/nws_velocity.kml?" + junkParameter );
nws_warnings = new GGeoXml( "http://www2.hawaii.edu/~jmaurer/kml/doppler/nws_warnings.kml?" + junkParameter );
} // if browser compatible
// If the browser is not compatible, display a static image instead:
else {
alert( "You're browser is not compatible with Google Maps." );
}
} // end function loadGoogleMap()
/*
This JavaScript function prints a message with the current map dimensions,
including the map center, zoom level, and map bounding box:
NOTE: map needs to be predefined (see loadGoogleMap() above).
Author: John Maurer
*/
function showMapDimensions() {
// First, strip latitudes and longitudes down to a reasonable
// number of decimals (Google supplies many by default!):
var numDecimals = 4;
// Get map center:
var centerStr = map.getCenter().toString();
// Split map center into latitude and longitude:
centerStr.match( /^\((.+), (.+)\)$/ );
var centerLat = RegExp.$1;
var centerLon = RegExp.$2;
// Reduce number of digits in map center lat/long:
var centerLatSubstr = centerLat.substr( 0, centerLat.indexOf( '.' ) + 1 + numDecimals );
var centerLonSubstr = centerLon.substr( 0, centerLon.indexOf( '.' ) + 1 + numDecimals );
// Get map zoom level:
var zoomLevel = map.getZoom().toString();
// Get map bounding box:
var bboxStr = map.getBounds().toString();
// Split bounding box into minlat, minlon, maxlat, and maxlon:
bboxStr.match( /^\(\((.+), (.+)\), \((.+), (.+)\)\)$/ );
var minLat = RegExp.$1;
var minLon = RegExp.$2;
var maxLat = RegExp.$3;
var maxLon = RegExp.$4;
// Reduce the number of digits in each of the above:
var minLatSubstr = minLat.substr( 0, minLat.indexOf( '.' ) + 1 + numDecimals );
var minLonSubstr = minLon.substr( 0, minLon.indexOf( '.' ) + 1 + numDecimals );
var maxLatSubstr = maxLat.substr( 0, maxLat.indexOf( '.' ) + 1 + numDecimals );
var maxLonSubstr = maxLon.substr( 0, maxLon.indexOf( '.' ) + 1 + numDecimals );
// Get map size (in number of pixels):
var sizeStr = map.getSize().toString();
// Split map size into width and height:
sizeStr.match( /^\((.+), (.+)\)$/ );
var width = RegExp.$1;
var height = RegExp.$2;
// Print the above dimensions into a separate pop-up window:
var popup = window.open( '', 'popup', 'resizable=yes, width=650, height=200, menubar=no, toolbar=no, location=no, scrollbars=no, left=400, top=400' );
popup.document.write(
'<html>'
+ '<head>'
+ '<title>Current Map Dimensions</title>'
+ '<link href="css/subpages.css" rel="stylesheet" type="text/css">'
+ '<style>'
+ 'h3 { font-family: Verdana, Tahoma, sans-serif; font-size: 105%; font-weight: bold; color: #003366; line-height: normal; padding-top: 6px; padding-bottom: 3px; padding-left: 0px; margin: 0px; }'
+ '</style>'
+ '</head>'
+ '<body style="padding: 0px 0px 0px 12px;">'
+ '<h3>Current map dimensions:</h3>'
+ '<ul>'
+ '<li>Center (Lat, Long): ' + centerLatSubstr + ', ' + centerLonSubstr
+ '<br/>'
+ '<li>Zoom Level: ' + zoomLevel
+ '<br/>'
+ '<li>Bounds (Min Lat, Min Long, Max Lat, Max Long): ' + minLatSubstr + ', ' + minLonSubstr + ', ' + maxLatSubstr + ', ' + maxLonSubstr
+ '<br/>'
+ '<li>Size (Width, Height): ' + width + ' px, ' + height + ' px'
+ '<br/>'
+ '<li>Map Projection: Spherical Mercator'
+ '</ul>'
+ '<a href="javascript:window.close();" class="NavLinksNSIDC" style="cursor: pointer; cursor: hand;"><img src="icons/cross_maroon_8x8.gif" border=0 align="absmiddle" width="8" height="8"/> <font color="#990033" style="Arial, Helvetica, sans-serif;">close window</font></a>'
+ '</body>'
+ '</html>'
);
} // function showMapDimensions()
/*
This JavaScript function puts a marker and info window at the submitted address.
NOTE: map and geocoder need to be predefined (see loadGoogleMap() above).
Author: Google Maps API Documentation
*/
function showAddress( address ) {
if ( geocoder ) {
geocoder.getLatLng(
address,
function( point ) {
// If the address is not found, display an alert message:
if ( !point ) {
alert( address + " not found" );
}
// Otherwise, display a marker and info window at the address:
else {
map.setCenter( point );
var markerOptions = { title:address };
var marker = new GMarker( point, markerOptions );
var markerHtml;
markerHtml = "<p class='googleMapMarkerText'>" + address + "</p>";
markerHtml += "<br/><p><font class='SmallTextGray'><i>NOTE: Double-click marker to remove it...</i></font></p>";
map.addOverlay( marker );
marker.openInfoWindowHtml( markerHtml );
// Make the info window appear when the marker is clicked, and
// make the marker disappear when it is double-clicked. Google
// Maps doesn't work to give a marker both a click and a double-
// click listener, so we're going to listen for a double-click
// by using a 250 millisecond setTimeout():
GEvent.addListener( marker, "click", function() {
if ( markerSingleClicked ) {
markerDoubleClicked = true;
}
else {
markerSingleClicked = true;
markerDoubleClicked = false;
setTimeout( makeCaller( markerActionAddress, marker, point, markerHtml ), 250 );
}
}
);
}
} // function()
); // geocoder()
} // if geocoder
// Set the default message and style into address display box:
var addressBox = window.document.atlasForm.address;
addressBox.value = "Enter an address or coordinates here...";
addressBox.style.color = "gray";
addressBox.style.fontStyle = "italic";
} // function showAddress()
/*
This function displays an info pop-up window on a marker if it is single-clicked
or it removes the marker if it is double-clicked. A setTimeout() must be used
to toggle global variables that determine if there is a single or double-click.
Author: John Maurer
*/
function markerActionAddress ( marker, point, markerHtml ) {
if ( markerDoubleClicked ) {
map.removeOverlay( marker );
}
else {
map.openInfoWindowHtml( point, markerHtml );
}
// Reset the clicked/double-clicked status:
markerSingleClicked = false;
}
/*
This fuction turns the first argument into a function with up to 10 optional
arguments. Used in event listeners like GEvent.addListener() and setTimeout() so
they properly handle arguments.
Author: Acme Laboratories (http://acme.com/javascript/Utils.jsm)
*/
function makeCaller ( func, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 ) {
return function () {
func( arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 );
};
}
/*
This JavaScript function jumps to a particular location from a list of options.
It chooses an appopriate zoom level for each location.
NOTE: map needs to be predefined (see loadGoogleMap() above).
Author: John Maurer
*/
function jumpTo( location ) {
var center;
var zoomLevel;
var sw;
var ne;
var bounds;
// Home location:
if ( location == "Hawai'i (State)" ) {
center = new GLatLng( 19.5869, -155.4675 );
sw = new GLatLng( 17.7225, -161.9494 );
ne = new GLatLng( 23.1757, -152.5836 );
}
// Each of the main Hawaiian islands:
else if ( location == "Hawai'i (Big Island)" ) {
center = new GLatLng( 19.5895, -155.5128 );
sw = new GLatLng( 18.9023, -156.6842 );
ne = new GLatLng( 20.2737, -154.3428 );
}
else if ( location == "Kaho'olawe" ) {
center = new GLatLng( 20.5476, -156.6066 );
sw = new GLatLng( 20.4850, -156.7103 );
ne = new GLatLng( 20.6226, -156.5220 );
}
else if ( location == "Kaua'i" ) {
center = new GLatLng( 22.0506, -159.4960 );
sw = new GLatLng( 21.7862, -159.8497 );
ne = new GLatLng( 22.3310, -159.1905 );
}
else if ( location == "Lana'i" ) {
center = new GLatLng( 20.8312, -156.9348 );
sw = new GLatLng( 20.6970, -157.1020 );
ne = new GLatLng( 20.9716, -156.7724 );
}
else if ( location == "Maui" ) {
center = new GLatLng( 20.7920, -156.3327 );
sw = new GLatLng( 20.5241, -156.7172 );
ne = new GLatLng( 21.0736, -155.9193 );
}
else if ( location == "Moloka'i" ) {
center = new GLatLng( 21.1280, -157.0159 );
sw = new GLatLng( 20.9934, -157.3743 );
ne = new GLatLng( 21.2573, -156.665 );
}
else if ( location == "Ni'ihau" ) {
center = new GLatLng( 21.8965, -160.1408 );
sw = new GLatLng( 21.7652, -160.2726 );
ne = new GLatLng( 22.0219, -160.0254 );
}
else if ( location == "O'ahu" ) {
center = new GLatLng( 21.4524, -157.9648 );
sw = new GLatLng( 21.1914, -158.3164 );
ne = new GLatLng( 21.7505, -157.6023 );
}
// The Northwestern (Leeward) Islands:
else if ( location == "Northwestern" ) {
center = new GLatLng( 24.5271, -168.6621 );
sw = new GLatLng( 17.9996, 177.6708 );
ne = new GLatLng( 31.5972, -154.0722 );
}
// Compute the zoomLevel that will fit the location's bounding box:
bounds = new GLatLngBounds( sw, ne );
zoomLevel = map.getBoundsZoomLevel( bounds );
// Set map to specified center point and zoom level:
map.setCenter( center, zoomLevel );
}
/*
This JavaScript function fills in the appropriate select options for
zoom-to locations based on the selected category.
Author: John Maurer
*/
function setJumpToOptions ( category ) {
var form = window.document.atlasForm;
form.jumpToIsland.style.display = "none";
form.jumpToBeach.style.display = "none";
form.jumpToStatePark.style.display = "none";
if ( category == "Island" ) {
form.jumpToIsland.style.display = "inline";
form.jumpToIsland.selectedIndex = 0;
}
else if ( category == "Beach" ) {
form.jumpToBeach.style.display = "inline";
form.jumpToBeach.selectedIndex = 0;
}
else if ( category == "State Park" ) {
form.jumpToStatePark.style.display = "inline";
form.jumpToStatePark.selectedIndex = 0;
}
}
/*
This JavaScript function increments either "forward" or "backward" in the
select list for the specified category.
Author: John Maurer
*/
function incrementCategory ( category, direction ) {
var form = window.document.atlasForm;
// Determine which select list to increment:
var jumpToList;
if ( category == "Island" ) {
jumpToList = form.jumpToIsland;
}
else if ( category == "Beach" ) {
jumpToList = form.jumpToBeach;
}
else if ( category == "State Park" ) {
jumpToList = form.jumpToStatePark;
}
// Get currently selected location and total length of this list:
var currentIndex = jumpToList.selectedIndex;
var length = jumpToList.length;
var lastIndex = length - 1;
// Determine the incremented index in this list; if value is
// null, skip another increment until you find a non-null value:
// this allows us to have select options that provide other
// event handler functions like displaying or removing markers:
var incIndex = currentIndex;
var incValue = '';
do {
if ( direction == "forward" ) {
if ( incIndex == lastIndex ) {
incIndex = 1;
}
else {
incIndex++;
}
}
else {
if ( incIndex == 1 ) {
incIndex = lastIndex;
}
else {
incIndex--;
}
}
// Get the value associated with the incremented index:
incValue = jumpToList[ incIndex ].value;
}
while ( !incValue );
// Set and jump to the next location value:
jumpToList.value = incValue;
jumpTo( incValue );
}
/*
This JavaScript function increments the loop speed for looping through
location lists when the play button has been pressed either "faster" or
"slower"; this either increases or decreases the number of milliseconds
in the global loopIntervalMilliseconds variable.
Author: John Maurer
*/
function incrementSpeed ( direction ) {
var minIntervalMilliseconds = 3000;
var maxIntervalMilliseconds = 10000;
if ( direction == "faster" ) {
if ( loopIntervalMilliseconds > minIntervalMilliseconds ) {
loopIntervalMilliseconds -= 1000;
}
}
else {
if ( loopIntervalMilliseconds < maxIntervalMilliseconds ) {
loopIntervalMilliseconds += 1000;
}
}
// Update the speed display with the new interval:
var loopIntervalSeconds = ( loopIntervalMilliseconds / 1000 ).toString();
window.document.getElementById( 'displaySpeed' ).innerHTML = "<font color='gold'><b>" + loopIntervalSeconds + "</b></font>";
// Stop the current loop and restart another with the new speed:
clearInterval( loopIntervalID );
loopIntervalID = setInterval( "incrementCategory( window.document.atlasForm.jumpToCategory.value, 'forward' )", loopIntervalMilliseconds );
}
/*
This function removes all map overlays using the values in the
given "category" select list.
Author: John Maurer
*/
function removeOverlays ( category ) {
for ( var i = 0; i < category.length; i++ ) {
// eval() is used to turn option value into reference to global variable
// of the same name holding that Google Maps API GGeoXml object:
map.removeOverlay( eval( category.options[ i ].value ) );
}
}
/*
This function adds the specified overlay with the specified refresh rate.
Since the Google Map API does not currently seem to honor the refresh rate
specified in the KML, this is a workaround to achieve it, since data that
are frequently updated (doppler radar, etc.) need it in order to stay current.
Before adding the overlay each time it is removed and then added back.
Author: John Maurer
*/
function addOverlayWithRefresh( overlay, refreshRateMilliseconds ) {
alert( overlay.value );
refreshIntervalID = setInterval( "map.removeOverlay( overlay ); map.addOverlay( overlay );", refreshRateMilliseconds );
}
</script>
</head>
<body onLoad="loadGoogleMap();" onUnload="GUnload();">
<form name="atlasForm">
<div id="homelogo"><a rel="ibox&width=500&height=263" href="mapwelcome.html" title="About the Atlas of Hawaiʻi..."><img src='logos/ah_icon_simple_gold_32x32.png' width="32" height="32" onMouseOver="this.src='logos/ah_icon_simple_olive_32x32.png'" onMouseOut="this.src='logos/ah_icon_simple_gold_32x32.png'" /></a></div>
<div id="title"><b>Atlas of Hawaiʻi <font color="gray">·</font> Palapalaʻāina o Hawaiʻi</b></div>
<div id="zoomToText"><b>Zoom to:</b></div>
<div id="header"><!-- -->
<select style="margin: 0px 0px 0px 65px;" name="jumpToCategory" onChange="this.blur(); setJumpToOptions( this.value );">
<option value="" disabled>Select a category...</option>
<option value="Beach">Beach</option>
<option value="Island" selected>Island</option>
<option value="State Park">State Park</option>
</select>
<select id="jumpToIsland" name="jumpToIsland" onChange="this.blur(); jumpTo( this.value );">