zahidsw / geoxml3

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

doc.placmarks not saving json data #22

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a parser and add placemarks to map
2. afterParse call a function to use the data (as in example) 
3. attempt to access doc.placmemarks

What is the expected output? What do you see instead? I would expect to be able 
to access placemarks via JSON (tried logging them to the console). placemarks 
is undefined, even though they were added to the map

What version of the product are you using? On what operating system?
trunk?

Please provide any additional information below.

not sure if I'm messing something up, perhaps it's my issue here is my code

          var duh = true;
          var myParser = new geoXML3.parser({
              map: map,
              processStyles: true,
              createMarker: addMyMarker,
              createOverlay: addMyOverlay,
              afterParse: useTheData
            });
            myParser.parse(['lugers.kml']);

            function addMyMarker(placemark) {
              // Marker handling code goes here
              if (duh == true) {
                myParser.createMarker(placemark);
              }
            };

            function addMyOverlay(groundOverlay) {
              // Overlay handling code goes here
              if (duh == true) {
                myParser.createOverlay(groundOverlay);
              }
            };

            function useTheData(doc) {
            console.error("use the data");
            console.error(doc);
            console.error(doc.placemarks);

              // Geodata handling goes here, using JSON properties of the doc object
              for (var i = 0; i < doc.placemarks.length; i++) {
                console.error("placmark");
                console.error(doc.placemarks);
              }
            };

Original issue reported on code.google.com by estockme...@gmail.com on 8 Feb 2011 at 11:24

GoogleCodeExporter commented 9 years ago
Can you provide a link to a map that exhibits the problem?

If you are using the trunk, please test the polys branch, that is the most 
recent code and supports polygons and polylines.  There are known problems with 
the trunk that have been fixed in the polys branch, back porting the fixes is 
not a high priority.

Original comment by geocodezip on 9 Feb 2011 at 8:59

GoogleCodeExporter commented 9 years ago

Original comment by geocodezip on 9 Feb 2011 at 9:00

GoogleCodeExporter commented 9 years ago

Original comment by geocodezip on 9 Feb 2011 at 9:01

GoogleCodeExporter commented 9 years ago
the polys branch worked, but I still got an error that said the length or 
placemarks was undefined. After messing around with it a bit, I got it to work 
by using the following

 for (var i = 0; i < doc[0].placemarks.length; i++) {
        console.error("placmark");
        console.error(doc[0].placemarks[i]);
      }

no sure why, but you need to reference doc[0].placemarks rather than 
doc.plamarks

Thanks for your help

Original comment by estockme...@gmail.com on 9 Feb 2011 at 4:09

GoogleCodeExporter commented 9 years ago

Original comment by geocodezip on 20 Feb 2011 at 9:14