Git Product home page Git Product logo

Comments (3)

tmcw avatar tmcw commented on August 22, 2024 2

I've corrected that readme example.

  fetch("test/data/linestring.kml")
    .then(function(response) {
      return response.text();
    })
    .then(function(xml) {
      console.log(kml(new DOMParser().parseFromString(xml, "text/xml")));
    });

from togeojson.

hoogw avatar hoogw commented on August 22, 2024

Now I save js file to apache2.4 server,

         `
             <script src='../share/lib/togeojson/dist/togeojson.umd.js'></script>

               <script>


fetch("https://opendata.arcgis.com/datasets/30400d96c9ef427380ff05dabd09fa2e_26.kml")
  .then(function(response) {
    return response.responseXML;
  })
  .then(function(xml) {


           // console.log(kml(xml));

           //console.log( 'kml reference ->' ,toGeoJSON.kml );
           console.log( 'kml -> geojson -> ', toGeoJSON.kml(xml) );
           
        



                 });
              </script>`

I still get error:
uncaught (in promise) TypeError: Cannot read property 'getElementsByTagName' of undefined at S (kml.js:273) at S.next (<anonymous>) at Function.from (<anonymous>) at Object.e.kml (kml.js:309) at kml_to_geojson.html:43

from togeojson.

hoogw avatar hoogw commented on August 22, 2024

yes, this works like a charm!!!!!

Note:
must use 'toGeoJSON.kml' instead of 'kml'
direct use 'kml' will cause "kml undefine error"

the working code is:

            `<script src='https://unpkg.com/@tmcw/[email protected]/dist/togeojson.umd.js'>  

                </script>

                 <script>


fetch("https://opendata.arcgis.com/datasets/30400d96c9ef427380ff05dabd09fa2e_26.kml")
  .then(function(response) {
    return response.text();
  })
  .then(function(xml) {


           // console.log(kml(xml));

           //console.log( 'kml reference ->' ,toGeoJSON.kml );
            // console.log( 'kml -> geojson -> ', toGeoJSON.kml(xml) );
           
           console.log(toGeoJSON.kml(new DOMParser().parseFromString(xml, "text/xml")));



             });
            </script>`

from togeojson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.