changeset 233:1a89174b7152 gmap2

Improvements in filtering controls.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 15 Mar 2014 19:21:40 +0200
parents 1706a1bb2a32
children 8a14983244b0
files markers.js
diffstat 1 files changed, 12 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/markers.js	Sat Mar 15 18:22:22 2014 +0200
+++ b/markers.js	Sat Mar 15 19:21:40 2014 +0200
@@ -268,6 +268,9 @@
 
   document.getElementById("controls").innerHTML = str;
 
+  //
+  // Set default states
+  //
   pmapSetVisContinent("all_c", true);
   pmapSetVisType("all_t", true);
   pmapUpdateVisible();
@@ -293,7 +296,7 @@
 var markerVisStates = [];
 
 
-function pmapSetVisState(c, show)
+function pmapSetFilterVisState(c, show)
 {
   markerVisStates[c] = show;
   document.getElementById("sp" + c).style.background = show ? "white" : "red";
@@ -317,41 +320,32 @@
 
 function pmapSetVisContinent(c, show)
 {
-  pmapSetVisState(c, show);
   if (c == "all_c")
   {
     for (var i = 0; i < pmapContinents.length; i++)
-      pmapSetVisState(pmapContinents[i][0], show);
+      pmapSetFilterVisState(pmapContinents[i][0], show);
   }
+  pmapSetFilterVisState(c, show);
 }
 
 
 function pmapSetVisType(c, show)
 {
-  pmapSetVisState(c, show);
   if (c == "all_t")
   {
+    for (var i in pmapAreas)
+      markerVisStates[i] = show;
+
     for (var i = 0; i < pmapMarkerTypes.length; i++)
-      pmapSetVisState(pmapMarkerTypes[i][1], show);
+      pmapSetFilterVisState(pmapMarkerTypes[i][1], show);
   }
+  pmapSetFilterVisState(c, show);
 }
 
 
 function pmapToggleVisContinent(c)
 {
-  var first = false;
-
-  if (c != "all_c")
-  {
-    pmapSetVisContinent("all_c", false);
-    pmapSetVisContinent(c, true);
-  }
-
-  if (!first)
-  {
-    pmapSetVisContinent(c, !markerVisStates[c]);
-  }
-
+  pmapSetVisContinent(c, !markerVisStates[c]);
   pmapUpdateVisible();
 }