Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Develop a dynamic location-based mashup

Mashups, maps, and snapshots

Ken Bluttman (ken@kenbluttman.com), Freelance Web Developer, Freelance Consultant
Ken Bluttman
Ken Bluttman has been tickling computer keyboards for nearly two decades. Along the way, he has conquered several programming languages and written a half-dozen computer books. And there is always tomorrow to do more.

Summary:  Mashups are a new, highly interactive Web development methodology. Essentially a mix of related content put together from disparate sources, mashups provide rich dynamic content for a superb user experience. Getting Asynchronous JavaScript + XML (Ajax) and mashup chops into your development toolbox will benefit you with high demand in the evolving Web 2.0 workspace.

Date:  07 Oct 2008
Level:  Intermediate PDF:  A4 and Letter (1309 KB)Get Adobe® Reader®

Activity:  11667 views
Comments:  

Before you start

This tutorial steps through the paces of using Ajax to dynamically update a Web page. The data needed to update one part of the page using an Ajax call is taken from a different portion of the page that was populated from another source. That is the basis of a mashup — blending data. Ajax is key to this process because it allows another part of the page to update without refreshing the entire page. Having a basic knowledge of Ajax will go a long way in helping you follow the tutorial; an Ajax overview/refresher is included in the tutorial to bring you up to Ajax speed.

About this tutorial

This tutorial presents a common mashup technique and builds from there. Maps are prevalent in Web usage and make for a great mashup. In the tutorial, the Google Maps API provides the map and mapping function. Data returned from the map — latitude and longitude coordinates — is applied to another API, provided by Flickr, the popular photography Web site. Flickr has an end-user feature that lets you geotag uploaded photographs: the latitude and longitude coordinates of where the picture was taken become associated with the photograph.

The mashup round trip follows clicking a Google map and having the Map API return the coordinates where you clicked. These values are then sent using Ajax to the Flickr API. The end result is a stream of photographs that are geotagged with the coordinates.

Along the way, you use an additional feature of the Flickr API: tags. Tags (not geotags) are keywords that describe a photograph. For instance, you could tag a photograph of the Golden Gate Bridge with San Francisco, bridge, Golden Gate, fog (that bridge is in the fog a lot), and so on. The tags have been added by people uploading their photographs into Flickr. In this example, you don't make new tags, you just search for them.

Because this mashup consists of different APIs, with Ajax in the middle, the tutorial introduces the components in a sequence:

  1. The basics of Google maps are demonstrated. You learn how to create one and alter it.
  2. Ajax is covered next because Ajax uses data coming from the Google map. The Ajax coverage includes a refresher on the basic Ajax call.
  3. The mashup is demonstrated: latitude and longitude coordinates from the Google map are sent to the Flickr API through the Ajax mechanism, and photographs are returned from Flickr.
  4. The basics of using the Flickr API are demonstrated. You learn how to get a Flickr account and use the Flickr API.

Objectives

The objective of this tutorial is to take your knowledge of Ajax and apply it such that data from one API is sent to another API in an Ajax call. A few parameters are sent with the Ajax call. The returned information from the Ajax call is then formatted to be properly presented on the Web page.


Prerequisites

Much of this tutorial uses JavaScript code. Ajax isn't a language; it's a programming paradigm that relies heavily on JavaScript code. Knowledge of Ajax is helpful, but if that is an issue, then at least a good working knowledge of JavaScript code is key. The tutorial also assumes you know some key features of a map: distance, coordinates, and scale.


System requirements

Access to a Web server and a valid domain are the only technical requirements for this tutorial. You need permission to add files to the domain. PHP is used for the server-side language, but the server-side code is fairly simple. On the server, you use code to query a database or retrieve data from a service. If these concepts are familiar in any server language, it should an easy task to rewrite the PHP into the server-side language of your choice.

1 of 9 | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Web development, XML, Open source
ArticleID=343557
TutorialTitle=Develop a dynamic location-based mashup
publish-date=10072008
author1-email=ken@kenbluttman.com
author1-email-cc=cmwalden@us.ibm.com

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.