O'Reilly logo

OpenLayers 3 : Beginner's Guide by Erik Hazzard, Paul Spencer, Thomas Gratier

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – getting dynamic data

In this exercise, we'll change our code to fetch the data from Flickr when the page loads, rather than using a previously downloaded file. As you'll see, this is quite straightforward.

  1. Recall that when we switched over to the static JSON data, we entered the following URL into our browser to download the JSON data:
  2. We should be able to use this URL with our $.ajax function and load data directly from the live feed rather than our static file. Go ahead and modify the URL:
    $.ajax({
      url: 'http://api.flickr.com/services/feeds/geo/?format=json&tags=bird',
      dataType: 'jsonp',
      jsonpCallback: 'jsonFlickrFeed',
      success: successHandler
    });
  3. Reload the browser ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required