In my angular webapp I store the lat and lon of a position.
I need to send an email to a user with some information including a Google Maps with a mark in (lat, lon) and some style for the maps like the zoom.
How can I include a Google Maps in my email with a mark?
Thanks
In my previous project I had a similar requirement.
I made use of the google maps static API, which returns an IMG by request.
Static API Doc´s
Now you have to decide if you wish to save the IMG to the filesystem and send it then via email, or if you just the IMG string and use this for your email.
If you wish to do it without saving the IMG to the filesystem take a look here:
Embed Image in Mail
Otherwise it would be a normal email, how to do that is pretty good explained the Doc´s.
Good Luck!
Related
I'm working with the Trello API. I want to attach an image to a newly created card. I have no problem POSTing the new card and getting the card id to then PUT the attachment.
My project is made in Laravel 5.4 and I'm using Guzzle to make the HTTP requests.
The image I want to attach is from the Google static maps API and I'm using an encoded polyline (which I generate using this script) to draw a figure over some area.
This is how the card should look like:
But it ends up looking like this:
If I go to Trello and attach the image (as an URL) manually everything works perfectly but when I do it through a HTTP request it looks like the second image above.
After doing some research I think the problem resides in the polyline string because it usually contains some characters that HTTP does not support. I've tried using PHP's urlencode() without any result.
I send the image URL as an URL encoded param since that is the only way the Trello API accepts it (even though the official Trello API docs say otherwise).
Do you guys have any other ideas | work-arounds | experience with this issue?
I think you can try to use Google URL Shortener or similar service to convert the complicated URL with encoded polyline to something really simple.
For example, I have the following static maps URL with polyline
https://maps.googleapis.com/maps/api/staticmap?size=512x512&scale=2&maptype=terrain&style=feature:all&path=weight:3%7Ccolor:0xff0000ff%7Cgeodesic:true%7Cenc:}sp}Gmrkl#m#wIiAaB_BaA}IcCmLoFqG_DuFkAyN[mEiBqN}MqFsLqUoxAyG{#qGqJwDkBeJMod#lScMzFcFvAwHn#wH[oGwAwI{EwFqGaHwKcS{e#mKkd#iGsi#wKem#iKg[aPg[_N_RiE{EoUaR{f#}X}d#sWo[mN}]_KqYcDePyCcQaGeUuM{PoO_SsWcLeTiSsi#{Ka[yRgb#sN{S}RaS_XkRiX{OiO{GgMiEoc#aDwq#{Eig#qHyhAeQ{n#Nqj#uOqp#qTcZmNyZkUcRkSsIiL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ortener service and get this URL: goo.gl/iytwvS
So, I can use the latter as src of the image as shown in the following example
http://jsbin.com/quridub/edit?html,output
I hope this helps!
I am POSTing an HTML page to the OneNote REST API, to:
https://www.onenote.com/api/v1.0/pages
I am doing this from Google App engine (Java), and it all works fine, except that I am having problems with the static Google maps that are linked within the HTML.
Specifically a static map WITHOUT an encoded path is working and showing up fine, e.g.:
http://maps.googleapis.com/maps/api/staticmap?key=<KEY>&sensor=false&
center=<LAT,LON>&scale=1&zoom=17&markers=<LAT,LON>&size=150x150
However, when I post including an encoded polyline, the images doesn't show up on the OneNote page that is created (it looks a broken link on the page), e.g.:
http://maps.googleapis.com/maps/api/staticmap?sensor=false&size=150x150&
scale=1&path=enc:<PATH>&markers=<BLAH>&key=<KEY>
My first thought was that it wouldn't work because the google maps key can only be used from my own domain (although that wouldn't explain why the maps without encoded polylines worked already), so I added
https://www.onenote.com/*
to list of referrers. (I don't know that's the right referrer - just a guess based on the API URL). That didn't solve the problem.
Then I thought maybe it's because MS doesn't allow google maps on OneNote (or Google doesn't allow Google maps on OneNote). So I tried serving the google maps via my own website. That didn't work either. But what I could see from my server logs is that OneNote didn't even called the URL on my website of the maps with encoded polylines - which is weird!
The final idea I had is that maybe it's because the URL with encoded polyline is too long for the OneNote API to handle. So one thing I could try is to create short URLs to put in the HTML. Before I try that final step, thought I would ask for advice in case I am still headed the wrong way...
Thanks.
Edit: Here's an example of a URL that didn't work (excluding the key only):
http://maps.googleapis.com/maps/api/staticmap?sensor=false&size=150x150&scale=1&
path=enc:obblHzpwnVY?QEmBqA#qEzDT|JeAtD{Qn#yQhD_CMeIZ}BeCO#A#A?H
&markers=label:S|49.331765,-123.169574|&markers=label:F|49.328255,-123.158863&
key=<KEY>
Note that the key is approx 40 characters long
This appears to have been a length of URL problem. I tried serving the maps from my own website with a very short URL...
http://MY_DOMAIN/mapwrapper/SHORT_KEY
....and they worked fine.
I just had an idea to have a collaboratively worked-on public Google Drive document's contents displayed on my Web site. I was hoping this would be straightforward, as I am only going to extract simple text and the document is public, so no authentication shenanigans will bar my way.
I have looked at Google Drive REST API, but turns out I can only get file metadata and/or the entire document file. Not just the document content.
I do not wish to spend a day coding to do this, I thought it would be nice to have, but can live with just linking into the file directly from my Web site. Anyone tried this before? Anyone experimented with Google Drive API and has a feel for how much work would be involved?
If you are thinking of getting the content of a native Google document (like a Google spreadsheet or a Google doc), this is currently possible with the Drive API.
In the Drive API, for Google native document types you will have a series of 'exportLinks' as part of the metadata of the file. Each of these export URLs allow you to download the content of the Google document in a specific export format (like RTF, plain text, HTML, PDF etc...). Updating my answer...
See the documentation for this: https://developers.google.com/drive/manage-downloads#downloading_google_documents
I'm having some issue with static Google maps generation. The API has "a query limit of 1000 unique (different) image requests per viewer per day. Since this restriction is a quota per viewer, most developers should not need to worry about exceeding their quota".
However when using a shared connection, as instance with a mobile phone and a 3G access (phone operators), this limit seems to be problematic.
Hence my question is the following: can I retrieve the image server-side and serve it to my clients? Is it allowed?
This FAQ indicates not: Can I generate a map image using the Google Static Maps API which I store and serve from my website?
Text (as of November 2016):
Can I generate a map image using the Google Static Maps API which I store and serve from my website?
You may not store and serve copies of images generated using the Google Static Maps API from your website. All web pages that require static images must link the src attribute of an HTML img tag or the CSS background-image attribute of an HTML div tag directly to the Google Static Maps API so that all map images are displayed within the HTML content of the web page and served directly to end users by Google.
Actually, you can. Reference the Google Maps TOS:
3.2.4 Restrictions Against Misusing the Services.
(a) No Scraping. Customer will not extract, export, or scrape Google Maps Content for use outside the Services. For example, Customer will not:(i) pre-fetch, cache, index, or store Google Maps Content for more than 30 days; (ii) bulk download geocodes; or (iii) copy business names, addresses, or user reviews.
(Edit: Updated to reflect the latest terms as of June 2018.)
This is discussed in further detail in the "Sanity Checks" aspect of Google Static Maps Usage Limits.
As of Oct 21 2021, both ToS and FAQ are speaking the same language. Storing and serving copies of images generated using the Google Static Maps API from your website is not allowed.
ToS
3.2.3 Restrictions Against Misusing the Services.
(a) No Scraping. Customer will not export, extract, or otherwise scrape Google Maps Content for use outside the Services. For example, Customer will not: (i) pre-fetch, index, store, reshare, or rehost Google Maps Content outside the services; (ii) bulk download Google Maps tiles, Street View images, geocodes, directions, distance matrix results, roads information, places information, elevation values, and time zone details; (iii) copy and save business names, addresses, or user reviews; or (iv) use Google Maps Content with text-to-speech services.
FAQ
Can I generate a map image using the Maps Static API which I store and serve from my website?
You may not store and serve copies of images generated using the Maps Static API from your website. All web pages that require static images must link the src attribute of an HTML img tag or the CSS background-image attribute of an HTML div tag directly to the Maps Static API so that all map images are displayed within the HTML content of the web page and served directly to end users by Google.
I find the TOS pretty contradictory
Can I generate a map image using the Google Static Maps API which I store and serve from my website?
You may not store and serve copies of images generated using the
Google Static Maps API from your website. All web pages that require
static map images must link the src attribute of an HTML img tag or
the CSS background-image attribute of an HTML div tag directly to the
Google Static Maps API so that all map images are displayed within the
HTML content of the web page and served directly to end users by
Google.
https://developers.google.com/maps/faq?csw=1#usagelimits
In my meeting management application, I am trying to send the meeting location information via mail and in the mail content I would like to place a link to to the google map site, so that the meeting place could be seen on the map.
What would be the best way to construct the google map url string (eg. http://maps.google.com/maps?q=address) , for a particular address.
Thanks
Reducing the clutter of arguments to a minimum, this seems to work pretty well:
http://maps.google.com/maps?q=1+infinite+loop,+cupertino,+CA