Implementing Google Maps API Key into Java Project using Vaadin - javascript

I have taken over a an ongoing project that is written in Java (something that I have no prior experience with, but I can code Python and C++) using Eclipse (which I am also new to). The project uses Vaadin components, and Eclipse runs it with glassfish which pops up a page in the browser with the results.
I have been successful in navigating myself around the code and made a few modifications, however one of them is a tiny Google Map with markers and I have having trouble displaying it. The previous owner has already set up a Google Maps API for it. When I run the code in Eclipse, the result appears with a link that starts with "localhost:8080..." which does not display the Google Map ("Oops something went wrong. This page didn't load Google Maps correctly. See the Javascript console for technical details."). The API become accessible to the component when I switch "localhost" with the IP of the computer, and the map displays.
I am trying to replace the API key of the previous owner of the project with one that I have just acquired here at Google Developers Console. While I have also searched and found many examples that are very similar to this one, I cannot locate any javacript files within the project via Eclipse that I can apply the solution with.
With the ultimate goal for this is to host the exported .war file on a server, any help on how to locate the link between the code and the API key is much appreciated.
Thanks

I suggest you use this semi-official addon instead of trying to roll your own. It allows you to give the API key directly in the component constructor.
You should check out the Vaadin add-on directory for other needs as well, it has hundreds of useful addons for many purposes.

Related

Problems using Ionic Native API and Javascript API in same app?

I'm making an app using Google Maps that makes use of BOTH the Ionic Native Google Maps API and the JavaScript version. Of course, the Native API is used on one page called home.ts, and the Javascript API on a sub page called details.ts which is reached by tapping on the infoWindow for a marker.
So far, this setup actually appears to work for me - but apparently I need to import "GoogleMaps" from #ionic-native/google-maps into both details.ts and home.ts for the map images to load on the main page - the markers and everything else will work fine.
Unfortunately, I need both APIs because Ionic Native does not yet support the use of the Google Places API. However, this seems to have led to at least one nasty issue so far -
On iOS, the app has a random chance of crashing/freezing when doing any sort of transition event, whether changing from page to another (the usual cause) or even just panning inside the map generated by details.ts. In XCode, when the crash occurs, the error I see in the console is something like this:
*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[2]
Of course, the number in objects[2] can be any number, as far as I can tell.
I haven't seen anything like this in the Android version of this app yet, but I have a hunch that it's there. I talked to someone who thinks that the app randomly attempts to use the wrong API, but I was hoping someone could provide a little more insight, and perhaps any other things that COULD go wrong with such a setup.
when you are working with ionic and google maps app most of cordova plugins have issues recommenced to follow google maps js docs or follow https://www.joshmorony.com/ionic-2-how-to-use-google-maps-geolocation-video-tutorial/

use of google script editor

Hey so currently working on my first personal project so bear with the questions!
Currently trying to create a Javascript program that will parse info from google forms to produce slides displaying the info. So far from my research the best way I've found to facilitate this process is googles app script editor. However, I was wondering if I can run this code by requesting it from a different javascript (or maybe even java) program that I will write code on webstorm. If I cant do this what is the best way to utilize the google apps script editor?
Thanks!
Google Apps Script is just javascript with extra built-in APIs (like SpreadsheetApp, FormApp, etc.).
It also has a UrlFetchApp API.
So you can run code like this:
// The code below logs the HTML code of the Google home page.
var response = UrlFetchApp.fetch("http://www.google.com/");
Logger.log(response.getContentText());
As such, if you want to provide JavaScript from elsewhere, you could fetch it and then eval it on the Google Apps Script side. (but we all know how tricky eval can get)
One other option is to have your own server side written using Google App Engine (or any other framework) and use Google's OAuth and authorize your app to fetch data from the Forms form
Slides and Google Apps Script
You might like to take a look at the addon "Slides Merge" by Bruce McPherson. I've never used it but it sounds like it might work for you. Here's what it's looks like in the addon store:
Getting information from Google Forms is a snap with google apps script since your can link the form right up to a spreadsheet. The Google Apps Script documentation is really quite good these days. Here's the documentation link. Google Apps Script is loosely based on Javascript 1.6. If your already a programmer my guess is that you'll have few problems learning to use it. In my experience the most difficult thing was dealing with the arrays of arrays produced by the getValues() method of ranges in google apps script and I made a short video that might be of some help to you.
I also have a script that I wrote in Google Apps Script that produces a sheet show that is a slide show inside of a spreadsheet.
I've found that using the Script Editor is pretty easy. There's some documentation in the support section of the documentation. It can be a bit buggy at times but overall I think it's a pretty good tool.

