importing EE javascript api into another javascript script--and not through html
See original GitHub issueHey Folks.
This is really more a question than an issue, but I though others might benefit. The javascript demos posted all have the js “application” accessing/importing the EE javascript api through the script tag
<script src="/static/ee_api_js.js"></script>
. I was wondering how to import this ee_api_js.js
file directly into a javascript script–and avoiding the html? I did not see any demos that did that.
So say I want to execute the code below to download a url without going through html.
var mymod = require('/../javascript/ee_api_js');
var image = mymod.Image('srtm90_v4');
var path = image.getDownloadURL({
'scale': 30,
'crs': 'EPSG:4326',
'region': '[[-120, 35], [-119, 35], [-119, 34], [-120, 34]]'
});
print(path);
But I get an error:
var image = mymod.Image('srtm90_v4');
^
TypeError: mymod.Image is not a function
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How do I include a JavaScript file in another JavaScript file?
You simply have to write import cond from 'cond.js'; to load a macro named cond from a file cond.js . So you don't...
Read more >How to include a JavaScript file in another JavaScript file?
Takeaway: An ES6 module is a JS file that can export its code to share with other files and import and use code...
Read more >How to import JavaScript files (import JS File into other JS File)
Import a JavaScript into another with import / export. Professional JavaScript Course: ...
Read more >How to include a JavaScript file in another JavaScript file
In this module, we define exported functions in one file and import them in another example. There are two popular ways to call...
Read more >Using JavaScript with Eclipse - Tutorial - Vogella.com
JavaScripts in the header is be executed when other JavaScript functions in the HTML body call them. 2. Getting Eclipse IDE for JavaScript...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For Node.js applications, you can try ee-runner. However, it mainly targets server-side and command-line apps and not web apps. For web apps, require() is still a relatively new feature, it may be better to still merge everything using something like Rollup or Webpack, to make sure it works with legacy browsers.
The Earth Engine JS library is now available on NPM. See: