Showing bird pictures from around the world is nice—but what about giving users the ability to show a photo with any tag they want? That's what we'll do next. So far, we've created a map that lets users interact with Flickr data. As far as we're concerned, we're more or less done with the interaction part. Now, we'll focus on changing the data source part. Currently, we're only asking for photos with the bird tag, but we want to allow that to be any tag.
An important concept in application development is to keep things modular. This basically means that we try to write out applications in such a way that we can take out, and put in, different parts without drastically changing the rest of our code. In this case, we will leave the interaction part of our code alone (what we've done so far at least) and focus mainly on the code that retrieves data.
What needs to happen? Well, let's think this through. We want the user to be able to specify any tag they want. We want to allow multiple tags. This means we'll need to change the URL that the $.ajax function is loading, but only after the user specifies some tags. We'll want to create a function to wrap the $.ajax call and come up with a way to change the URL based on the selected tags. We'll also need to deal with removing existing features when the tags change.
So, we know we need to allow a variable that specifies the tags parameter in the URL to be based on user input. We'll need to create an input box that will allow the user to specify tags. We'll also have a submit button that will, when clicked, call a function that updates the $.ajax method's URL with the specified parameters.