GAS: How to allow other people to use your library without sharing the code

How can I create a library in google app script in which I can share just the library key and people can use it, without sharing the code properly? I am trying hard to find a solution, but I failed.
I don't want to share the library for the world. I just want to use the library in different google drives, without having to share the code, but just the library/project key.
I found this link on stackoverflow that the guy had basically the same question as me, but it didn't has a good answer: How to share Spreadsheet with reference to a custom (private) library
Thanks in advance!
it is currently imposible with you requirement to end up "sharing a library key."
you must give at least read access to the library file for this case of running the script functions directly from the spreadsheet.
Once a script uses the library, and the user has view permission on the container script, a curious user could use the apps script debugger to "step into" a library function and there it is, the library source code.
If you were to instead publish the script as a web app, you could hide the library but that option does not apply in your case as you are making copies of the spreadsheet, and services do not get copied, need to be re-published.
Another option, but which does not give the library key in your requirement, is to publish an apps script service that uses the library and implements an API, which the other scripts (inside each spreadsheet copy) use. This however will not scale as quotas will be deducted from the API service publisher, and not the users that call the API.

Using Google Maps offline (Js Api)

I'm trying to make an NodeJs App in which, on web page I'm using Maps, For some reasons I've chosen Google Maps and I want to stick to it. My question is, Is there anyway where I can either store or cache map tiles offline and later on use it as needed [Note: Not looking for any hack or Illegal way for it, I already know there are many such ways].
I tried and saw many options like GEE (Google Earth Enterprise) portable but I guess they are shutting it down very soon i.e by 2017.
Basically what I'm trying here is to minimize the data usage on rendering map tiles, so alternatively, if there ain't a way to make google map work offline any suggestion or advice for minimizing data usage is appreciated.
The offline access via Maps JavaScript API is not available at the moment. There is a feature request in the public issue tracker:
https://issuetracker.google.com/issues/35827808
Please star this feature request to express your interest and receive further updates from Google.
1.Use Localstorage instead it might help but will be used in google chrome.
2.Check this url it might help How to cache Google map tiles for offline usage?

Is there a way to access the Google Data API from the Google Apps Script environment?

Google Apps Script is the javascript-based environment for running scripts on Google Documents, amongst other things. You can do things like copy data between spreadsheets and generate emails.
The Script API is a bit simplistic - although you can get the ID of an object, you cannot retrieve an object by ID, so it makes it difficult to track objects between two different Applications (such as Spreadsheet and Calendar).
However there are is a "Google Data API" javascript API that provides google.gdata.* - and I'm trying to work out how to use this from within the Google Apps Script environment.
My core problem is that I want to update existing Calendar Events (or create new ones if they don't exist) but tracking them purely by date/time is insufficient - I need to store the ID in the Spreadsheet and then use this to retrieve the Event later, because it may have moved (by other processes, including humans).
I'm not very experienced with Javascript but my understanding is that if I can somehow 'import' something called 'google' then I can call:
google.load("gdata", "1");
var service = new google.gdata.calendar.CalendarService(...);
But there's nothing called 'google' available as far as I can tell.
I've had no luck searching Google - just lots of unanswered similar questions - so hopefully someone here can tell me it definitely can't be done, so I can stop wondering.
Purely answering the last part of your question...
The google.load is Google's API Loader. You can load it as per the example:
<script type="text/javascript" src="https://www.google.com/jsapi?key=INSERT-YOUR-KEY"></script>

Categories

Resources