Make a query with array of locations(lat and long)?

  • 1
  • Question
  • Updated 4 years ago
Hi, is it possible to make a query with array? So I would like to make a query to a service with array of locations(lat and long) and to get response for these locations?

Thank you.
Photo of Ivan


  • 2 Posts
  • 0 Reply Likes

Posted 4 years ago

  • 1
Photo of WunderWilliam


  • 267 Posts
  • 17 Reply Likes
The API only supports one location per request, so an array won't work. You can do multiple requests for one location, such as including geolookup, conditions, and forecast on the same call.
Photo of Ivan


  • 2 Posts
  • 0 Reply Likes

Thank you for response, I know about multiple requests for one location, was just hoping that I can also do something like array of locations per requests.

Thank you.
Photo of afelicioni


  • 227 Posts
  • 42 Reply Likes
With just basic javascript skills, you can code something like this

<script src=""></script>
<script type="text/javascript">
var aQueries = ['Italy/Rome.json','Italy/Florence.json','Italy/Venice.json'];
for (var nIndex in aQueries) {
url: ''+sWUAPIKey+'/geolookup/conditions/q/'+aQueries[nIndex],
dataType: 'jsonp',
success: function(parsed_json) {
var location = parsed_json['location']['city'];
var temp_f = parsed_json['current_observation']['temp_f'];
alert("Current temperature in " + location + " is: " + temp_f);

Let us know if this is the wanted approach to solution or the scenario needs something different
Photo of shortstuffsushi


  • 5 Posts
  • 0 Reply Likes
To William and afelicioni -- your answers are both the obvious choice. Yes, we can make multiple requests, but that's bad for both of us.

As developers, multiple requests will likely both put us over our per-minute, and per-day limit much faster.

As the owners of this API, by forcing developers to make multiple requests, you're forcing your servers to take on lots of additional incoming requests that could be avoided by allowing us to send a request body with multiple locations, or something.

Then there's the mobile perspective. Users of the devices have limited bandwidth, and limited multi-concurrent request abilities.

It seems like this is something you should at least consider adding support for.
Photo of iheartfishing


  • 1 Post
  • 0 Reply Likes
Well said, shortstuffsushi!