Tornadoes in Google Earth

With storms again ripping through the country, many of us are on the lookout for tornadoes. While it can’t help you prepare for one, Tornado Paths, created by Perry Samson at the University of Michigan, is a great way to view the locations and paths of past storms.

By default it shows all of the tornadoes that have hit the United States in the past 48 hours, but it has a few other nifty features.

• View “Today in History“, which shows all of the tornadoes that have struck on today’s date in the past 61 years.

• Use the search box to let you see all of the tornadoes that have struck a particular zip code since 1950. Very interesting stuff! For example, I now know that a 1986 tornado came within a few hundred meters of our current house.

tornadoes.jpg

Of course, it makes excellent use of Google Earth too. By clicking the “View in Google Earth link from the home page, you can view the most recent tornadoes in Google Earth.

tornadoes.jpg

As you can see, the tornadoes have a nice 3D semi-transparent affect, and some cows flying around nearby in an apparent homage to the classic movie “Twister”.

Transparency and controls for Adobe Flash Player’s local storage

Many web users today are aware of browser cookies, and every major browser allows users to view and delete the browser cookies stored on their computer. However, some users may not be aware that many websites use different types of local storage as well, including Adobe Flash Player Local Shared Objects (LSOs), referred to by some people as “Flash cookies.”

In the past, in order to view Flash LSOs and delete them from your computer, you had to visit an online settings application on Adobe’s website. To make local storage data deletion easier, we worked with Adobe and others in the web community to design the NPAPI ClearSiteData API. This API, which Adobe has implemented in Flash Player 10.3, has made it possible to delete Flash LSOs directly from the browser itself.

As of this week’s Chrome Dev channel release, you can delete local plug-in storage data (such as Flash LSOs) from within Chrome by clicking Wrench > Tools > Clear browsing data and selecting “Delete cookies and other site and plug-in data.”
Above: The chrome://settings/clearBrowserData dialog.

“Plug-in data” here refers to client-side data stored by plug-ins that obey the NPAPI ClearSiteData API, such as Flash Player 10.3. You can also configure Chrome’s content settings to clear plug-in data automatically whenever you close the browser.
Above: The chrome://settings/content dialog.

To our knowledge, Adobe Flash Player is currently the only NPAPI plug-in which has implemented support for the NPAPI ClearSiteData API, but we hope other plug-ins will follow suit. We believe providing control over plug-in data directly in the browser creates a better experience for both users and website developers.

Open Street Map and ESRI tiles on Bing Maps

In a previous post, I explained how to replace the base tile layer in the Bing Maps Silverlight control with an ESRI tile layer. In this post, I’ll show how to do the same but using the Bing Maps AJAX v7 control. You can use this technique to use the Bing Maps AJAX control, but replace the Bing imagery with OSM tiles or the ESRI tile layers used in the previous Silverlight post, as well as many other tile sources.

The first step is to specify not to load the default Bing Maps tile layer. Do this by specifying the mercator MapTypeId in the options passed to the constructor when you first initialise the map:

[php]mapTypeId: Microsoft.Maps.MapTypeId.mercator[/php]

The next step is to create a new TileSource. The uriConstructor of the TileSource must return the correct URI for a requested tile. If your tile provider names its tiles according to the default Bing Maps quadkey numbering system, then the uriConstructor can be a simple string using the {quadkey} placeholder. This will be replaced with the appropriate quadkey when the tile is requested:

[php]var tileSource = new Microsoft.Maps.TileSource(
{  uriConstructor: ‘http://www.microsoft.com/maps/isdk/ajax/layers/lidar/{quadkey}.png’ }
);[/php]

However, for OSM tiles, or any other tile providers that not follow the basic quadkey numbering system, we instead need a function to construct the appropriate URI for each tile. I’ll do this in a function called getTilePath, and I’ll specify this in the TileSource uriConstructor as follows:

[php]var tileSource = new Microsoft.Maps.TileSource({ uriConstructor: getTilePath });[/php]

The getTilePath function will return a string with the appropriate URI for the requested tile. For OSM tiles, a typical tile looks like http://tile.openstreetmap.org/zoom/x/y.png. The function to create this tile is therefore:

[php]function getTilePath(tile) {
return "http://tile.openstreetmap.org/" + tile.levelOfDetail + "/" + tile.x + "/" + tile.y + ".png";
}[/php]

Put this all together and your code should look like this:

[php]<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
<script type="text/javascript">
function GetMap() {
// Create a basic map
var map = new Microsoft.Maps.Map(document.getElementById("mapDiv"),
{ credentials: "YOURBINGMAPSKEYHERE",
center: new Microsoft.Maps.Location(56, 2),
zoom: 5,
// Don’t load the Bing base map tiles
mapTypeId: Microsoft.Maps.MapTypeId.mercator
});

// Create the tile source
var tileSource = new Microsoft.Maps.TileSource({ uriConstructor: getTilePath });

// Construct the layer using the tile source
var tilelayer = new Microsoft.Maps.TileLayer({ mercator: tileSource, opacity: 1 });

// Push the tile layer to the map
map.entities.push(tilelayer);
}

function getTilePath(tile) {
// Construct the URI path for an OSM tile based on tile zoom/x/y
return "http://tile.openstreetmap.org/" + tile.levelOfDetail + "/" + tile.x + "/" + tile.y + ".png";
}
</script>
</head>
<body onload="GetMap();">
<div id=’mapDiv’ style="position:relative; width:640px; height:480px;"></div>
</body>
</html>[/php]


And here’s what it looks like:

image

If you want to try some other tile providers, replace the URI constructed by the getTilePath() function with some of the following:

DeLorme World Basemap

[php]function getTilePath(tile) {
return "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer/tile/"
+ tile.levelOfDetail + "/" + tile.y + "/" + tile.x;
}[/php]

image

ESRI World Imagery

[php]function getTilePath(tile) {
return "http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/"
+ tile.levelOfDetail + "/" + tile.y + "/" + tile.x;
}[/php]

image