Author Topic: Google API billing  (Read 3012 times)

0 Members and 1 Guest are viewing this topic.

Online Ian.

  • Forecaster
  • *****
  • Posts: 459
    • Chatteris Weather
Google API billing
« on: May 02, 2018, 05:02:16 PM »
Hi,

Received an e-mail from Google regarding API billing for use of maps, the mail says that the new systems comes into play in June and you get $200 monthly credit free, it goes on that my sites usage is below this, but they need billing details should it be exceeded.

Is this genuine?


CWOP - DW3371
PWS - ICAMBRID16
https://www.chatteris.biz

Offline dupreezd

  • Forecaster
  • *****
  • Posts: 512
Re: Google API billing
« Reply #1 on: May 02, 2018, 05:12:50 PM »
Ian, just hover your mouse over the link they provided. DO NOT CLICK. It will show where the link is going to take you. Check if it makes sense, spelling mistakes etc.
You are below your quota, so if you ignore the email, what is the worse that can happen?  :-)

Davis VP2 6163 | WiFi Logger
CWOP - FW0717
Blitzortung 2100

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 946
    • LexMAWeather
Re: Google API billing
« Reply #2 on: May 02, 2018, 06:05:19 PM »
It's real. I was about to post something and saw a thread was started already.

Google had announced last year that they'd stop supporting Maps use without API keys.  That and more is explained here:

https://cloud.google.com/maps-platform/user-guide/

It's short, but the even shorter tl;dr version is that as of July 11:

1) If you don't have a key, you have to create one;

2) You have to associate a credit card with your key for it to work so they can charge you if you go over the $200 limit.

In the email I got, they say I haven't exceeded the $200/month quota since I've had an API key.

https://lexmaweather.info
On Mastodon: @LexMAWeather@toot.community

Offline DaleReid

  • Forecaster
  • *****
  • Posts: 2002
    • Weather at Eau Claire, WI
Re: Google API billing
« Reply #3 on: May 02, 2018, 07:15:14 PM »
Is this for those programs with plot data pulled from Google Maps, or ALL users, whether you just are zoomed in to a view or location, say with doing a google search, getting a diner's address and a pin on a map where the location is, for example?

I know lots of folks who just use their cellphones, and a map pops up many times a day.  To think that they all are going to apply for an API key and use it (it took me an hour to figure out how to get one) they are going to loose a lot of folks using Google maps.

On the other hand, I'm not sure what I got a Google key for.  How do I find out where it is used or just wait till things stop working?

I use Blitzortung, and I think that has google maps display.  I have TOA lightning, too, and don't know if that uses a key, I doubt it since I think I just set up and used it. 

I read their little discussion, and there is no way I will link a charge card, without having some option of being notified I'm about to be charge, and the option to not go forward.  It's like dad and mom finding out their minutes used (before unlimited plans) were far exceeding the amount they were entitled to when they got the $500 bill for last month when junior was romancing his new sweetheart.

This is very strange. 
ECWx.info
&
ECWx.info/t/index.php

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 946
    • LexMAWeather
Re: Google API billing
« Reply #4 on: May 02, 2018, 07:41:12 PM »
The key is needed by the developer of the web site, app, etc.  It isn't the end user that does this or has to pay.

For example, if you are using the Saratoga template and use the NWS alerts code, look in nws-alerts-config.php.  There is a variable called $googleAPI which is where the API key goes. That is then used in the javascript Google API code in nws-alerts-details-inc.php. Essentially, it will have to be included in the request for the map in the code to operate successfully.

Ken's code already checks to see if a properly formatted key is in $googleAPI and, if not, it does not attempt to pull in the map.
https://lexmaweather.info
On Mastodon: @LexMAWeather@toot.community

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 946
    • LexMAWeather
Re: Google API billing
« Reply #5 on: May 02, 2018, 07:44:07 PM »
Also wanted to note that this issue is why Weather Underground changed from using Google to using Mapbox / OpenStreetMap for Wundermap. They obviously get a lot more traffic than I do.  8-)
https://lexmaweather.info
On Mastodon: @LexMAWeather@toot.community

Offline DaleReid

  • Forecaster
  • *****
  • Posts: 2002
    • Weather at Eau Claire, WI
Re: Google API billing
« Reply #6 on: May 02, 2018, 07:54:19 PM »
Thank you, that extra explanation goes a long way to my understanding this.  Hat's off to the developers who obviously know this stuff VERY well.
ECWx.info
&
ECWx.info/t/index.php

Offline 92merc

  • BismarckWeather.net
  • Forecaster
  • *****
  • Posts: 1307
  • BismarckWeather.net
    • BismarckWeather.net
Re: Google API billing
« Reply #7 on: May 03, 2018, 08:59:51 AM »
I received the email as well yesterday.  My Plains Weather Network also uses the API.  I guess I'll have to put a card in as well.  I'm easily under the $200 mark as well.
https://www.BismarckWeather.net
Davis VP2, Cumulus, WeatherDisplay, Blitzortung, Saratoga Scripts, NOAA Stream via PI

Offline yamiacaveman

  • Forecaster
  • *****
  • Posts: 436
    • Penn Lake Weather
Re: Google API billing
« Reply #8 on: May 03, 2018, 09:24:59 PM »
I did follow some of the links from google but did not look at this is in great deal. I did not yet get to the place where my google letter explains how I am "way under" and should not have to worry about a 200.00 charge.

So does anyone know once you give a credit card is there a way to stop access or limit access so you will never reach the 200.00???  I mean is it based on the amount of hits your site takes with google maps? If so to me it's a pretty bad plan. I mean if it's base on hits or usage, come June I could go on anyone's site using google maps, keep clicking on that map and create a very hefty bill for some one. But I might be way out of line here cause I really did't look into yet.

Did or does anyone understand how this all works??

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 946
    • LexMAWeather
Re: Google API billing
« Reply #9 on: May 07, 2018, 10:18:57 AM »
I've been doing some experimenting with Mapbox and it looks like a very feasible replacement for google for alert maps. You still need an API key but no credit card on file. As far as I can tell from the documentation, if you go beyond the freebie volume, the user experience just degrades.

The basics:

The Google code that defines a map looks like this:

Code: [Select]
<script>
function initMap() {
             var map = new google.maps.Map(document.getElementById('map'), {
               zoom: 8,
               center: {lat: 42.15, lng: -71.7},
               mapTypeId: 'roadmap'
             });
</script>
<script async defer
            src="https://maps.googleapis.com/maps/api/js?key=your key&callback=initMap">
</script>


For Mapbox, it looks like this:

Code: [Select]
<script>
mapboxgl.accessToken = 'your key';
             var map = new mapboxgl.Map({
               container: 'map',
               style: 'mapbox://styles/mapbox/streets-v10',
               center: [-71.7, 42.15],
               zoom: 6.5
             });
</script>

Adding polygons with Google:

Code: [Select]
var polyc0 = [
{lat: FIRST LATITUDE POINT, long: FIRST LONGITUDE POINT},
  ... etc ...
]

var mapoly0 = new google.maps.Polygon({
      paths: polyc0,
      strokeColor: "COLOR",
      strokeOpacity: OPACITY,
      strokeWeight: "WEIGHT",
      fillColor: "FILL COLOR",
      fillOpacity: FILL OPACITY
    });
 mapoly0.setMap(map);

Adding polygons with Mapbox:

Code: [Select]
map.on('load', function() {
  map.addLayer({
    'id': 'poly0 ',
    'type': 'fill',
    'source': {
      'type': 'geojson',
      'data': {
        'type': 'Feature',
        'geometry': {
          'type': 'Polygon',
          'coordinates': [ [
[FIRST LONGITUDE POINT, FIRST LATITUDE POINT],
 ... etc ...
] ]
          }
        }
      },
    'layout': {},
    'paint': {
      'fill-color': 'FILL COLOR',
      'fill-opacity': FILL OPACITY
    }
  });
  // more map.addLayer definitions can go here
});

There doesn't seem to be a way to get a different stroke color for the boundary without adding another polygon layer, but the alerts code uses the same color for the stroke and fill anyway.

I recently did a lot of additions to the alert code on my site to include maps even when there is no polygon in the NWS alert (using geocode definitions of counties and zones) so my code is far afield from the base Saratoga. However, I'd be willing to help someone get this running with the base code if Ken and the rest of us (especially Ken) think this is a good way to go.

My Mapbox stuff is still in my sandbox but when I take it live I can let you all know if you'd like to see it in action (although the weather here is supposed to be nice and boring this week).
https://lexmaweather.info
On Mastodon: @LexMAWeather@toot.community

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9244
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Google API billing
« Reply #10 on: May 07, 2018, 11:12:00 AM »
I'm back from the cruise and looking at converting all my Google Map scripts to use Leaflet/OpenStreetMap in the near future.  It should be done well before the June, 2018 Google implementation date.  That would cover quake-json.php, global-map.php, mesonet-map.php, nws-alerts.php and radio.php scripts.  I'm working on the quake-json.php script right now.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 946
    • LexMAWeather
Re: Google API billing
« Reply #11 on: May 07, 2018, 11:42:56 AM »
Awesome!
https://lexmaweather.info
On Mastodon: @LexMAWeather@toot.community

Offline 92merc

  • BismarckWeather.net
  • Forecaster
  • *****
  • Posts: 1307
  • BismarckWeather.net
    • BismarckWeather.net
Re: Google API billing
« Reply #12 on: May 07, 2018, 11:48:07 AM »
I'm guessing Blitzortung is going to have to do a major re-work.  Looks like he's on Google.  I'm sure that site gets more hits than any of our smaller sites do.
https://www.BismarckWeather.net
Davis VP2, Cumulus, WeatherDisplay, Blitzortung, Saratoga Scripts, NOAA Stream via PI

Offline mikeym2m

  • Senior Contributor
  • ****
  • Posts: 153
    • MikeyM's Thornhurst PA Weather
Re: Google API billing
« Reply #13 on: May 07, 2018, 12:13:44 PM »
Sounds Great Ken - thanks!

 :grin:

MikeyM

Offline yamiacaveman

  • Forecaster
  • *****
  • Posts: 436
    • Penn Lake Weather
Re: Google API billing
« Reply #14 on: May 07, 2018, 01:34:06 PM »
Yes! Thanks Ken!!!

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2573
    • SouthEast Lincoln, NE Weather
Re: Google API billing
« Reply #15 on: May 07, 2018, 10:42:59 PM »
Looking forward to the changes.  Thanks, Ken!
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 946
    • LexMAWeather
Re: Google API billing
« Reply #16 on: May 08, 2018, 08:04:59 AM »
I did side-by-side comparison tests and have to say Leaflet is a far superior choice over Mapbox. Rendering speed is comparable to Google. Mapbox is slooooooooooow.

I like the API better also and it is well documented.

Good call, Ken!
https://lexmaweather.info
On Mastodon: @LexMAWeather@toot.community

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9244
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Google API billing
« Reply #17 on: May 08, 2018, 12:05:34 PM »
Leaflet JS library allows you to use many different map tile providers (like Mapbox or thunderforest.com), and including OpenStreetMaps.

My current work on quake-json.php uses Leaflet/OpenStreetMaps for display, and I must admit, it is very much faster than Google AND easier to use.  There's a really nice clustering plugin and the Marker has a built-in label property.   Here's what my sample code looks like with Leaflet/OpenStreetMaps in the current development phase.

I did that conversion in about 6 hours, and it doesn't require an API key for map use (bonus).  I need to add the ability to use other map tile providers (and their API key info), then the script should be completed .. it will be a replacement for the current quake-json script set.
« Last Edit: May 08, 2018, 12:07:12 PM by saratogaWX »
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline spweather

  • Contributor
  • ***
  • Posts: 125
    • Sand Point Weather
Re: Google API billing
« Reply #18 on: May 08, 2018, 12:39:58 PM »
Thank you, Ken!

Dennis
Regards,
Dennis

- Davis Wireless Vantage Pro2 Plus w/24hr FARS
- Davis (Ultra)Sonic Anemometer
- Boltek/MicroLDN TOA Lightening Detection
- Porcupine Labs LR4/Fluke 414D Laser Rangefinder snow depth measuring sensor


Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9244
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Google API billing
« Reply #19 on: May 10, 2018, 06:26:17 PM »
Ok, Version 3.00 - 10-May-2018 of the quake-json scripts has been released.

It replaces the Google map with a Leaflet/OpenStreetMaps+other tile providers map.  5 different tiles are available (4 are https so one is not shown on https sites), and if you acquire a Mapbox.com API key, two additional maps (Terrain3 and Satellite) are also available.

Standalone users: download from the script page
Template users: use the update tool page with a query of Base-*,Plugin-*, 10-May-2018

Enjoy!

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline SteveFitz1

  • Forecaster
  • *****
  • Posts: 519
    • Tyler Texas Weather
Re: Google API billing
« Reply #20 on: May 10, 2018, 08:01:59 PM »
Ken,

I just downloaded the non-template code and it is working. However, when I want to change the default map tile to OSM, no change seems to occur if I do this in quakes.php. I had to change quakes-json.php to get the map tile to change. I noticed your recommendation not to make any customization changes in quakes-json.php, so I'm wondering whether something isn't working correctly, or if I'm just misunderstanding which file to make changes in.

Thanks very much.

Steve

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2573
    • SouthEast Lincoln, NE Weather
Re: Google API billing
« Reply #21 on: May 10, 2018, 08:03:12 PM »
Fantastic job, Ken!

Here it is on my site.  (I like to see even minor tremors of magnitude 1.5, so there's a longer list than you would see with magnitude 2.0.)

Many thanks. =D&gt; =D&gt; =D&gt;
« Last Edit: May 10, 2018, 08:05:00 PM by gwwilk »
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 946
    • LexMAWeather
Re: Google API billing
« Reply #22 on: May 10, 2018, 09:03:19 PM »
I'm a big fan of the "detectRetina" option in Leaflet, although it's only going to matter if you have a retina display. Here are without and with screenshots on an iMac with a retina display for a chunk of southern New England.
https://lexmaweather.info
On Mastodon: @LexMAWeather@toot.community

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9244
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Google API billing
« Reply #23 on: May 10, 2018, 09:39:51 PM »
Ken,

I just downloaded the non-template code and it is working. However, when I want to change the default map tile to OSM, no change seems to occur if I do this in quakes.php. I had to change quakes-json.php to get the map tile to change. I noticed your recommendation not to make any customization changes in quakes-json.php, so I'm wondering whether something isn't working correctly, or if I'm just misunderstanding which file to make changes in.

Thanks very much.

Steve
Hmm... that's odd.  In quakes.php script (and wxquake.php for the template) using
Code: [Select]
$setMapProvider = 'OSM';     // OpenStreetMap - no key neededshould set it to Open Street Map as the default page.  I just tried and it worked  :?
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline SteveFitz1

  • Forecaster
  • *****
  • Posts: 519
    • Tyler Texas Weather
Re: Google API billing
« Reply #24 on: May 10, 2018, 10:11:09 PM »
Ken,

Here's my code from quakes.php
Code: [Select]
# $mapProvider = 'Esri_WorldTopoMap'; // ESRI topo map - no key needed
  $setMapProvider = 'OSM';     // OpenStreetMap - no key needed
# $setMapProvider = 'Terrain'; // Terrain map by stamen.com - no key needed
# $setMapProvider = 'OpenTopo'; // OpenTopoMap.com - no key needed
# $setMapProvider = 'Wikimedia'; // Wikimedia map - no key needed
 
#  $mapProvider = 'MapboxSat';  // Map by Mapbox.com - API KEY needed in $setMapboxAPIkey
#  $mapProvider = 'MapboxTer';  // Map by Mapbox.com - API KEY needed in $setMapboxAPIkey

and here's my code from quake-json.php

Code: [Select]
      $mapProvider = 'Esri_WorldTopoMap'; // ESRI topo map - no key needed
//$mapProvider = 'OSM';     // OpenStreetMap - no key needed
//$mapProvider = 'Terrain'; // Terrain map by stamen.com - no key needed
//$mapProvider = 'OpenTopo'; // OpenTopoMap.com - no key needed
//$mapProvider = 'Wikimedia'; // Wikimedia map - no key needed
//
//$mapProvider = 'MapboxSat';  // Maps by Mapbox.com - API KEY needed in $mapboxAPIkey
//$mapProvider = 'MapboxTer';  // Maps by Mapbox.com - API KEY needed in $mapboxAPIkey

I'm still getting the ESRI map. You can see it here http://tylertexasweather.com/quake-json.php.

Steve