How to get a Google Place using a placeId on Flutter? - google-maps

I'm trying to find a function that would allow me to get a Google Place only using a placeId (and the apiKey of course).
I found the function GeoDataClient.getPlaceById(placeId) but unfortunately this doesn't seem to be available on Flutter. I am currently using the flutter_google_places dart package but am open to using something different if necessary.

I can't find one. It seems like something of a large gap in the ecosystem -- if you store a Google Place ID in your local database, you should be able to convert that into a place name and a location when you reload it.
The iOS equivalent of GeoDataClient is the Places SDK for iOS: https://developers.google.com/places/ios-sdk/intro.
I may write a plugin for this and add it to pub.dev. Unless you've found a better solution since you posted this question, this seems like the best available approach at the moment.
With that said, however, connecting to the Google Places SDK requires a network connection, so if you want optimal performance, you should try to keep invocations of the SDK bridge to a bare minimum, and ideally keep place details in a local SQLite database. This way, users will only be invoking the SDK bridge after loading the app on a new device.

Related

Setting up Graphhopper (open source version)

I am looking for an alternative to the Google Directions API and run into Graphhopper, as I need to get matrices that provide the distances and travel times between a group of points given by coordinates.
I have installed the Graphhopper server in Java following these instructions, and it seems to be running fine.
As I need to send the requests using Python, I also installed the Python client as shown here. However, it asks for an API key and refers me to the Graphhopper website to get one.
How can I get the client to make a call to the machine where I have installed the server, instead of trying to reach the Graphhopper API? Is this possible? I have been going through the client files but haven't found any place to enter this information.
Thanks in advance!
For anybody in my same situation, I have found an answer. The Matrix API is not open source, so you need to get an API key regardless. Then, you can use the client code (like the one I linked to above) to send queries. The chart of features that are available via the open source code can be found here.
I hope that helps!

How to return from Google Maps App to my app?

From my app I'm calling Google Maps app using Intent and everything works well.
My question is:
how do I get back from Google Maps app to my app?
If I use the device "back" button then I need to press it 4-5 times!
Does anybody have a better solution?
Android does not give you control to the activities you launch. And since it mentioned nothing in the official documentation, it possibility means you can not.
One thing might help is it seems your application can check whether if the navigation is currently running. Look at this post for more information on that: Android application to detect when Google maps direction is finished
My solution is to create an AlarmManager right before you start the Maps Activity, save any variables in sharedPreferences and then let the Map Intent do what it has to do. After x time has passed(You decide how much time needs to pass before returning to your app) in the BroadcastReceiver open up your app in the activity that you want. Then load any needed variables that you stored in the sharedPreferences and done!
In essence it works like an alarm clock, you set the time and after x time you notify the user. I followed this tutorial(I used only the part I needed):
http://stacktips.com/tutorials/android/repeat-alarm-example-in-android

How to get the id of a chrome app from an extension

First a little background
I was tasked with creating a 'program' that would take screenshots of web pages at given times throughout the day and save the images to a folder accessible to the user. My original train of thought was to create an extension to do the job, but I soon realized that extensions don't have access to the file system, so I turned to chrome apps which can use the fileSystem API. However, chrome apps don't have access to the functions required to take a screenshot of the current page, thus I ended up creating both: the extension takes the screenshot and sends a blob of it to the app which saves it to the file system. The process is a bit convoluted but works like a charm.
Now, the app/extension communication occurs via chrome's Message Passing API. In order for communication to take place, I need to know the id of the extension or app beforehand. I've hard-coded the ids until now, but given that those ids will will change every time the extension or app is installed, I need a better approach.
Now The Question
Thus the question is: what is the recommended way to obtain the id of a chrome app from within a chrome extension and vice versa? The plan right now is to use the chrome.management API and do the following:
In Extension
var APP_NAME = "Name of My App";
var _appId;
...
function initializeAppId() {
// must declare the "management" permission in the manifest
chrome.management.getAll(function(result) {
for (var i=0; i<result.length; i++) {
if (result[i].name == APP_NAME) {
_appId = result[i].id;
}
}
});
}
Is this the way to go about it? I would still need to hard code the name of the app, but that's not nearly as tragic as hard coding its id. Also, packaged apps don't have access to the management api, so if I went this route, I would have to do it from the extension only. Once I get the app id, I can then send a message to the app and provide the extension id which can be easily obtained from within the extension code.
How does that sound? Any suggestions?
Thanks
Your approach is correct in the sense that it will work.
But chrome.management is a big hammer not particularly suited for the task.
You said that the IDs change. This only happens with unpacked versions, because they are not signed yet with a cryptographic key; Chrome has to assign something as an ID and it does it by hashing the path to the extension/app.
The solution is to either pack/sign the app once to obtain a suitable public key inside the CRX, or do the cryptography yourself as described here. When you specify the "key" property in the manifest, Chrome uses it to derive the ID and it stops changing.
After that, you can hard-code the ID.

