I am new to the whole google app script and i might be missing something essential if so please forgive me.
Use Case:
I have a google map with POI on it gotten from my gps. The issue with these points is that they are all based on long and lati. By itself this works perfectly in google maps. But as we share this map with other people it sometimes provide a issue as they need a physical address.
So I was thinking that if i could pull out all the POI on the map and use the reverseGeocode I could create a spreadsheet with the name of the POI and the physical address and even the long and lati of the point.
But I just can't seem to find a way to get that data out of the map. Where I could use the DocumentApp.openById() or Spreadhseet .... there does not seem a way to actually get the maps loaded in.
If their is another way or if I am approaching this the wrong way please advice.
If you want to get some data from an API not supported by Apps Script, you can use the Class UrlFetchApp. You need just to pass the URL as a parameter in the fetch(url) method or if you want to pass some advanced parameters, you can pass them as a JSON object in a second argument, defining it like fetch(url, params).
Related
I am wondering if there is a simple way to convert a shortened google maps link into its equivalent coordinates, inside of google sheets. For example a point near the Eiffel Tower:
Coordinates: 48.857469, 2.295821
Long URL: https://www.google.com/maps/search/?api=1&query=48.857469,2.295821
Short URL: https://goo.gl/maps/fxgX5rM1snM2
My Problem:
I have a spreadsheet of locations that were shared to me using the 'share' button inside of google maps, which automatically shortens the url. I am wondering if there is a way to un-shorten the url so that I can extract the coordinates for further use.
My Attempt:
This question was asked, and a solution below shows how this can be done using Python. I would like to do this using Google Apps Script, and potentially any existing APIs that can work with URLs. I am unfamiliar with .gs code, and any tricks to using them.
UPDATE: I have followed this setup tutorial and my script is associated with my Google API project.
My questions:
This seems like a simple thing to do. Is it?
If it is simple and someone can write the code quickly that would be a great help. I will go back and understand the code myself.
You can do this in javascript.
In Google Scripts you can implement the method used in the other question you referenced. Google Scripts provides URLFetchApp. In a vanilla JS context you would use the fetch api or XMLHttpRequest.
Since you are following a redirect you can provide an options object to PREVENT following the redirect.
var response = URLFetchApp(url, {followRedirects: false});
Then you can find the redirect URL in the response Location header. The header is encoded so you can use decodeURIComponent to work with the URL.
var longUrl = decodeURIComponent(response.getHeaders()['Location']);
From there you can use the RegExp from the second question you referenced to get the relevant portion:
var matches = longUrl.match(/#([0-9]?[0-9]\.[0-9]*),([0-9]?[0-9]\.[0-9]*)/);
You'll want to check the response status code and handle any errors in case the URL doesn't work or is not a redirect.
I have the Place Id of a place on google maps in my app. Is there a way to put the place Id in a URL and have it directly link to the page? Or does it have to be done through the URL?
I can't seem to find anything detailing this in the docs. I've tried below, but it just gets me the standard google maps page:
https://maps.google.com/maps?placeid=ChIJN1t_tDeuEmsRUsoyG83frY4
Recently, in May 2017, Google launched the new Google Maps URLs API. You can read about this API in the official documentation
https://developers.google.com/maps/documentation/urls/guide
So, from now on you can construct a URL for Google Maps using the place ID. In your particular case this URL will be
https://www.google.com/maps/search/?api=1&query=Google&query_place_id=ChIJN1t_tDeuEmsRUsoyG83frY4
Hope this helps!
Not directly, using the placeID you can get a variety of information in JSON or XML format, among them there are also the lat lng of the place and its address with which you can easily locate the map
google developer doc
The URL for a specific Google Place is returned by the places details API endpoint.
If for example you query:
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJV2BQ4laeekgRFauLvdXbFXE&key=YOUR_API_KEY
You will see that in the returned JSON there is a key 'url' which points to https://maps.google.com/?cid=8148660811851344661
The correct format, at this time, to produce a general link that goes directly to correct google place is: https://maps.google.com/?cid=[place_id]&t=[maptype]
The map type parameter "t" is apparently necessary. Without it, google maps seems to perform a more general search when the link opens that is sometimes successful and sometimes not. With it, maps opens to correct place each time whether it opens in browser or in app on mobile.
Set this parameter to "m" for a street map and "k" for a satellite map.
A lot of answers on SO show the following syntax which often pulls unwanted results if two locations of the same name are nearby e.g.:
https://www.google.com/maps/place/Starbucks/#43.088554,-88.06579,17z/
If you are already using google places api, then you have the place_id, so i recommend using it to avoid ambiguity.
I would like to create a Map by the excel sheet values (.csv files too).
By using FusionTableLayer API, I think it is possible. At first step we could upload the excel values to the database. Then we create a map by the database annotated value. It is very good idea. This is what I wanted. But One thing is problem to me with FusionTableLayer API is google's Drive has been pointed for the fusion table. It means that all my business data will be shared with google. I don't want to be like that.
Instead of Google's drive My database has to be pointed out. From my database I would like to create a map with FusionTableLayer API. I have been searching through internet, I dont find this is possible. But I believe that it is possible. Please guile me to specify the way to trigger it out ?
Regards,
ArunRaj.
If you want to use your own database, then you cannot use the Fusion Table API as it's meant for the Google Infrastructure. You will have to find another API to take care of this.
One workaround I can suggest to you is to parse points you have as drawing objects for your map. So for each point, create new google.maps.Marker with the respective coordinates. Each region can be denoted with google.maps.Polygon, and lines with google.maps.Polyline. There's plenty more you can do, but it's just a bit more work, and possibly less secure depending on your implementation. Furthermore, you can also add info windows to each of those areas using the Google Maps API by attaching respective listeners to those objects created.
Hope this helps!
I want to use Google Maps API with Processing. Until now I was just able to get Google Places data, but I'm struggling with the map itself. I know about other map options, like unfold or modestMaps, but I need Google. In particular because of the directions API in further progress. I've searched this forum and the web, without any help. I thought it should be quite
easy.
How can I use Google Maps with Processing?
I'm not sure about getting a full featured, dynamic Google Maps within your Processing app, but you might be able to modify the Processing library for the Google Weather API to instead use the Directions or Static Maps APIs. http://www.onformative.com/lab/google-weather-library-for-processing/
If you download the source and check out GoogleWeather.java you can see the constructor is calling the WeatherAPI and getting back the XML result. I think you could do the same thing except use the Directions API in it's place.
Here's a post on a Java blog about showing Static Maps API results in Java, which might be translatable into Processing: http://weblogs.java.net/blog/cajo/archive/2010/10/16/adding-google-maps-your-java-application
For something more dynamic, you might be able to adapt JXMapViewer, check out this article: http://today.java.net/pub/a/today/2007/10/30/building-maps-into-swing-app-with-jxmapviewer.html
Is it possible to call Google Maps API using a C++ code to retrieve text info about nearby locations.
I am trying to make a simple application (C++) which gives the information about Nearby places on entering longitude and latitude info. Only data I am looking for is the Name of Nearby place and its distance from mentioned location.
Is it possible?
I think your best option would be to use the Google Places API with the JSON format for request.
I don't know about any library that would perform the thing automatically, but there is a thread on StackOverflow about JSON parsing in C++ . Even it does not provide an answer it as good votes scores.
I guess the web call could be made with something like curl.