12

Is there a simpler way to embed a Google Earth Engine (javascript) application into a web page without following the tortured route presented by the Google EE demo apps?

The Earth Engine Code environment makes it quick and fast to develop the core GEE app. However, it's going to take me 10x the time to embed the GEE app into a web page than it took to do the GEE app.

All the demo apps seem to require (a) using Google App Engine, (b) recoding the GEE app in Python, (c) using jinja2 templating engine to link the python code to the web page, and (d) still some lingering javascript.

For example, in the Trendy Lights demo, the server-side scripter server.py App Engine kicks things off and it gets complicated quickly. (Even the simpler demos go this route.)

When the user first loads the application in their browser, their request is routed to the get() function in the MainHandler class by the framework we're using, webapp2.

The get() function sends back the main web page (from index.html) along with information the browser needs to render an Earth Engine map and the IDs of the polygons to show on the map. This information is injected into the index.html template through a templating engine called Jinja2, which puts information from the Python context into the HTML for the user's browser to receive.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
Biofloat
  • 377
  • 3
  • 10
  • 1
    Just commenting to see if you had found a solution to this? – NateH06 Jul 05 '17 at 08:10
  • 2
    Has anyone successfully launched their real-world Earth Engine app with Apps Engine yet? How much effort is it really? Maybe someone has an example link? – Joooeey Apr 28 '18 at 00:35
  • As of when I posted it, there were a number of demos running on the App Engine you can look at, such as the Trendy Lights demo hyperlinked in the original posting. – Biofloat Apr 29 '18 at 16:11

1 Answers1

4

The reason it's complicated is due to authorization. The Earth Engine calls have to be authorized against someone's Earth Engine account. That has to be either the end user (See: https://github.com/google/earthengine-api/tree/master/demos/client-auth, but that only works if the end user has an Earth Engine account), or the application's credentials. If the application's credentials were just stuck in the javascript, then anyone can steal those credentials and use them to do anything they wanted. So we recommend using the appengine server-auth route (https://github.com/google/earthengine-api/tree/master/demos/server-auth-nodejs) to keep your credentials safe.

eco-model
  • 13
  • 2
Noel Gorelick
  • 489
  • 2
  • 10
  • Is there some reason that the Google Maps credentials model isn't used? Example: we embed our credentials on the request for the Maps API in our Javascript (in plain sight) but it presumably can't trivially be exploited because we've also configured access restrictions such that any of these requests must originate from our domain. – JDischler Dec 11 '18 at 14:55
  • 1
    The difference is the how expensive the request is; a maps API request can't be too expensive, you're just requesting a tile and not accessing e.g.: drive, GCS, etc For EE, a single request can do an arbitrarily complex amount of analysis and could end up accessing and even modifying resources in a number of other services, some of which might be metered/billed. When that can happen, the requests have to carry full OAuth credentials. All that said, check out the new "earthengine apps" feature that launched a few months ago. EE will build the app for you with a button click. – Noel Gorelick Dec 13 '18 at 00:16
  • The link isn't available anymore. – poetyi Jan 03 '20 at 12:24