mdeutch3 / geoxml3

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

Stand-alone parser returns empty doc #59

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I am trying to use geoxml3 as a stand-alone parser. According to the wiki, I am 
doing something like this:

  <script type="text/javascript">
    var myParser = new geoXML3.parser({afterParse: useTheData});
    myParser.parse('my_geodata.kml');

    function useTheData(doc) {
      // Geodata handling goes here, using JSON properties of the doc object
      for (var i = 0; i < doc.placemarks.length; i++) {
        doSomething;
      }
    };
  </script>

However, in my for-loop, doc has empty placemarks, as if it is not being saved 
in the source. Can someone confirm that the stand-alone parser indeed works?

Original issue reported on code.google.com by BasemEm...@gmail.com on 20 May 2012 at 7:38

GoogleCodeExporter commented 9 years ago
Seems intentional by looking at the source code. Not sure why coordinates are 
saved to doc if there are only 1. I created a patch (#60) with a new parser 
option called "pointsOnly". This will extract all coordinates across all 
placemarks. This way, I can use the points to create my own polyline, even if I 
wish to use another 3rd party Google Map API like gmap3.

Original comment by BasemEm...@gmail.com on 20 May 2012 at 11:43

GoogleCodeExporter commented 9 years ago
Added #61 patch to return placemarks instead of just coordinates.

Original comment by BasemEm...@gmail.com on 21 May 2012 at 2:46

GoogleCodeExporter commented 9 years ago
Do you have an example that shows the problem?

Original comment by geocodezip on 24 May 2012 at 6:00

GoogleCodeExporter commented 9 years ago
I have attached a working sample. You will see the doc[0].placemarks is empty 
when using stand-alone parser. However, when using geoxml3.mod.js in the 
sample, it has the placemarks object. The mod file is from patch posted to 
issue #61. I hope this makes sense. Thanks a mil!

Original comment by BasemEm...@gmail.com on 24 May 2012 at 5:01

Attachments:

GoogleCodeExporter commented 9 years ago
The trunk is fairly old (although I am surprised that the stand-alone parser 
doesn't work), I wouldn't be surprised that it didn't work in the more recent 
branches (polys/kmz), but that is only because it hasn't been tested.

The trunk also doesn't support polylines or polygons.

Your example doesn't work, did you test it? It doesn't include the google maps 
API.

Fixed example here (you also need to set "zoom" to false):

http://www.geocodezip.com/geoxml3_test/geoxml3-parser-mod/index_polys.html

I am not planning on merging the polys fixes back into the trunk at this time, 
so I am closing this as "WontFix", feel free to vote for issue 52 if you are 
interested in that happening:

http://code.google.com/p/geoxml3/issues/detail?id=52

Original comment by geocodezip on 25 May 2012 at 6:28

GoogleCodeExporter commented 9 years ago
I am only using it as a parser, then in I feed it to gmap3 to draw the 
polyline. Works really well with my patch. I am only showing the parser only 
portion in the sample. I will check out the polys trunk. Thanks again.

Original comment by BasemEm...@gmail.com on 25 May 2012 at 1:03

GoogleCodeExporter commented 9 years ago
OK.  Glad it is working for you.  If you find any issues with the polys or kmz 
branches, please let me know I can either re-open this issue or you can start 
another.
  Thank you.

Original comment by geocodezip on 25 May 2012 at 1:23