OpenLayers vs Google Maps?

Viewed 51492

I have used Google Maps a couple of times, but what wondering about OpenLayers.
Before starting any kind of coding, here are a couple of questions that come to my mind,

  • Why would I use OpenLayers instead of Google Maps?
    • Except for its OSS licence, anyway
    • Did you encounter any situation in which you'd recommend absolutly not using OpenLayers?
    • I did a search about "OpenLayers" on Stack Overflow; there are not many answers. Does it mean this solution is not used much? Could it be a problem for long-term viability of the project?
  • For those of you who have already used OpenLayers: are there any common pitfalls / problems I may encounter?
    • What about using a JavaScript Framework with it? I've seen it's using Prototype, and I know Prototype, so that would be OK. But what about using something else like MooTools? (Which is not compatible with Prototype, BTW)
    • Are there any kind of speed and performance related problems? I need my application to be responsive and can't wait hours to get a map displayed.
  • Are there maps available for many places, or are there lots of those missing?
    • That is, I'm in France, and need my application to work at least for big cities... Will that be OK?
    • if not, is it easy to find layers and visualisations for OpenLayers and integrate them?
  • Is there any kind of API to display roads?
    • For instance, to show roads that are one-way only.
    • If yes, how can I do that? Do I have to have some kind of file containing those roads information, and, then, display them on the map by myself?
  • Do you know any good tutorial to OpenLayers?

I have not tried it yet, those are just out of the blue questions...

11 Answers

It's not necessarily a question of OpenLayers OR Google Maps. You can after all use Google Maps for your map background in OpenLayers. Some more specific answers:

Why OpenLayers?

  • OpenLayers can combine maps from different sources (Google Maps background, WMS overlays, vector data from KML or GML files or WFS etc)
  • You can style OpenLayers much more thanyou can Google Maps
  • Open source, you can check the source code when debugging
  • If you need high precision in the maps, use OpenLayers with a suitable map server backend rather than Google Maps to get a better map projection (Google Maps assumes that the earth is a perfect sphere)

Pitfalls

  • If you want to use vector (WFS) data from another server you need a proxy, due to cross site scripting limitations

Performance

  • Depends mainly on the speed of the map backend
  • Displaying many vector features (limit is browser dependent, but say > 200 on one view) takes time, but that is more a browser thing than a problem with OpenLayers

JavaScript frameworks

  • Have a look at GeoExt, which is ExtJS + OpenLayers, for example

Available maps

  • OpenLayers doesn't come with a map backend. You can use Google Maps, Yahoo Maps, MS Virtual Earth etc, or any WMS and WFS service tou have access to

I haven't seen much of a presence from OpenLayers users on SO but they're out there. The OpenLayers mailing lists are pretty active (I'm on Users and Dev and see anywhere from 50-100 emails a day discussing various things. You can search the lists from those links too.).

I can't answer all your questions but one thing I'll put out there is that OpenLayers and google maps aren't mutually exclusive. OpenLayers is a javascript library and you can use it to interact with google maps. Check out this example: OpenLayers using google maps. And here's the main OpenLayers examples page.

It really depends on what you want to use the map for. To simply plot points on a map, Google Maps will be fine. The map layers for Google Maps are also quite detailed. OpenLayers on the other hand offers far more functionality and is very extensible.

OpenLayers have lots of examples to get you started.

As for maps, OpenLayers is only an API so you need to supply it will map layers. The Google Maps API will be limited to the map layers supplied by google. With OpenLayer you can display pretty much any publicly available map service (WMS, WFS, TMS, WMS-C). A very good example is openstreetmap.org - (global streets map collected by the community). OSM can be added to openlayers as a TMS layer. Check out this example for instructions.

One point that hasn't been fully made here is that using OpenLayers avoids various restrictions Google places on the terms of service for its map APIs, including:

  • You can't legally use a Google map solely in a section of your site that requires payment to access, or for a private site that the public can't sign up for (e.g. a corporate intranet). (IANAL, but see Terms of Service, 9.1 and the FAQ)

  • You can't legally (or practically) use the Google API for offline applications (i.e. where the tiles are served from your own machine). Even if there weren't legal restrictions, Google makes this technically very difficult, while OpenLayers makes it easy.

  • Google reserves the right to shut down access to the API if you're showing a map with content it finds objectionable. The example given in the FAQ is a map of illegal drugs, which gives a good sense of the gray areas this restriction might cover.

See this FAQ and the Terms of Service for more details.

All that said, as a long-time Google Maps developer who recently started using OpenLayers, I feel that Google Maps has better documentation, a larger user community, and a clearer and more stable API than OpenLayers. So you have to make a trade-off somewhere.

A couple of things I would add, from two perspectives: client usage and data derving.

Client usage:

  • What are you clients used to using currently? Change can be difficult.
  • How much functionality do you really need? OpenLayers has quite a bit, but if you are not using it...

Data serving:

  • Are you serving KML data? If so, both OpenLayers and Google Maps will work with it, and you are probably going to have to decide based upon client usage.

  • Are you serving other types of data services? (WMS, WFS, CSV, etc.) If so, then OpenLayers very likely has examples and support for it.

Related