Google My Maps - API - google-maps

Is there any way to add Layers, Points, Directions or any data to a map in the Google My Maps, using API?
I have searched in Google but didn't find a solution to do this.

Currently there is no any API to access MyMaps programmatically.
I can see a feature request for this in the public issue tracker:
https://issuetracker.google.com/issues/35820262
It looks like Google is evaluating the feasibility to implement the API, however, no timeline provided at the moment.
Please star this feature request to express your interest and receive further updates.
UPDATE
As of April 2018 it looks like Google decided do not implement the API for Google MyMaps and marked the aforementioned feature request as Infeasible.

This is not a fantastic solution — and it does not use the API — but it might fit your needs. Instead of using the API you could write a browser console script that adds each new item. You could probably even run this through a headless browser and remove any manual interaction altogether.
eg.
fetch('https://example.com/newLocations')
.then((response) => response.json())
.then((newLocations) => {
newLocations.forEach(location => {
document.querySelector("#mapsprosearch-field").value = location.name + ", " + location.city;
document.querySelector("#mapsprosearch-button > div").click();
document.querySelector("#addtomap-button").click();
// etc.
});
});
—
UPDATE
Re-opened as of Feb 2021 — API support for this has been assigned. So hopefully we get support soon!
https://issuetracker.google.com/issues/35820262

Related

YouTube Analytics and Reporting API with Google Apps Script

I'm trying to use the YouTube Analytics and Reporting API with Google Apps Script to populate a Google Sheet with analytics data from YouTube brand accounts that I own and manage.
As a preface, I have tried this on YouTube channels that I own and channels that I manage and nothing has worked. I have also taken a look at all of the Stack Overflow questions & responses related to this for the past few days and nothing has worked. Believe me when I say I have tried everything. I do not believe the code or the way I set things up is the issue; I believe it has to do with Google or the YouTube API itself.
Here are the steps I have taken:
Enable the YouTube Analytics API and YouTube Data API in Google Apps Script. (The YouTube Reporting API is nowhere to be found which may be the issue...)
Enable the same APIs in Google Developer Console (The YouTube Reporting API is available there)
Set up a Client ID & Secret and linked my project to the Apps Script
Verified that my code indeed works by inputting the same exact parameters (metrics, dimensions, etc.) in the YouTube Analytics and Reporting API Explorer in Google Developer Console. When I do this, the explorer does indeed export the right information. However, in Google Apps Script, it does not work at all.
Due to the fact that the code works in the Explorer, but not in Google Apps Script, I believe that there's something simple that I'm doing wrong, or it's an error on the Google side. I'm hoping that there's a way around this or a fix, because I'd really like to get the data from my YouTube channels into Google Sheets.
Google Apps Script code (shortened for simplicity. The "key" property may not be necessary, but it doesn't work without it either).
function myFunction() {
var metrics = [
'averageViewDuration'
];
var oneMonthInMillis = 1000 * 60 * 60 * 24 * 30;
var today = new Date();
var lastMonth = new Date(today.getTime() - oneMonthInMillis);
var report = YouTubeAnalytics.Reports.query({
ids: 'channel==MINE',
startDate: formatDateString(lastMonth),
endDate: formatDateString(today),
metrics: metrics.join(','),
dimensions: 'day',
sort: 'day',
includeHistoricalChannelData: false,
key: "AIzaSyAcVb-hriIydRs8iVqFZ6ZoyL8En3qLcnc",
});
Logger.log(report);
}
When I run the code, there is zero output to the logger. I expect there to be something there.
As a reminder, this happens when I select any account besides my core account. When I select the core account attached to the account (that does not have a YouTube channel), it does output this:
"[19-10-30 17:58:19:251 PDT] {columnHeaders=[{columnType=DIMENSION,
dataType=STRING, name=day}, {columnType=METRIC, dataType=INTEGER,
name=averageViewDuration}], kind=youtubeAnalytics#resultTable,
rows=[[2019-09-30, 0], [2019-10-01, 0], [2019-10-02, 0], [2019-10-03,
0], [2019-10-04, 0], [2019-10-05, 0], [2019-10-06, 0], [2019-10-07,
0], [2019-10-08, 0]...]]}"
There's no reason that it shouldn't be working. What do you think is the issue?
Sorry, but currently what you would want to do, it's not supported by Apps Script. It was already reported in Google Issue tracker, as you can see in the next links:
Youtube Data api v3 can not authenticate by brand account in gas
The YouTube API Will Not Authorize a Google+ Page's YouTube Channel
YouTube.Videos.update throws Forbidden exception for any video on secondary channel
As a workaround, you can implement Oauth2.0 as it is said in this Stack Overflow's post
Edit
If you are having troubles using the refresh token, Use this code to make the request directly to the Youtube API after obtaining an access token from Oauth2.0 playground
function makeRequest() {
var response = UrlFetchApp.fetch('https://youtubeanalytics.googleapis.com/v2/reports?endDate=2019-10-10&ids=channel%3D%3DMINE&metrics=views&startDate=2019-10-09', {
headers: {
// you will get the access token from Oauth2.0 playground
Authorization: 'Bearer ACCES_TOKEN'
}
});
Logger.log(response)
}
From The YouTube API Will Not Authorize a Google+ Page's YouTube Channel, it says
The engineering team has decided that it's not possible to support
this use case. You'll need to use something other than the YouTube
advanced service to access a channel owned by a G+ page.
So, it seems there is no support for what you want

Google geocode API doesn't recognise some zipcodes

I am using google geocode+geolocation APIs for finding places and calculating distances between them.
There are some zip codes which actually exist when we search them on Google but google APIs are unable to locate them.
Here is one in the link: 01703
Response is
{
"results" : [],
"status" : "ZERO_RESULTS"
}
How can I overcome this issue (with Google API) or is there a way to contact google support directly? Or if there is any other service which has better results?
Please help me to solve this. Waiting for response. Thanks
The Google maps api reads directly from Google maps itself. If there is data missing then it can be added Report an error on the map
If it is on the map and just not in the API then they may be in the process of approving the change.
Beyond that you could report it as a bug issue tracker or try to contact the support team
Normally there isnt much you can do if there is no data in the api for your request there is no data. For the most part Google services are free "you get what you pay for".
I am a developer at SmartyStreets, and have worked a lot with our US ZIP Code API. I ran the ZIP Code 01703 through it, and got back the geocodes no problem. You can try it out for free if you're interested.

Is it possible to get live traffic layer data from android google api?

I am trying to get the live traffic data for a point(provided lat & long), is there any Google Maps API service which can provide me the Google Maps traffic layer data for a specified point?
Hello #R AaHul Dutta,
Thanks for inquiring about this feature and for helping to keep this conversation alive. At the moment, the google.maps.TrafficLayer class does not support Typical data since the class is defaulted to autoRefresh: true.
You could help the community by showing support in the Google Public Issue Tracker's existing feature request. Feel free to show us your support for new features and don't forget to follow our blog for feature roll-outs, and bug fixes as new versions of the Google Maps JS API roll-out.

Google Places Autocomplete API Consumption

I'm using google maps API on my company, and we're facing some issues with the consumption of the API.
We use the Javascript API, loading the map, and we geocode some address and make some routes. Everything normal.
But we use the Autocomplete in some cases, to allow the user to input the location he's searching.
So, I define the autocomplete like this:
var autocomplete = new google.maps.places.Autocomplete(
document.getElementById('textBox'),
{ types: [] });
When the user select an option, we call the function
autocomplete.addListener('place_changed', doSomething);
get the place and do more things
function doSomething() { var place =
autocomplete.getPlace();
//more code }
Everything works fine, but when the user start typing, it's been consuming the Google Places API Web Service. Is it right?
I thought it would only consume the Javascript API when we loads the map, and that's it.
And the weird thing is that, on the developer's console, the utilization of the API started few days ago (30/06/2016), and we have a gap of no utilization of this API (between 3th and 10th of July), and yesterday we reach the limit of 1000 uses.
Am I doing something wrong? What can I do?
Sorry if this is not the right place for the question, and if it's not, move it or tell me so I can open in the new place.
Thanks
You can find an answer in this blog post:
http://googlegeodevelopers.blogspot.com.es/2016/06/building-for-scale-updates-to-google.html
Look at 4. Starting from June 22, 2016 Google counts client-side requests against the corresponding web service APIs. Apparently, some of your domains were "grandfathered", but the new ones will follow the new policy.

Is it possible to get Google Maps Directions using HTTP requests?

Is it possible to use the Google Maps API router just using HTTP? Something like http://maps.google.com?from=blah?to=blah
And have it return some sort of XML or JSON representing the directions?
If you want Google to allow legal access to driving directions via HTTP you might consider voting for the enhancement request: Issue 235. Theoretically, the more people that vote for an enhancement request, the more attention Google give to it.
However, I strongly suspect that there might be contractual issues with the organisations that supply the data. Organisations like TeleAtlas impose restrictions about how Google can use their data. TeleAtlas probably don't want Google to make it legal for people to use their data to create apps for free that directly compete with their own commercial apps and devices.
There is no documented and approved method to access driving directions via an HTTP API request.
This makes it difficult to get driving directions on the server-side, which I assume is your intention.
Not only it is undocumented and difficult to achieve, but it would also violate the restrictions 10.1 and 10.5 of the Google Maps API Terms and Conditions.
However, if you don't mind the challenge, and you believe that rules are there to be broken, you may want to check these articles:
Calculate driving directions using PHP?
Retrieve driving directions from google maps with server-side HTTP calls and show results with static maps for WAP
Actually yes, and they do it themselves
The REST format is like:
http://maps.google.com/maps/nav?output=js&q=from:%20Montreal%20to:%20Toronto&key=apikey
Where q should have the form: "from: x to: y" (url encoded).
Some of the parameters are similar to the HTTP Geocoding service: http://code.google.com/apis/maps/documentation/geocoding/index.html
Mike
As of May, 2010, directions are available via web services:
http://code.google.com/apis/maps/documentation/directions/
Directions are returned in XML or JSON format:
http://maps.google.com/maps/api/directions/json?origin=Boston,MA&destination=Concord,MA&waypoints=Charlestown,MA|Lexington,MA&sensor=false
http://maps.google.com/maps/api/directions/xml?origin=Boston,MA&destination=Concord,MA&waypoints=Charlestown,MA|Lexington,MA&sensor=false
It's pretty danged easy to use.
Here you can find a list of parameters you can pass to the maps.google.com URL. Maybe you'll be able to get the information you need. I don't know what the returned output contains. At least you are able to define different output types.
I have already used this library with python and it works well, although it's against Google Maps API Terms.
API v3 (made the official version in the last six months), does:
http://code.google.com/apis/maps/documentation/directions/
Also note that most of the competing services (Bing Maps, Yahoo, MapQuest, CloudMade, etc) also support RESTful web services along these lines.
As always with these services, check the Terms & Conditions.
I've never used the API but it is pretty easy to get the structured directions data from a google maps page using JS to access the gmap page's DOM.