Comments (14)
The solution is what I posted before: use
<script src='https://unpkg.com/@tmcw/[email protected]/dist/togeojson.umd.js'></script>
from togeojson.
It looks like, in this context, you're in a clone of this repository (togeojson/index.js), and trying to get browserify to create a standalone bundle of togeojson?
Assuming that's the case, first off: you can get a standalone bundle, if you're in a git checkout, by running:
$ npm install
$ npm run prepare
There are also prebuilt standalone bundles on unpkg: https://unpkg.com/browse/@tmcw/[email protected]/dist/ (you'd want the .umd ones, most likely).
from togeojson.
I have tried you suggestion, but still get error as:
`Uncaught (in promise) ReferenceError: kml is not defined
at convert_kml_to_geojson (helper.js:313)`
html, script tag is:
<script src='https://unpkg.com/browse/@tmcw/[email protected]/dist/togeojson.umd.js'>
js call this function
`
function convert_kml_to_geojson(kml_string){
var kml_dom = new DOMParser().parseFromString(kml_string, "text/xml");
console.log( 'kml_dom ', kml_dom );
console.log( kml );
console.log( kml(kml_dom) );
}`
from togeojson.
You'll need to refer to the kml
function of toGeoJSON as toGeoJSON.kml
, instead of just kml
.
from togeojson.
This time I get
Uncaught (in promise) ReferenceError: toGeoJSON is not defined at convert_kml_to_geojson (helper.js:313)
` function convert_kml_to_geojson(kml_string){
var kml_dom = new DOMParser().parseFromString(kml_string, "text/xml");
console.log( 'kml_dom ', kml_dom );
console.log( 'kml reference ->' ,toGeoJSON.kml );
console.log( 'kml -> geojson -> ', toGeoJSON.kml(kml_dom) );
}`
from togeojson.
I have tried, both script tag, with/without type='module'
same error
toGeoJSON is not defined
`<script type='module' src='https://unpkg.com/browse/@tmcw/[email protected]/dist/togeojson.umd.js'> `
from togeojson.
I found the reason:
my browser console complain when load "togeojson.umd.js"
`Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.`
from togeojson.
I use opera, seem like failed to load module at the first place, because of strict......
from togeojson.
I tried with firefox, get more info
Loading module from “https://unpkg.com/browse/@tmcw/[email protected]/dist/togeojson.umd.js” was blocked because of a disallowed MIME type (“text/html”).
learn more at:
from togeojson.
I tried with google chrome, get this, is ES6 module problem,many people get this.
`Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.`
from togeojson.
The URL should be https://unpkg.com/@tmcw/[email protected]/dist/togeojson.umd.js
from togeojson.
Ok, I found a fix !!!!!!!
Simply saying:
You need to save togeojson.umd.js file on to your node http server! or Python http server!!!
if you use the online "unpkg.com" version, your browser will block load module due to unpkg.com server incorrectly respond MIME type!!!
if you put that file on apache2.4 server, likely failed for same reason(not test yet)
Why? because only node http server and python http server can correctly respond MIME type
see this top accepted answer:
https://stackoverflow.com/questions/46138375/trouble-with-es6-modules#
The problem is NOT caused by toGeoJSON module iteself, it caused by how you get this module from( unpkg.com, apache will failed, node and python http server will success)
from togeojson.
Now I save togeojson.umd.js to my node.js server, no more error.
works like a charming!!! after 4 hours painful countless try and failure.
I will continue to try save it on apache2.4 server, see what happen.
On other side, do you have any idea to work around it?
from togeojson.
yes, this one works:
https://unpkg.com/@tmcw/[email protected]/dist/togeojson.umd.js
but this one DO NOT work:
https://unpkg.com/browse/@tmcw/[email protected]/dist/togeojson.umd.js
I believe the local dist, by npm install is the same as first one (works) above.
So, for safe, just run a local npm install, get it from dist folder.
from togeojson.
Related Issues (20)
- Remove swc dep?
- Add support for LinearRing outside Polygon HOT 1
- GPX conversion adds "s" character to extension names HOT 1
- TS7016: Could not find a declaration file
- GPX metadataType HOT 2
- KML Bounds Not Parsed HOT 3
- Unexpected link to online shop in dist/lib HOT 1
- skipEmpty option for KML HOT 1
- KMZ overlay with rotation not working correctly HOT 2
- KMZ overlays not aligning same as seen in Google Earth HOT 3
- gpxx extensions without namespace HOT 1
- Reason for not mapping all found TrackPointExtensions, and only keeping one? HOT 2
- Github sponsoring HOT 1
- gpx() and kml() types aren't symmetric HOT 2
- This should complain if the input is not valid XML or valid KML HOT 1
- Unable to use ESM import HOT 5
- Translate TCX courses to folders
- Translate GPX trk elements to Folders
- Keep KML placemarks with missing coordinates HOT 4
- Folder data HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from togeojson.