Web designFeature

Guide to Google Maps API - and 6 great alternatives

Google Maps API

Wm Leler expands your mapping horizons by explaining Google Maps API's benefits - and some alternatives that could be even better.

We explain all you need to know about Google Maps API and also offer some great alternatives and why you should consider them. Google Maps API is one of the most popular JavaScript libraries on the web, used by more than 350,000 websites. And with good reason - it's powerful and for six years was absolutely free. It spawned a wave of map mashup websites (who initially hacked the then-private API, which Google not only tolerated but encouraged).

But Google dropped a bombshell in October 2011 when its announced it would start charging the heaviest users of Google Maps and would eventually start inserting ads for other users (as it does for videos on YouTube). Google's price was quite high - $4 per thousand map views - which had popular map-based websites such as FourSquare scrambling to find cheaper alternatives rather than paying Google tens or even hundreds of thousands of dollars each month. By June, Google realised it had priced its maps too high and was in danger of losing most of its potential paying customers, so it dropped the price by 88 per cent to 50 cents per thousand views. But the damage had been done. Other vendors and open-source solutions had already attracted attention as reasonable alternatives.

In fact, many of these alternatives have advantages over Google Maps beyond being cheaper (or free). Even if you are a small enough user of Google Maps that you wouldn't have to pay (you average less than 25,000 map views a day), it is worth your while to look at the alternatives.

What kind of map user are you?

This article assumes that you are a user of Google's JavaScript map API. But even if you know nothing about JavaScript and just want to embed a simple map on your website, there are alternatives. Mapbox Embed is an alternative to embeding a Google Map on a webpage, in case you don't like the idea of Google placing ads on your map.

Advertisement

Proprietary versus open APIs

In addition to Google Maps, there are a number of other proprietary APIs. Most proprietary APIs provide free or low-cost accounts to smaller users, as long as your maps are accessible to the public and not behind a password or other paywall.

Proprietary APIs are usually all-in-one solutions that include not just the API, but also basemaps and servers to serve map tiles to the API. This is both good (simpler to use) and bad (lack of flexibility). The main advantage of proprietary APIs is that they tend to include advanced features like real-time traffic, routing (directions), geocoding (translating addresses into locations), 3D buildings and 'bird's eye' views, street-level imagery, and information about businesses on the map.

On the other hand, some of the most popular alternatives to Google Maps API are open source. Mapping applications are incredibly diverse, and having access to the source makes it much easier to customise things to your needs.

Another advantage of open source is that you can mix and match components for your mapping solution. With Google Maps, Google controls all parts of the solution: the API, the maps, and the servers that serve these maps. Open-source map APIs allow you to pick from a large number of maps, or even create your own maps. You are also free to use your own servers, put your maps in the cloud, or outsource your map server needs.

Google Maps

Google Maps, of course, is still the 800-pound gorilla of mapping APIs. Google provides advanced features: powerful routing (including for walking, bicycling, and transit), Street View, 3D buildings, weather, and traffic information. Some of these features are unique to Google, so (depending on your application) you might have no choice but to use its API.

A big problem with Google is that you have little or no control. Google Maps comes with three base maps: street, satellite, and terrain. It is possible to use the Google Maps API with other maps but this is usually not a good idea because Google charges are based on API usage, even if you are not using its maps. If you aren't using Google's maps (or one of its other unique features), there is no reason to pay for them.

Here are six great alternatives to Google Maps API.

01. Microsoft Bing

Microsoft has positioned Bing maps as an alternative to Google maps, especially for providing local information. A unique feature of Bing maps is their 'bird's eye' view, which gives aerial views from several perspective angles.

Free accounts for Bing maps limit you to 125K sessions or 500K transactions per year. Free accounts do not include 'bird's eye' or 'streetside' (streetview) maps. They also have educational and not-for-profit accounts, which do include free access to Streetside maps.

02. MapQuest

MapQuest was one of the first providers for maps on the web, and today it's encouraging the transition to open maps. MapQuest is the only company that lets you choose between using licensed maps or open maps. Even using licensed map data, it has free accounts with no limits on map views. However, it does limit you to 5K calls per day for routing (including for multiple destinations), geocoding, and search.

The open map option - which uses OpenStreetMap and free satellite and aerial data - has no limits at all, but does not provide routing or traffic services. Unlike most non-open-source APIs, the open map option can be used for paid (non-public or password-protected) applications.

MapQuest also has servers for map tiles, which it lets you use with other APIs for free, even for heavy use. Using MapQuest's tile servers with open source APIs such as OpenLayers or Leaflet is a popular option.

03. OpenLayers