Calling a Google Drive SDK from Google App Script application

i have been going around in circles here and have totally confused myself. I need some help.
I am (trying to) writing an application for a client that in concept is simple. he want a google write document with a button. the google drive account has several folders, each shared with several people. when he drops a new file in one of the folders, he wants to be able to open this write file, this file is the template for his email. he clicks the button, the system calls the changes service in the Google Drive SDK https://developers.google.com/drive/manage-changes, gets the list of files that have been added since the last time it was checked, then pull the list of people that the file has been shared with, and use the write file as a template to send that list of people an email saying their file is ready.
SO, easy enough, right?
I started by looking at the built in functions in the Google App Script API. I found this method, https://developers.google.com/apps-script/class_docslist#find in the DocsList class. problem is the description for the query simply says "the query string". So at first i tried the Drive SDK query parameters, which are
var files = DocsList.find("modifiedDate > 2012-12-20T12:00:00-08:00.");
it didn't work. that leads me to believe it is a simple full text search on the content. Thats not good enough.
That lead me into trying to call a Drive SDK method from within an App Script application. Great, we need an OLap 2 authentication. easy enough. found the objects in the script reference and hit my wall.
Client ID and Client Secret.
you see, when i create what this really is, a service account, the olap control in apps script doesn't know how to handle the encrypted json and pass it back and forth. Then when i tried to create and use an installed applications key, i get authentication errors because the controls again, don't know what to do with the workflow. and finally, when i try to create a web app key, i can't because i don't have the site host name or redirect URI. And i can't use the application key ability because since im working with files OLap 2 is required.
i used the anonymous olap for a while, but hit the limit of anonymous calls per day in the effort of trying to figure out the code a bit, thats not going to work because the guy is going to be pushing this button constantly thru the day.
i have been pounding my head on the desk over this for 5 hours now. i need some help here, can anyone give me a direction to go?
PS, yes, i know i can use the database controls and load the entire list of files into memory and compare it to the list of files in the database. problem being, we are talking tens of thousands of files. bad idea.
I wouldn't use DocsList anymore - DriveApp is supposed to be a more reliable replacement. Some of the commands have changed, so instead of find, use searchFiles. This should work more effectively (they even use a query like yours as an example).

Incorporate Google Drive solution in existing Android app project?

I have an existing Android app project which has been already published on the Google Play, and now I would like to incorporate in my app the possibility to use the Google Drive possibilities in order to download *.jpg files directly to the sd card when the app is opened or load for the first time. Like this I liberate the internal memories of the phones where this app is installed (All the images are stored in the resources of the app actually which is >~ 20MB). I have read a lot of forums concerning the Google Drive SDK or API subjects and I can say that I'm a little bit lost on the manner to manage it for my present app. Some ideas or suggestions would be very very very appreciated.
Thank you very much).
Please see this question for the basics on how to integrate your Android app with Google Drive SDK: Access to Google Drive from self implemented Android application
In it, I reference a good Google+ tutorial on how to get started, and it's easy enough to take the concepts and apply them to an existing app. (That's how I did it too.) Before you get started, sign up for the Google APIs (https://code.google.com/apis/console/), get into the API Console, and turn on both the Google Drive API and Drive SDK. This'll make coding go a lot smoother. Let me know if you have any problems.
One addendum for your specific case relating to *.jpg files is you could set a MIME type for fetching strictly the pictures. It'd go something like this:
request = service.files().list(); // .setQ("mimeType=\"text/plain\"");
Unfortunately setQ is commented out because it would fail to return any results when I used it. However, you may have better luck with the image/jpeg MIME type.