Display Active Wildfire Data with Google Mapplets

In my last post I covered a simple way that you can add existing KML files to your Google Maps application through the GGeoXML class which is part of the Google Maps API. In that example we displayed an auto-updating KML file containing Global MODIS Hotspots provided by the Fire Information for Resource Management System (FIRMS) at the University of Maryland inside Google Maps. I’d like to build upon that initial post and show you how to convert this simple functionality into a Google Mapplet. Mapplets are focused, mini-applications wrapped in an XML file that run on top of the Google Maps API, and can communicate with Google Maps, fetch data from remote websites, and store user preferences. In addition, Mapplets use Google Gadget technology which gives them much of this functionality. The point of creating a Mapplet is to expose your application to Google Maps users around the world or simply to your organization.

Mapplets vs. Google Maps
Although the API calls for manipulating Mapplets are virtually identical to Google Maps API calls, there are some differences. Before writing the mapping code, you will need to wrap your Mapplet inside a Google Gadget XML structure that controls the content, user preferences, and Gadget preferences. We’ll cover these topics in the next section. At a high-level there are some additional differences including simpler initialization, the disallowance of non-standard behavior, asynchronous communication with the map, security, and requests for remote data.

Mapplet XML Structure
Mapplets, which are a type of Google Gadget, are XML based and all specifications are enclosed by the <Module> element. A gadget is composed of three major parts: content section, user preferences, and gadget preferences. The Content section, defined by the <Content> element can contain HTML and JavaScript code. This is where all the work of your Mapplet takes place and results in the display seen by your users. Google Maps API code will be located in this section wrapped inside a <script> tag. User preferences are used to specify user settings and are defined within the <UserPrefs> element. This section can contain user interface items such as text boxes or combo boxes that are used to gather information from your user for use within the Mapplet. Finally, gadget preferences contain characteristics of the gadget such as the title, description, author, author email and other high level details, and are defined within the <ModulePrefs> element.

Creating the Wildfire Google Mapplet
Now that you understand the basic contents of a Mapplet let’s take a look at a very simple example that builds on what we accomplished with the GGeoXML class. I’ve created an “Active North American Wildfire” Mapplet and uploaded it to our website. We could also submit this Mapplet to the Google Maps directory so that other users around the world can display active North American wildfires in Google Maps. To add this Mapplet to your collection of maps please open a web browser and paste the following URL into the address bar.

http://maps.google.com/ig/add?synd=mpl&pid=mpl&moduleurl=http://www.geospatialtraining.com/Mapplets/WildfireMappletExample.xml

This should prompt you to add the Mapplet to Google Maps as you see below:

Click the “Add it to Maps” button and the “My Maps” tab in Google Maps should become activated. The “Active North American Wildfires” Mapplet will be displayed in Google Maps as you see below.

Click here to see the XML structure and Mapplet API code that we used to create this Mapplet. In this case we’re only using the <ModulePrefs> and <Content> sections. Because we do not have any user interface items in this simple example we are not including a <UserPrefs> section. It would be fairly simple to add in functionality that allows your user to display active wildfires by state simply by adding in a user input control inside the <UserPrefs> section. When creating a Mapplet you must ensure that the <Require feature=”sharedmap” /> element is included inside the <ModulePrefs> element. This enables your Mapplet to automatically initialize the Mapplet API.

In our next post we’ll discover how to integrate Google Maps, Google Mapplets, and the new ArcGIS Server JavaScript Extension for Google Maps.

More Information
For more information on the Google Maps API, Google Mapplets, or GeoSpatial Training Services please see our e-learning courses entitled “Google Maps For Your Apps”, “Creating Mapplets with Google Gadgets“, or our “Google Maps Developer Bundle” which is currently on sale as part of our 3rd Year Anniversary Sale.

Leave a Reply

You must be logged in to post a comment.