The OpenLayers API is a project of the Open Source Geospatial Foundation, and is often used with OpenStreetMap maps and data. It is a very flexible and powerful API designed to be used in advanced mapping applications, but it is somewhat complicated and large. It is a mature API with lots of features, but it can be difficult to use in mobile applications since it was designed before they became popular.

04. Leaflet

Leaflet is the newest mapping API, but has gained popularity quickly. Many of the companies switching away from Google Maps use the Leaflet API, including Flightstats (the company I work for) and Foursquare. It was designed to work well with both desktop and mobile applications and is small and fast. Being newer, it is not as powerful as some of the other APIs, but what it lacks in features it makes up for in flexibility. It has a powerful object model that makes it easy to add features or customise existing features to your needs.

Leaflet specifies access to tile servers using templates, which means Leaflet can be used with almost any online map including proprietary tile servers. If you can figure out the URL for a tile server, you can probably use Leaflet to display its maps. For example, here is the template to access Google's map tile servers from Leaflet:

    var tiles = new L.TileLayer(
     
     'http://mt{s}.google.com/vt/v=w2.106&x={x}&y={y}&z={z}&s=',
     
     { subdomains:'0123', attribution:'© Google 2012' }
     
    );

Note that it is unclear whether this violates Google's terms of service or copyright, and its servers can easily block your application if they want. Luckily, there are hundreds of non-proprietary map servers that you can access. Indeed, CloudMade, the company that created Leaflet and open sourced it, makes money by charging for their map servers.

05. Modest Maps

As its name implies, Modest Maps was designed to provide the minimal features to include maps inside applications. It originally used Adobe's Flash, but was later ported to JavaScript. There are a half dozen other ports, including for Python, PHP, Processing, and OpenFrameworks, which facilitate using Modest Maps in desktop (non-browser-based) applications, native mobile applications, and on servers.

06. Polymaps

Unlike other map APIs, Polymaps uses SVG to display geographic information, rendering this data directly on the browser. Other APIs use image tiles to render maps, but they still need to display geographic information (such as markers and routes) by rendering it directly. Map data can be loaded using standard formats such as GeoJSON and rendered directly.

The use of SVG enables you to use CSS rules for styling map features like roads and boundaries, including changing styles on the fly. It also allows the use of SVG transitions and animations on maps.

Polymaps makes it easy to visualise large datasets of geographic information (for example, population density, crime statistics or voting patterns). Level of detail is controlled by tiling the raw geographic data, rather than tiling rendered images, so it can be changed dynamically.

Polymaps also doesn't limit map display to fixed zoom levels, as with maps based on tiled images. And because SVG is resolution independent, it works well on devices with higher pixel count displays, such as Apple's Retina displays.

The main disadvantage of the use of SVG is that it is not fully supported on all mobile browsers; and even if supported, it uses a lot of processing power. It is also not supported at all on Internet Explorer prior to IE9 (IE8 and before used VML instead of SVG).

The future

When Google Maps was free it supressed the development of alternatives, but now the number of both proprietary and open mapping APIs has exploded. This competition is good news for developers of  applications that involve maps. Different APIs have unique features and capabilities, enabling you to pick the API that best suits your needs.

Advances in mapping APIs are also being driven by the increasing capabilities and power of mobile devices including smartphones and tablets, where there is high demand for applications based on maps.

Mapping seems to be moving toward open solutions. Even proprietary mapping products from Google and Nokia encourage crowdsourcing, enabling users to add or edit their proprietary maps. It is impossible for even large companies to keep up with all the changes to maps around the world as roads are added or changed. But although this data is supplied by users (including governments and NGOs), once added to a proprietary map it becomes proprietary (even the user or organisation who added the data has to pay to use it). It makes more sense to keep this data open, using something like OpenStreetMap.

In the slightly more distant future, all-in-one APIs like Google's will likely be split up into separate APIs, so for example a developer can use an open API such as Leaflet to draw the map and an open map based on OpenStreetMap data, while still using (and paying for) proprietary APIs for advanced features such as traffic or routing.

In addition to APIs, there are companies that help you create and host your own maps (such as MapBox and CloudMade) so that the style of your maps can match the style of your applications. There are also new APIs and platforms emerging for developing location-based applications (GeoLoqi, for example). And marketplaces will emerge for sharing, buying, and selling geographic data (such as WeoGeo).

One thing is clear though - map APIs are going places quickly.

Contributor: Wm Leler

Wm Leler is a principal engineer at Flightstats, Inc, who draw lots of airplanes on maps. He has published two computer books, and started several computer companies. This article was first published in .net magazine in 2012.

Words: Dan Oliver

Dan Oliver is editor-in-chief at Creative Bloq.

Advert

Log in to Creative Bloq with your preferred social network to comment

OR

Log in with your Creative Bloq account

site stat collection