City not appearing in the Api:

  • 1
  • Question
  • Updated 5 years ago
I'm using latitude and longitude via jquery to get my location. My variables are plugging in correctly, but when I test the api url: http://api.wunderground.com/api/ff70e... I don't even get Rochester, let alone Buffalo as an option. How do I get the city that is closest to me?

My project is here: http://mrb5776.cias.rit.edu/solar/

Can someone please help me?
Photo of missemm

missemm

  • 3 Posts
  • 0 Reply Likes

Posted 5 years ago

  • 1
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
Please don't use the US state fragment in API URLs when querying for latitude+logitude
Photo of missemm

missemm

  • 3 Posts
  • 0 Reply Likes
I'm completely new to this so in all honesty I don't know what you mean.

In terms of my post: I solved the problem by using Google Maps API to give me a zip code so I could use that with the Wunderground json instead of longitude and latitude. If this is a bad method for doing this. Is there a better way you would recommend?

Also for the future, if you're going to tell me not to do something please explain why I shouldn't do it.
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
I'm sorry, I used to be fairly short in replies

According to first post, your WU API call should be someting similar (after you input your key)

http://api.wunderground.com/api/INPUT...

Avoid exposing your key, since it could be used by others, beyond your control so api calls could be consumed from your account.

Please note that a IA (you specified in first post), that would stand for US state when querying for a location, is needed to get excluded: it would bring to an unwanted response, as you have noticed. I hope this cleared the issue and made less "stern" my answer, it was not my intention.

Anyway have a look at http://www.wunderground.com/weather/a... for allowed query syntaxes.

As a personal opinion, latitude and logitude are the best way to use this types of APIs, since you can always get your project a worldwide vision and in long term you can be always safe that you'll set for your requests that precise point (zip codes databases could be dynamic).
Photo of missemm

missemm

  • 3 Posts
  • 0 Reply Likes
Thank you!