Can't run Code Playground example from local file - google-maps

This is the Map/Earth Integration example at Google's 'Code Playground' site:
https://code.google.com/apis/ajax/playground/#maps/earth_integration
I can run that example from the playground just fine. But if I save its html locally and then try to load that file in Chrome, the browser just stalls indefinitely with:
Installed Plugin Version: Loading...
An Android app of mine that attempts to load the same example into a WebView does the same thing. That app works fine when running html that employs the API V3 javascript.
The Chrome browser's Developer Tools debugger stops on line 15:
"google.load("maps", "2.x");"
saying that "google" is not defined. It also reports that 'GMap2' (line 18) and
"GET file://www.google.com/jsapi?key=ABQetc" (line 10) are also not defined.
The Map/Earth Integration example html includes a (long) jsapi key. Do I need to get my own jsapi key maybe? Where do I get one? I have a v2.API_KEY from:
"https://console.developers.google.com/project/apps~elite-rider-459/apiui/credential"
but I'm not sure if it will work with Google Earth and Google Earth is not among the available choices at the "APIs % auth" page at that console website:
I remember reading that Google Earth no longer requires such a key. Can anyone tell me
what I'm missing? And how to stop Google Earth from embedding itself in my desktop? I tried removing and reinstalling the plug-in, but GE continues to do so.
Thanks,
Ted

When you run this example from local filesystem you must prepend the http: -protocol to the <script/>-src , otherwise the browser will try to load the API from your filesystem(what of course will fail)

When I ran "Marker V3" code example in Google's Code Playground under "Maps V3" section, on local file, the code didn't execute. I had to add "http:" to script tag that loads Google maps in order to run the code locally.

Related

Google Chrome Translate Page Does Not Work

In Google Chrome, Translate to English (or any other language) function was working fine, but all of the sudden it stopped working.
By looking at the console, I see error messages when the page tries to translate:
Failed to load resource: the server responded with a status of 403 () https://translate.googleapis.com/translate_a/t?anno=3&client=te_lib&format=html&v=1.0&key=no&logld=vTE_20170619_02&sl=da&tl=en&tc=1&tk=927511.556110&mode=1
I tried completely uninstalling Google Chrome and installing it again but it still does not work, it also does not work in Incognito Window.
It works fine in other machines, any ideas?
It looks like that you don't have the api key:
key=no
Look at environment variables to see if GOOGLE_API_KEY is set to no and delete it.
For now, I would just translate pages the long way.
I.E.:
Going to https://translate.google.com and typing your address in the input box, and going to address produced in the output box.
If you want to continue our discussion from the comments, I have created a chat for us to keep talking about your issue.

Can't get Hello world example to work as a web-app

I am a total newbie to google-apps-script, but I can't believe the problem I'm having. I can't even get the Hello World! example to work as a web-app.
I have copied and pasted code from google's documentation website, and I still can't get it to work. (I tried more complicated stuff first, but then I started trying simpler and simpler code until I bottomed out with the below problem.)
When I publish the following code as a web-app:
function doGet() {
return ContentService.createTextOutput('Hello, world!');
}
Instead of seeing "Hello, world!" in the browser, I get the following error message:
The script completed but did not return anything.
I'm really at a loss here. I don't know how to try anything simpler, and again, the code snippet above was copied and pasted directly from the Content Service documentation page (https://developers.google.com/apps-script/reference/content/).
Any help with this problem is greatly appreciated.
Thanks in advance.
Thanks for the response Alan.
I created a new project and pasted the Hello world code into it, and it worked. I'll just work from this new project going forward.
...
Now that I have a few more minutes of experience, I think my problem was with version control. I thought that when I made a change in my code and updated the current version, then the current version published as a web app would reflect this change in my code. However, it seems that you have to create a new version of your code in order for your newly-published web-app to reflect the most recent changes in your code. My problem was that I was not creating new versions as I changed my code, so I kept accessing the old code which was always the same as when that version was first created.
(Using the Test web app for your latest code link (located in the Deploy as web app dialog which is accessed from the Publish menu) did reflect my most recent changes, but this was not adequate for my testing purposes since I was sending arguments to my web app url. (The latest code link only calls your web app with a read-only version of your web app url that has no arguments appended to it.) In order to properly test the web app with all arguments appended to the url, I needed to re-publish the new code under a different version number in order for those changes to be reflected in the web app that was published. Only then I could access this url that pointed to my latest code with all of my arguments appended.)
Again, just hitting the Update button in the Deploy as Web App dialog without specifying a new version does not actually update the current version with your new code. In order for your latest/newest code to be deployed you have to create a new version of your code that will reflect your latest changes. In order to create a new version, you first have to choose Manage versions... from the File menu and then save a new version that reflects your most recent code changes by hitting the Save New Version button. Once you have done this, you can choose to publish this new version in the Deploy as Web App dialog. The url for your web app will then access whichever version of your code that you last deployed/published.
I know that everyone on here probably already knows this, but I thought I'd clarify what my problem was (problem understanding the work-flow of the code-publish cycle) in case any newbie in the future also runs into this problem.
<<<<<UPDATE>>>>>
See the answer from Serge below about how to use the dev version of your web app url with parameters appended to it. In many cases, this can alleviate the need to create new (exec) versions of your web app as I described above if/when you are making only incremental changes to your code.
In order to get hold of your dev url in the browser address bar so you can copy it for further use (instead of getting the script.googleusercontent.com... url that is used to temporarily serve the content/output of your web app) just call an undefined function in your web app code. Then use the Test web app for your latest code link to call the dev version of your web app. This will cause an error page to be returned, and your dev url will then be available for copying in the browser address bar.
Following these steps I was able to get the Hello World Script to run:
Go to script.google.com
Paste your above code into the script area.
Save as Hello World.
Publish as version 1.0.
Go to the url it generates and "Hello, world!" is now displayed.
You can now also test the web app with the latest code when publishing.
Your statement that the .dev url is not able to support parameters is not exactly true (The latest code link only calls your web app with a read-only version of your web app url that has no arguments appended to it). Actually it does just like the exec one but you can only call this url directly from the browser (and not from another app) because only you can access the app using this special url.
demo code :
function doGet(e) {
var valToReturn = ContentService.createTextOutput('the parameter was '+e.parameter.val).setMimeType(ContentService.MimeType.TEXT);
return valToReturn;
}
The test .dev url with parameters goes like this :
https://script.google.com/macros/s/AKfycb___vWxs/dev?val='test'
and the return you get in your Browser is :

ChromeCast: Chrome sample project not running

I am following the setup instructions here: https://github.com/googlecast/CastHelloText-chrome step by step.
I have my Google Drive hosting folder here: https://drive.google.com/folderview?id=0ByI6ac75SrewSE1odEdBMm1fNk0&usp=sharing
I set my URL (for my application in the developer console) to https://googledrive.com/host/0ByI6ac75SrewSE1odEdBMm1fNk0/receiver.html
However, when I run my chromehellotext: https://googledrive.com/host/0ByI6ac75SrewSE1odEdBMm1fNk0/chromehellotext.html
I get this error in the console: "onError: {"code":"session_error","description":"NOT_FOUND","details":null}" and my Chromecast will not connect when I hit the carriage return and select my Chromecast.
What am I doing wrong?
Checking the box for sending the serial number to google solved this problem for me as well. It took me a few minutes to figure out where this box is so that I could check it. I had to download the chromecast setup application and then let it discover my device, select it, and click settings. The checkbox is in the settings.
It can take up to 6 hours to publish your receiver app. As the docs suggest, all you need to do is restart your Chromecast to force the device to reload it's configuration data. I was having this same issue and a restart was all I needed.
Make sure your receiver app is loading the cast_receiver.js javascript file as well as starting an instance of the castReceiverManager.
I was seeing that same timeout message before I did that. My initial receiver code was just static HTML, but apparently that's not good enough.
The following, in my receiver's index.html did the trick for me:
<script src="//www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js"></script>
<script>
window.castReceiverManager = cast.receiver.CastReceiverManager.getInstance();
window.castReceiverManager.start();
</script>
(copied from https://developers.google.com/cast/docs/custom_receiver)

Automate Chrome console from Desktop app?

I'd like to be able to send info to the Chrome developer console from my application.
For example, my app has some json. I'd like this json to show up in either an existing, or newly created instance of the chrome dev tools console.
Is this possible? If so, any pointers to examples? Note that the platform should be any language, not just javascript. And definitely not a site already running in Chrome. I'm interested in implementing this in another process.
Do you thought of running your app in an environment which is pretty much like a browser?
Node.js
or (this is a whole webkit browser)
phantom.js
Otherwise you could call Chrome directly via commandline and try to simulate the dev tools key stroke like explained here:
Is there a command line argument in Chrome to start the developer tools on startup?
The command of displaying something in the Chrome console is e.g. console.log and it is at the end Javascript. All Console commands are described here:
https://developers.google.com/chrome-developer-tools/docs/console-api
The closest I've seen so far is this library:
https://github.com/ccampbell/chromelogger
which seems to allow logging to the Chrome Console from lots of other server side apis, but no desktop APIs.
This can be done on Mac using osascript. Save the following as a script and run it:
#!/usr/bin/osascript -l JavaScript
var chrome = Application('Google Chrome');
//chrome.activate();
chrome.includeStandardAdditions = true;
var currentTab = chrome.windows[0].activeTab()
currentTab.execute({javascript: 'console.log("Hello")'})

Chrome Inline Install for extension not working

I'm trying to use the new chrome inline install feature for extensions (see here: http://code.google.com/chrome/webstore/docs/inline_installation.html).
I can't get it to work unfortunately, and have very little clues to go by. I've added the link element to the head element
<link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/pnnfemgpilpdaojpnkjdgfgbnnjojfik">
and I call
chrome.webstore.install();
in a jquery event handler. I've also verified my domain, however, I'm testing this on a local machine but have a subdomain pointed to my localhost (i.e. testing on dev.getbentobox.com which is mapped to localhost in my hosts file if that makes a difference).
When stepping through my js using the chrome debugger, chrome.webstore.install() is getting called and the function is defined. However, nothing happens - no install, no javascript exception, no console printing, nothing.
any ideas?
Your Chrome Web Store item doesn't show the verified site. If you compare it to the "We Heart It" extension, which can be inline installed from http://weheartit.com/heart-button, it has a green check saying "from weheartit.com". You'll need to edit your Web Store item, and associate your verified site with the item.
As of December 2018 (Chrome version 71), Google has disabled this feature. The workaround is to send the user to your extension in the Chrome Web Store.
Source: https://developer.chrome.com/extensions/inline_faq#change_dec18
What will change in M71 (Dec 2018)?
Beginning in M71, Chrome will no longer support the chrome.webstore.install() method and calling it will fail, resulting in a broken installation flow on your site. At this point calls to the API will throw a JavaScript TypeError. You should remove any calls to the API method before this date.