Google Earth Engine API with Angular problem

260 views
Skip to first unread message

george popescu

unread,
Jul 19, 2019, 2:26:37 AM7/19/19
to Angular and AngularJS discussion
If somebody worked with Google Earth Engine API into Angular please help me with this error: Cannot use 'in' operator to search for 'Filter' in undefined
This is code:

public googleEarthEngine() {
// Load client library.
const ee = require('@google/earthengine');

// Initialize client library.
const initialize = function () {
ee.initialize(null, null, () => {
createMap();
}, (e) => {
console.error('Initialization error: ' + e);
});
};

// Authenticate using an OAuth pop-up.
ee.data.authenticateViaOauth('Api code', initialize, (e) => {
console.error('Authentication error: ' + e);
}, null, () => {
ee.data.authenticateViaPopup(initialize);
});


function createMap() {
// Initialize map.
const mapEl = document.querySelector('#earthmap');
const map = new google.maps.Map(mapEl, {
center: new google.maps.LatLng(39.8282, -98.5795),
zoom: 5
});

// Load EE image.
const image = ee.Image('srtm90_v4');
image.getMap({ min: 0, max: 1000 }, ({ mapid, token }) => {

// Create Google Maps overlay.
const mapType = new google.maps.ImageMapType({
getTileUrl: ({ x, y }, z) =>
`https://earthengine.googleapis.com/map/${mapid}/${z}/${x}/${y}?token=${token}`,
tileSize: new google.maps.Size(256, 256)
});

// Add the EE layer to the map.
map.overlayMapTypes.push(mapType);

});
}
}

Sander Elias

unread,
Jul 21, 2019, 12:07:09 AM7/21/19
to Angular and AngularJS discussion
Hi George,

The code provided here is not enough to find an answer. I suspect you are trying to use google earth before it finished loading. Make sure it's loaded before using it.

Regards
Sander

Deepak Jain

unread,
Jun 6, 2020, 2:04:37 PM6/6/20
to Angular and AngularJS discussion
Hey Sander,
I tried using AuthenticateViaPrivateKey() but it says "Use of private key authentication in the browser is insecure. Consider using OAuth, instead.". And, when I try this OAuth, it says same error.

Sander Elias

unread,
Jun 15, 2020, 1:10:48 AM6/15/20
to Angular and AngularJS discussion
Hi Deepak,

Make sure you are using the google authentication path that s setup up for usage in the browser, it sounds like you are trying to use server-side auth in your browser.

Regards
Sander

Sander Elias

unread,
Jun 15, 2020, 1:11:34 AM6/15/20
to Angular and AngularJS discussion
Reply all
Reply to author
Forward
0 new messages