OpenLayers vs Google Maps? [closed]

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...


These are a really great questions! I'm a professional OpenLayers developer and fan, so I'll address your questions from that perspective.

Why would I use OpenLayers instead of Google Maps?

  • Flexiblity: You are not tied to any particular map provider or technology. You can change anytime and not have to rewrite your entire code. Google, Yahoo, Microsoft, WMS, ArcGIS Server, MapServer, etc. are all supported out of the box.
  • Vector Support: Better support for points, polylines, and polygons.
  • Control: You have the ability to add any new features that you may need. I've personally written three plugins for OpenLayers, two of which are or will be part of the source.
  • Debugging: Much easier to debug when you can step through the source code!

I would not worry at all about the long-term viability of the project. It is the premier open source client-side mapping library.

Are there any common pitfalls / problems I may encounter?

  • The biggest pitfall I've run into is working with the Web Mercator (Google) projection. It can be a pain to display vector data that is in a common and real projection like WGS 84 into an OpenLayers map using Google, Yahoo, and Microsoft base maps. The examples are your friend.

JavaScript Framework Compatibility

  • I use the jQuery framework for all of my work, and the only problem I've had is referencing jQuery after OpenLayers. Other than that, it's been smooth sailing.
  • Performance is great! The only issues will be with your map server or adding too many vectors to your map.

Are there maps available for many places?

  • Like I said, you can use basemaps from just about any source for anywhere in the world.

Is there any kind of API to display roads?

  • I'd check out CloudMade! The have converted the OpenStreetMap project into a map tile service and allow custom styling. I believe that you can style one-way streets (per your example) a particular way. The CloudMade Developer Zone.

Do you know any good tutorial to OpenLayers?

  • I don't know any tutorials, but there are a ton of examples in OpenLayers Examples

I hope this is useful. And I'm around Stack Overflow if you have any questions!


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.