rarietta / geoxml3

Automatically exported from code.google.com/p/geoxml3
0 stars 1 forks source link

hideDocument executes properly, but map doesn't update #113

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Initialize map:

myParser = new geoXML3.parser({map: map});

2. Load KML string for each file and create a Show/Hide toggle button for each 
file:

function handleFileSelect(evt) {
    var files = evt.target.files; // FileList object

    // files is a FileList of File objects. List some properties.
    var output = [];
    for (var i = 0, f; f = files[i]; i++) {
      output.push('<li><strong>', escape(f.name), '</strong>', '</li>');
      var fr = new FileReader();
      fr.onload = function () {
            myParser.parseKmlString(this.result);
        };
      fr.readAsText(files[i]);

      var button = document.createElement('button');
      button.id = 'kmlShowHide' + i;
      button.innerHTML = 'Hide: ' + escape(f.name);
      button.onclick = kmlHideShowToggle;
      document.getElementById('kmlLayers').appendChild(button);
      var br = document.createElement("br");
      document.getElementById('kmlLayers').appendChild(br);
    }
    document.getElementById('list').innerHTML = '<ul>' + output.join('') + '</ul>';
  }

3. Click the Show/Hide button and execute the following:

  function kmlHideShowToggle(){
    var buttonId = this.id;
    var kmlIndex = buttonId.substring(11,12);
    alert(kmlIndex);
    alert(myParser.docs[0].placemarks.length);

    var buttonName = this.innerHTML;
    var buttonNameArray = buttonName.split(': ');
    var hideShowText = buttonNameArray[0];
    var buttonFileName = buttonNameArray[1];

    if (hideShowText == 'Hide') {
      myParser.hideDocument(myParser.docs[kmlIndex]);
      document.getElementById(this.id).innerHTML = 'Show: ' + buttonFileName;
    } else {
      myParser.showDocument(myParser.docs[kmlIndex]);
      document.getElementById(this.id).innerHTML = 'Hide: ' + buttonFileName;
    }

    return false;
  }

4. Observe that hideDocument is executed and the setMap property for the 
gpolylines for the doc is set to null.

With alert statements, I verified this.

What is the expected output? 
KML lines should be hidden on the map.

What do you see instead?
KML lines are still there.

What version of the product are you using? 
r127 in the kmz branch.

On what operating system?
Win7 w/ Chrome

Original issue reported on code.google.com by PJSimon4...@gmail.com on 1 Jul 2015 at 1:43

GoogleCodeExporter commented 9 years ago
Unable to reproduce this issue.  It suddenly started working!  Thanks for this 
great tool!

Original comment by PJSimon4...@gmail.com on 1 Jul 2015 at 1:49

GoogleCodeExporter commented 9 years ago
Please provide sample KML required to reproduce the issue.

Original comment by geocodezip on 1 Jul 2015 at 6:55