sorry I am not much of a Javascript programmer so this is a rather noob question. But I was having trouble trying to import the Google Earth Engine api file into another javascript file. All of the examples in the Earth Engine repo use a <script src="/static/ee_api_js.js"></script>
in html to access the Earth Engine features, but I want to avoid using html.
I tried to follow standard Javascript procedures. Here is the code that I got.
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);
The error message I got back was:
var image = mymod.Image('srtm90_v4');
^
TypeError: mymod.Image is not a function
The original ee_api_js.js
file is located in the github repo at:
https://github.com/google/earthengine-api/tree/master/javascript/build
Not sure why this module is not importing correctly? Any ideas.
I suspect your life will be a lot easier if you alias that:
var ee = require('...').ee