This is not supposed to be an advertising post for the maps API of my employer. Definitely not. But after playing around with the Google Maps API a little bit and using it for my GeoLinkr plugin, I felt it was time to check out “the other API” from Yahoo! and do some comparison.
Honestly, up until now, I believed that the Google API really kicks ass. Nice and easy to follow “getting started”-examples, good documentation and satellite images covering the whole world up to a great amount of detail. Something that I discovered when developing GeoLinkr is that, e.g. the geocoding facility sometimes does not really work as you would expect it. So I would say it is fair to check out what Yahoo! as to offer in this respect
To be able to make a proper comparison, lets consider the following task: Display a list of cities (big and small ones) located all over the world as (custom) markers on a map. On click on these markers, they should reveal additional information about the city (its population). I have chosen the following cities to be displayed:
- London (UK)
- Evansville (Indiana, USA)
- Vancouver
- Dornbirn (Austria)
- Nice (France)
- Valletta (Malta)
- Neustadt an der Aisch (Germany)
- Barcelona
- Vienna (Austria)
- Mistelbach (Austria)
As both APIs offer geocoding, the API itself should figure out where these locations are, i.e. get their latitude and longitude values, and place them on the map. To make things a little bit more interesting, I also replaced the english city names with their german equivalents (e.g. using “Wien” instead of “Vienna”).
The HTML markup is pretty basic and straightforward and provides the foundation for both APIs. It looks like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Maps API Comparison</title>
<style type="text/css">
/* the map */
#mapContainer {
width: 800px;
height: 600px;
}
/* the text that gets displayed in the info window */
.infotext {
font-family: verdana;
font-size: 10px;
font-weight: normal;
}
</style>
</head>
<body>
<div id="mapContainer"></div>
<script type="text/javascript" src="[source of the api plus your application key]"></script>
<script type="text/javascript" src="[source of your javascript file]"></script>
</html>
</body>
</html>
I decided to have the list of cities and their population data (kindly provided by Wikipedia) available in a JavaScript array of objects, which looks like this:
var cities = [
{name:"London",pop:"7.554.236"},
{name:"Evansville",pop:"115.918"},
{name:"Vancouver",pop:"587.891"},
{name:"Dornbirn",pop:"43.854"},
{name:"Nizza",pop:"347.100"},
{name:"Valletta",pop:"7.048"},
{name:"Neustadt an der Aisch",pop:"12.326"},
{name:"Barcelona",pop:"1.605.602"},
{name:"Wien",pop:"1.668.737"},
{name:"Mistelbach",pop:"10.555"}
];
It is actually not important how the data gets in there. It might get retrieved straight from a database or parsed from an XML file using a server-side language, e.g. PHP. The main thing is: You have generic data (the name of a city and some additional info about it) that you want to display on a map. You have no geographical data stored, so the API (i.e. its geocoder) should figure that out, right?. The steps to acquire the task described above would be:
- Geocode the given cities and retrieve the lat-and-long values
- Place icons on the map representing the cities
- By default, center the map over a given location (Austria, in my case) and set an appropriate zoom level (so that all Europe is visible on the map)
- Clicking an icon will reveal information about the city
Now lets see what the two APIs can do for us…
Yahoo! Maps API
Check out the final result using the Yahoo! Maps API.
I decided to start with the, for me unfamiliar, Yahoo! Maps API. As said, I did some stuff with the other API before, so I expected to spend much more time to accomplish the given task. But that was not the case. Using the Yahoo! Maps API is pretty straightforward and, given the examples in the Getting Started Guide, I completed it in about one hour. Almost piece of cake. What I found noticeable:
Geocoding
Amazingly enough, without any more information given, the geocoder from the Yahoo! Maps API was able to get the correct values for nine out of ten locations. The only marker misplaced on the map was the one for Evansville. The one I meant was “Evansville, Indiana”, but the marker got placed on “Evansville, Alabama”. But that is okay, cause without any additional information, the geocoder is not able to disambiguate.
Update (September 29, 2007): After correcting the mistake pointed out by Christian, I noticed that Yahoo! Maps places “Valletta” in Florida, USA, close to Tamper, whereas the correct location would be as the capital of Malta, south of Italy. So based on that, it seems that Google has a more precise geocoder.
Custom Icons and Info Windows
Using your own images as marker icons is also pretty easy as well. But as you might notice, it would take a little more tweaking to place the lower end of the pin to the exact position of the location on the map. With a little playing around, I feel that you could get the result you would want.
Further Maps APIs
If you take a look at the Yahoo! Maps API homepage, you will notice that apart from the AJAX API, which is the subject of this discussion, there are also a couple of other Map APIs, namely:
I have not looked at them at all, but I believe that they are great extensions/alternatives to the JavaScript-centered AJAX API. Definitely a thumbs up for Yahoo! I would say.
Google Maps API
Please proceed to the solution using the Google Maps API.
I have used this API before, so I thought that it might even take me less time to accomplish the given task. However, this was not the case. Due to some reasons, which I would say are “interesting” at best, it took about five times the time it took me using the Yahoo! API. I won’t go into further detail here, but the attentive reader might spot the details in the final solution. Noteworthy:
Geocoding
Interestingly enough, the Google Maps geocoder also got nine out of ten locations right, but here “Valetta” (which is the capital of Malta) mas mistakenly interpreted as “Valetta Rd.” (in Ontario, Canada, close to Detroit). The pin for Evansville was perfectly placed in the right state, namely Indiana.
Update (September 29, 2007): As pointed out by Christian, it should be “Valletta”, instead of “Valetta”. My bad. So if spelled correctly, Google gets 10 out of 10 right, which is quite remarkable.
Custom Icons and Info Windows
Also here, using your own icon images is pretty easy. From a design perspective, the Google API offers a lot more options to tweak and style the icons to your needs, which might make it a little bit more attractive for UI people to use it.
Comparison Table 1 – initial loading
The following table presents figures from my experiments. The map was viewed in “normal mode”, meaning no satellite images were requested, just general map data.
| Yahoo! | ||
|---|---|---|
| Custom JS-File filesize (in bytes) | 1.699 | 1.483 |
| Geolocation rating | 10/10 | 8/10 |
| Number of HTTP requests | 42 | 59 |
| Amount of Data requested | 505 KB | 1.37 MB |
| Loading time | 3.21s | 7.92s |
Note: request time and size data was tested on my local webserver using Firebug
Comparison Table 2 – measuring over time
As pointed out by Drew, it might be worth to check how the aforementioned figures change over time, i.e. after the user has carried out several moves on the map (moving in any direction, zoom in, zoom out). So I carried out 20 movements, which were (in the order in which they were performed):
- up
- right
- down
- left
- zoom in (twice)
- up
- right
- down
- left
- zoom in (twice)
- right
- right
- zoom out (twice)
- up
- right
- down
- left
Please find the results of that observation below.
| Yahoo! | ||
|---|---|---|
| Number of HTTP requests | 176 | 255 |
| Amount of Data requested | 4.6 MB (75 kB from Cache) | 15.68 MB (46 kB from Cache) |
| Loading time | 9.37s | 13.58s |
Conclusion
From my perspective, both APIs offer a great range of functionality and opportunities for the developer. However, also both have their pros and cons, which I would like to point out here.
Using the Google Maps API, it was much harder (coding-wise) to accomplish the particularly simple task laid out above. Normally, I would say, this is not a good sign. Cause if you are already struggling with such a simple task, then how hard will it be to do some real complex stuff? The geocoding works pretty solid right now got remarkably precise and the number of possibilities you have regarding styling the markers etc. are quite sufficient, I would say. Regarding the amount of detail which is provided in the satellite images, I would say that Google Maps offers slightly more detailed images than Yahoo! Maps.
Accomplishing the task described at the beginning of this post using the Yahoo! Maps API was, as said, a piece of cake. You get the impression that the developers really knew how a user of the API would expect the API to behave, and that is a real plus. The amount of time it took me was minimal compared to using Googles API. The geocoding is pretty decent as well not as precise as Google’s and the number of design options for markers could be improved, I guess. Satellite images are slightly less detailed, but the normal map view offers more geographical details than the one from Google. This might also be the reason why the figures for the number of requests, the load times and the amount of data requested are not as good as for Google.
From my point of view, there is no real winner here. Google Maps is definitely the number one in the marketplace and Yahoo! Maps is still treated as the underdog, which is not really justifiable. Both have their advantages and disadvantages, and finally, I believe they almost equal out each other. In the end it is up to the implementing developer to decide which characteristics are more important for the project.
Further Reading
Google Maps API
- Google Maps API Homepage
- Concepts and Examples
- API Reference
- Google Groups: Google Maps API
- Google Mapki (Wiki)
That’s a really interesting comparison, Klaus. The figures in the comparison table are enlightening. The Y! maps seem to be a lot heavier and therefore slower to load. Were you able to tell from your tests if it was just front-loading more? It would be interesting to see if the weight and number of HTTP requests balanced out between the two over an extended browsing period. If so, that could influence which you choose, based on expected use.
Amazing that the Y! maps enabled you to achieve the same task in one fifth of the time, and with less code. However, counter to the argument of “if this is hard, how hard will something really complex be”, it may be the case that the learning curve is just steeper with Google maps. Perhaps once you’re over that initial difficulty, incrementally more complex tasks will be easier to achieve. Who knows.
I have to say though, I really like the visual style of the new Y! maps. I think they look much better aesthetically.
Drew, thanks for your thoughts. I added a second table which shows how the figures change after a few movements on the map. Still Google does less requests and also requests less amount of map data.
But I agree, the Y! maps just look better.
Hey Klaus, thanks for writing this article. I’m also a Yahoo over at Maps and I just recently pushed a new page of documentation that includes pdf cheatsheets and a downloadable resource bundle with all the code examples and resources. I was curious if you used these while learning the API. Otherwise take a look at them and let me know what you think.
Rahul, thanks for your response. I have sent you an email about that as well, but basically I was just copy & pasting the examples from the AJAX-Getting Started Guide to learn the API. Having them bundled together with the cheatsheets I think really helps to get a grasp of how the API works.
Hi Klaus,
Really a great work and a lot of real stuff to know for developers like me who has just started using Maps API.
Well, I am using Google Maps API and it was little tough in starting but then i found it very very powerful.
But i did not know Yahoo! Maps API is also very powerful.
Well, I will also try Yahoo! Maps API for some things to develop and then only i will realize the fact.
Anyways Thanks a lot for sharing ur knowledge..
Keep posting good stuff..
Klaus
I seem to have found just the opposite. I made a map in Google API just fine; images and resizing of the infowindows and the information parsed by XML. But in Yahoo, I have stumbled into problem after problem. I’m not sure if it’s because their Documentation is a bit confusing to me or because it’s more in-depth than Google’s but in either case I cannot load images into the infowindow or resize it to what I want. Also, the Yahoo! Maps do take a while to load the maps and the data while it quite fast on the Google side.
But thank you for posting this information!
Lindsay
Very nice comparison. Could you maybe add Maps24 [url:http://devnet.map24.com/] to your tables as well? I’m just thinking in using this one, since I don’t like the Google maps, from the taste side…
@Lindsay: Well, I believe it heavily depends on what kind of experiences one has had with JS programming and the kind of things you want to do with the API. For the task given, I found it easier for me to do it with the Y! Maps API, but each to their own.
@Olaf: thanks for mentioning Maps24, I certainly overlooked that. If I find the time, I might incorporate their API (and eventually Microsoft’s Virtual Earth) into the comparison.
>Interestingly enough, the Google Maps geocoder also got nine out of ten locations right, but here “Valetta” (which is the capital of Malta) mas mistakenly interpreted as “Valetta Rd.” (in Ontario, Canada, close to Detroit).
Maybe because the capital of Malta is VaLLetta, and not Valetta
@Christian: Jeez, what an embarrassing mistake! Seriously, this should not have happened. I corrected the code examples and made changes to the post where appropriate. Thanks for pointing this out!
Yahoo maps is very pretty, but as it doesn’t have maps for Australia, let alone, I would assume, other places. Google Maps is really the only option I have at the moment
I have played with google map api but not tried yahoo api. I think google map offers integration to google earth which is one extra feature that is really good.
From a few simple tests I have found the Yahoo API much more accurate at geocoding addresses based on UK post codes.
Interesting comparison, thanks for doing it.
Please note that we discourage developers from geocoding multiple addresses on the fly – so I view it as a good thing that a developer can’t simply create a marker from an address. Geocoding will never work all of the time – the world is full of crazy and new addresses – and we encourage developers to geocode addresses ahead of time, tweak them if needed, and cache them in a database.
The use case that GClientGeocoder is good for, however, is letting a user enter an address to locate themselves on the map.