Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Maps API requires API token #6

Open
iancward opened this issue Sep 20, 2018 · 2 comments
Open

Google Maps API requires API token #6

iancward opened this issue Sep 20, 2018 · 2 comments

Comments

@iancward
Copy link

I've been getting a lot of "Couldn't find " errors from this integration lately, and when I went to go investigate it, it appears that Google no longer allows to their maps API without an access key, as I received this warning when running the google maps query manually:

{
   "error_message" : "Keyless access to Google Maps Platform is deprecated. Please use an API key with all your API calls to avoid service interruption. For further details please refer to http://g.co/dev/maps-no-account",
   "results" : [],
   "status" : "OVER_QUERY_LIMIT"
}

I think #4 may fix this.

@Nmasood
Copy link

Nmasood commented Dec 11, 2019

I know this repo is pretty dead but I needed it to showcase some things hubot could do. Was going to use google but they charge. If anyone in the future needs a free service, mapquest worked well enough for the 5 minutes I needed it for:

mapquest_key = process.env.HUBOT_MAPQUEST_KEY || ''
mapquest_secret = process.env.HUBOT_MAPQUEST_SECRET || ''
mapquest_url = "http://open.mapquestapi.com/geocoding/v1/address"
q = location: location, key: mapquest_key
msg.http(mapquest_url)
  .query(q)
  .get() (err, res, body) ->
    result = JSON.parse(body)
    if result.results.length > 0
      lat = result.results[0].locations[0].latLng.lat
      lng = result.results[0].locations[0].latLng.lng
      lookupWeatherAndRespond msg, lat, lng, options.separator, location
    else
      msg.send "Couldn't find #{location}"
      console.log("hubot-darksky google geocoding result: " + JSON.stringify(result))

@enfuego311
Copy link

Thanks for the reply. I was able to take your code and manipulate it for what I needed. It was very helpful.

        if result.results.length > 0
          lat = result.results[0].locations[0].latLng.lat
          lng = result.results[0].locations[0].latLng.lng
          if result.results[0].locations[0].adminArea5 == ""
            retcity = ""
          else
            retcity = "#{result.results[0].locations[0].adminArea5}, "
          if result.results[0].locations[0].adminArea3 == ""
            retstate = ""
          else
            retstate = "#{result.results[0].locations[0].adminArea3}, "
          if result.results[0].locations[0].postalCode == ""
            retzip = ""
          else
            retzip = "#{result.results[0].locations[0].postalCode}, "
          if result.results[0].locations[0].adminArea1 == ""
            retcountry = ""
          else
            retcountry = result.results[0].locations[0].adminArea1
          darkSkyMe msg, lat,lng , options.separator, (darkSkyText) ->
            response = "Weather for #{retcity}#{retstate}#{retzip}#{retcountry}#{options.separator}#{darkSkyText}"
              .replace /-?(\d+\.?\d*)°C/g, (match) ->
                centigrade = match.replace /°C/, ''
                match = Math.round(centigrade*10)/10 + '°C/' + Math.round(centigrade * (9/5) + parseInt(32, 10)) + '°F'
            response += "#{options.separator}"
            msg.send response
        else
          msg.send "Couldn't find #{location}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants