1
1
$ ( window ) . on ( 'load' , function ( ) {
2
2
var documentSettings = { } ;
3
- var markerColors = [ ] ;
3
+ var markerColors = [ ] ;
4
4
5
5
var polygonSettings = [ ] ;
6
6
var polygonSheets = 1 ;
7
7
var currentPolygonSheet = 0 ;
8
8
var polygonsLegend ;
9
9
10
+ var completePoints = false ;
11
+ var completePolygons = false ;
12
+ var completePolylines = false ;
13
+
10
14
/**
11
15
* Returns an Awesome marker with specified parameters
12
16
*/
@@ -251,10 +255,9 @@ $(window).on('load', function() {
251
255
searching : false ,
252
256
columns : generateColumnsArray ( ) ,
253
257
} ) ;
254
-
255
- updateTable ( ) ;
256
258
}
257
259
260
+ completePoints = true ;
258
261
return group ;
259
262
}
260
263
@@ -397,6 +400,8 @@ $(window).on('load', function() {
397
400
if ( legendPos == 'off' ) {
398
401
$ ( '.polygons-legend' ) . hide ( ) ;
399
402
}
403
+
404
+ completePolygons = true ;
400
405
}
401
406
402
407
/**
@@ -565,6 +570,8 @@ $(window).on('load', function() {
565
570
if ( points . length > 0 ) {
566
571
layers = determineLayers ( points ) ;
567
572
group = mapPoints ( points , layers ) ;
573
+ } else {
574
+ completePoints = true ;
568
575
}
569
576
570
577
centerAndZoomMap ( group ) ;
@@ -573,11 +580,15 @@ $(window).on('load', function() {
573
580
var polylines = mapData . sheets ( constants . polylinesSheetName ) . elements ;
574
581
if ( polylines . length > 0 ) {
575
582
processPolylines ( polylines ) ;
583
+ } else {
584
+ completePolylines = true ;
576
585
}
577
586
578
587
// Add polygons
579
588
if ( getPolygonSetting ( 0 , '_polygonsGeojsonURL' ) ) {
580
589
processPolygons ( ) ;
590
+ } else {
591
+ completePolygons = true ;
581
592
}
582
593
583
594
// Add Mapzen search control
@@ -615,7 +626,7 @@ $(window).on('load', function() {
615
626
// Change Map attribution to include author's info + urls
616
627
changeAttribution ( ) ;
617
628
618
- // Generate icons for markers legend
629
+ // Append icons to categories in markers legend
619
630
$ ( '#points-legend form label span' ) . each ( function ( i ) {
620
631
var legendIcon = ( markerColors [ i ] . indexOf ( '.' ) > 0 )
621
632
? '<img src="' + markerColors [ i ] + '" class="markers-legend-icon">'
@@ -625,16 +636,24 @@ $(window).on('load', function() {
625
636
$ ( this ) . prepend ( legendIcon ) ;
626
637
} ) ;
627
638
628
- // All processing has been done, so hide the loader and make the map visible
629
- $ ( '#map' ) . css ( 'visibility' , 'visible' ) ;
630
- $ ( '.loader' ) . hide ( ) ;
639
+ // When all processing is done, hide the loader and make the map visible
640
+ showMap ( ) ;
631
641
632
- // Open intro popup window in the center of the map
633
- if ( getSetting ( '_introPopupText' ) != '' ) {
634
- initIntroPopup ( getSetting ( '_introPopupText' ) , map . getCenter ( ) ) ;
635
- } ;
642
+ function showMap ( ) {
643
+ if ( completePoints && completePolylines && completePolygons ) {
644
+ $ ( '#map' ) . css ( 'visibility' , 'visible' ) ;
645
+ $ ( '.loader' ) . hide ( ) ;
636
646
637
- togglePolygonLabels ( ) ;
647
+ // Open intro popup window in the center of the map
648
+ if ( getSetting ( '_introPopupText' ) != '' ) {
649
+ initIntroPopup ( getSetting ( '_introPopupText' ) , map . getCenter ( ) ) ;
650
+ } ;
651
+
652
+ togglePolygonLabels ( ) ;
653
+ } else {
654
+ setTimeout ( showMap , 50 ) ;
655
+ }
656
+ }
638
657
}
639
658
640
659
/**
@@ -730,6 +749,10 @@ $(window).on('load', function() {
730
749
} ) ;
731
750
}
732
751
}
752
+
753
+ if ( p . length == index + 1 ) {
754
+ completePolylines = true ;
755
+ }
733
756
} ;
734
757
} ( i ) ) ;
735
758
}
0 commit comments