Wednesday, July 25, 2012

Great open source map tools for Web developers

http://www.javaworld.com/javaworld/jw-07-2012/120718-open-source-map-tools.html


A long time ago, when Web 2.0 was just Web 1.0, we had to ask people for directions, copy them down, and hope we had a foldable map to help us find our way. Then along came MapQuest, followed by Google Maps in 2005. Today, it seems impossible to imagine finding our way without handheld phones and Web-based maps.
Google Maps and its cousins Yahoo Maps and MapQuest have grown into integral parts of the Web. It's now odd for a website to offer an address without a map showing the location and offering directions. The mapping APIs made it easy for people to insert snippets of maps into their websites; now the maps are everywhere.
[ How much do you know about this stalwart developer tool? Find out in InfoWorld's JavaScript IQ test. | Learn how to work smarter, not harder with InfoWorld's Developers' Survival Guide. | Keep up with the latest developer news with InfoWorld's Developer World newsletter. ]
HTML5 Deep Dive
These APIs were also one of the leaders in the Web 2.0 vanguard because they offered stunning visual proof that users can do great things with remixed data. Everyone started plotting their geographic data on their websites because the JavaScript code made it as easy as adding a few lines.
The explosive growth and endless optimism came crashing to an end in October 2011, when Google started charging heavy users. Light users could still get the services for free, but everyone else was going to pay to support the big map in the sky. It wasn't as tragic as it might seem, but Google's decision was one of the first to signal the end of totally free era.
While some groused, others saw opportunity. Before the price change, everyone was happy to let the big companies do the hard work because no one wanted to compete with a free service from Google. Why pay for what you could get for free? The new prices were steep enough to open the door to competition, making it possible for new companies to get traction.
These new stacks use liberal amounts of open source software mixed with proprietary tools and services. You do what you want on your own and pay for what you can't do. Open source licenses give you the control. While some will still grouse about not getting everything for free, there's no doubt the new marketplace offers many more options and opportunities than before.
To understand the breadth and depth of this new ecosystem, I spent some time building maps and hacking code using these tools. The options are expanding quickly as companies are building their own databases for holding geographical data, their own rendering tools for building maps, and their own software for embedding the maps in websites. I built maps, added data, created overlays, and stuck virtual pushpins all over the place.
Working with these tools can be a bit more complex than working with a big provider like Google. Some of these companies make JavaScript tools for displaying the maps, and others just deliver the raw tiles that the browsers use to assemble the maps. (All browser-based map tools break the maps up into pre-rendered squares or tiles that can be downloaded independently.) Working with the code means making decisions about how you want to assemble the pieces -- now within your control. You can stick with one simple library or combine someone else's library with tiles you produce yourself.

The new tools are great, but the up-and-comers will continue to face stiff competition from the big companies. MapQuest still has the prettiest maps, in my opinion. Microsoft's Bing Maps offer a neat bird's-eye view that gives a nicer perspective than vertical photos. Google has been pumping more money into better 3D imagery and better street-level views -- including those you can take offline. Google is also rapidly integrating Google Maps with its other databases. It's now possible, for instance, to search the maps with the name of a business. All of the above are competing, it turns out, with Apple, which is releasing its own mapping tools for iOS developers.
Of course, these commercial juggernauts have plenty of resources to draw your attention to their mapping tools. The list that follows highlights some of the smaller upstarts that seem ready to give the bigger companies some true competition. The tools are smooth, elegant, and flexible. They're going to give the big companies a real run.
 OpenStreetMapThe source of data for many of these programs is OpenStreetMap, a big collection of coordinates and names for streets around the world. If you want a map, you can grab this huge collection of coordinates and plot them. Voilà!
The real fun comes if you create an account on the website. Suddenly, an Edit button appears and you can fire up an editor to make changes as you would in a wiki built around text. The site keeps getting better and better as people add roads, streams, and trails to the data set.
The license is a bit tighter than many of the standard open source licenses. If you improve the data, you have to share your improvements with everyone. You can do what you want with any maps you create, but once you start sharing the maps built with improved data, you must share the data too. In the parlance of open source licenses, the stickiness quotient is high. If you start using the data, you'll be stuck contributing.
The OpenStreetMap servers also distribute the raw tiles built from this data, but the project discourages any use that puts a strain on its equipment. The website points to a long list of companies that turn the data into services that you can use.
You can edit your own neighborhood with the browser-based interface of OpenStreetMap, an open source collective building the data structures that describe the world.

The group has been building upon this core, which seems to have become stable in 2007. Among the newer projects is GeoMoose, a tool for mixing OpenLayers data with geographic data overlays. It's popular with real estate tax departments in state governments.
Most of the OSGeo projects are protected by generous BSD or MIT licenses.
 TileMillIf you're a Web programmer who loves maps, you'll find TileMill to be the greatest combination since electricity met semiconductors. The tool combines open source data with a language for controlling how the data is rendered. When you're done, TileMill will spit out all of the tiles that your mapping application presents to the user.
The core of the product is Carto, a language for describing how the fonts, lines, and colors are combined. It is, for most intents and purposes, a version of CSS. You design your maps with the same corner of your brain that you use to determine the look for your Web pages. If you want the major streets to be thicker, you bump up the number next to the CSS-like parameter "line-width."
TileMill turns open source data about the world into map tiles that allow you to customize (or experiment with) the look of your maps.

HTMAPL is a jQuery plug-in that pairs HTML with Modest Maps to streamline Web mapmaking.

A skilled artist can work wonders with the OpenStreetMap data. Some of my favorites come from Stamen, a general design studio that has been releasing the tiles under a Creative Commons license. The Terrain maps are nice, but the watercolor maps are eye opening. The colors run together as if they were painted by hand with a messy watercolor brush.
Here are some examples showing the Black and White "Toner" tiles, Watercolor tiles, and Terrain tiles.
Most of the mapping tools are built with Web technology stacks because most people assume the maps will be consumed by mobile browsers. MapNik is written in C++ for desktop users, although it offers Python bindings that might be used in browser-based applications.
The code is essentially a big pipe for juggling geographic data and feeding it into the AGG rendering library, the "antigrain" tool that does a great job with antialiasing. The quality shows too -- MapNik maps have some of the most pleasing details I've seen. Google has been a big supporter of this project during recent Summers of Code, and I hope that continues. Desktop users need maps too.
The commerce behind the toolsAll of these open source tools don't come out of nowhere. TileMill, for instance, was created by MapBox, a company that makes its money by selling downloads of the map tiles. You can fiddle with the data and make all of the pretty pictures for free, but once people look at your map tiles more than 3,000 times in a month, it's time to pay.
The higher-priced plans offer more than just endless streams of map tiles. You get analytical charts that help you understand who is looking at which corner of the globe. MapBox has a cloud-based infrastructure that can optimize your maps to make sure they work as smoothly as possible in the mobile browsers.
MapBox contributes a fair amount of open source code, including not only TileMill but also Wax, a tool that makes it a bit easier to use libraries like Modest Maps to embed MapBox tiles in your site. My favorite part of Wax is TileJSON, a basic format for wrapping up the data about the tiles.
This example at stamen.com shows the use of Stamen's Watercolor, Toner, and Terrain tiles within the same map.

If you're just playing with maps, CloudMade is a good place to begin. CloudMade gives away some maps it created from OpenStreetMap data. Like the data, these are protected by the Creative Commons-Share Alike license. If you want to make use of these tiles, CloudMade offers Leaflet, a full-featured library for putting maps in Web pages. It's small and optimized for adding extra layers and pins. Here's an example I made with Leaflet.
What if you want to go deeper? If you're interested in connecting location with games, for instance, you'll want to visit the business end of CloudMade where they're pioneering this integration. One library, for instance, helps you figure out the weather and time of the person playing your game. The game can adjust itself using this data so that the action on the screen can take place in the dark if it's night or light if it's day. Or maybe you just want to serve up the opposite of the grim reality surrounding the player. If it's a cold and gray January day, you could offer tropical weather in your game.
Another clever idea is sponsored locations, in which advertisers might pay you to include a connection with their local business. If someone is near the coffee shop, the game could tell the user about a discount coupon and even offer to unlock certain levels for free if they redeem it. In one blog post, the company notes that our brains love dopamine and that it's tightly linked with seeking out and searching. In other words, games plus marketing yield dopamine for the user and money for the company.
This collection of mapping tools and the companies behind them show the power of open source to unlock competition while encouraging cooperation. Everyone has an incentive to contribute data to the central pool kept by OpenStreetMap, yet everyone is also striving to outdo the next company with better code and prettier renderings.
There's no doubt that Google is feeling some pressure from this ersatz collective. The company announced it was lowering its prices dramatically, knocking down fees almost 90 percent from $4 per 1,000 views to 50 cents per 1,000 views. This price will be billed only to sites that regularly exceed 25,000 views per day.
While this is a dramatic change, I'm not certain it would be enough to turn me away from these open source alternatives. While there's no doubt that the major Web companies provide great tools, there's something wonderful about controlling your own destiny. The ability to customize my own map tiles is so dangerously seductive that I'm sure I'll lose too many hours fiddling with the colors and the fonts so the maps look just so. Sure it's work, but the power and control are hard to beat.                                                          

No comments:

Post a Comment