170

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

Community
  • 1
  • 1
Pascal MARTIN
  • 374,560
  • 73
  • 631
  • 650
  • Out of curiosity, why would "OSS license" be a point in favor of OpenLayers, except for philosophical reasons? Assuming Google's license allows you to do what you want for free, why would it sway your decision either way? – Mark Aug 25 '10 at 15:12
  • 7
    @Mark There are problems with Google's license. IANAL but I understand that displaying data on Google Maps gives Google an unlimited license to copy, modify, transform, and redistribute your data. E.g. [it is illegal](http://blog.ordnancesurvey.co.uk/2010/08/what-the-psma-really-means/) to show any data derived from UK Ordnance Survey GIS products on Google Maps. Another advantage of OSS is that OpenLayers is not subject to the whims of one organisation. Although practically, you can probably trust Google's good sense (and money, and business reasons) to support Google Maps into the future – MarkJ Aug 26 '10 at 14:13
  • 8
    Google Maps is not totally free (http://www.google.com/support/forum/p/maps/thread?tid=42dbb1b2b5dbc6ad&hl=en). The license depends on how you use it. – Mo. Sep 22 '11 at 03:28
  • It's worth checking out the GIS.SE site for all things geography if you can't find an answer on SO. – Roy May 16 '12 at 00:58
  • 1
    These articles might be of some use: EveryBlock - About Our Maps: http://blog.everyblock.com/2008/feb/18/maps/ A List Apart - Take Control of Your Maps (also from EveryBlock) http://www.alistapart.com/articles/takecontrolofyourmaps – mg1075 Jun 14 '11 at 17:11

11 Answers11

159

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 hope this is useful. And I'm around Stack Overflow if you have any questions!

iFez
  • 38
  • 5
atogle
  • 9,263
  • 4
  • 18
  • 13
  • 5
    Hi! Thanks a lot for this answer, that is indeed useful! There are definitly some interesting points (better vector support will probably be useful for the project I'm thinking about ; and it's not the only thing you're saying that is interesting !) ; Maybe I'll ask some other questions in sometime : I've not started working with OL yet (this question was quite a "prelimar" one ^^ ), but time will come, I suppose, considering the answers I've gotten! – Pascal MARTIN Aug 15 '09 at 15:40
  • 5
    +1. I've tried not to type this comment, but I can't help myself. WGS84 is not a projection. (It is worth trying to learn this stuff - I'm painfully picking up a bit of GIS, and it really helps with map stuff.) – MarkJ Jan 27 '10 at 18:01
  • 1
    WGS84 is a geographic coordinate system (used to display lat/long points on an ellipsoid). Web mercator is pretty much the defacto web-projection. – Roy May 16 '12 at 00:56
35

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
Muhammad Reda
  • 24,289
  • 12
  • 85
  • 99
Nils Weinander
  • 2,019
  • 1
  • 14
  • 19
  • Nice answers ; thanks for all these informations! I don't know the details yet, but I might have to use some data from my own server, so everything should be OK, particularly with the ability to integrate several backends (If I understood correctly ^^ I'll have chances to test that in a couple of days, I hope ;-) ) – Pascal MARTIN Aug 06 '09 at 20:23
  • 1
    @Pascal, I'm glad the answer was useful. I can add that the OpenLayers community is very active and the mailing lists quite helpful. – Nils Weinander Aug 07 '09 at 10:53
  • If there is anything you want to do that is not covered in the dev examples page you most probably cannot do it on google maps. for example, even cross-site scripting doesn't have to be covered by a proxy: http://openlayers.org/dev/examples/cross-origin.html – Glenn Plas Oct 05 '12 at 08:00
23

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.

Derek Swingley
  • 8,574
  • 5
  • 28
  • 31
  • Thanks for that answer! It's nice to see the mailling-lists are quite active, before beginning working with a project ^^ – Pascal MARTIN Aug 06 '09 at 20:20
13

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.

Andrew Dwyer
  • 446
  • 4
  • 9
13

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.

nrabinowitz
  • 52,936
  • 10
  • 139
  • 161
  • "You can't legally use a Google map 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)." That is incorrect. You can use Google Maps in a paid section of your site so long as the majority of users get to use your site and maps without paying. E.g. A real estate website. The posters have to pay to list their houses, but the vast majority of users get to browse the site without paying. In this case both have access to Google Maps. – Craig Mar 11 '11 at 02:10
  • Thanks - I meant that you can't use the API *exclusively* on payment-required sections. I've updated my post and added more links to address this issue. – nrabinowitz Mar 15 '11 at 04:03
  • OpenLayers uses Google Maps API internally so you are subject to the same license. http://osgeo-org.1560.x6.nabble.com/Introduction-of-usage-limits-to-the-Google-Maps-API-td3912955.html – Alfredo Osorio Mar 20 '14 at 21:42
  • @AlfredoOsorio - yes, IFF you use Google layers. There are lots of other tile sources. – nrabinowitz Mar 25 '14 at 21:03
10

I agree with all answers, but there is one very important point that nobody mentions. OpenLayers and Google Maps have different targets.

OpenLayer is an excellent framework to display geodata, but Google Maps is a pool of services that include a framework to display geodata among other services.

So, Google Maps expose a lot services and features that OpenLayes do not have. Some examples of Google Maps features and services are region localization, sensor detection (for device with GPS) and user localization, geocoding and reverse geocoding, street view, etc.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
angelcervera
  • 2,705
  • 32
  • 54
9

Some clients may refuse, or have strong reservations, about using Google Maps. They may have valid concerns that Google may introduce advertising or change the API without notice. However Google Maps does have the benefit of integrating with other Google services (placemarks, adding photos, geocoding services). As its the web you can always combine many different mapping services and APIs.

geographika
  • 6,098
  • 2
  • 33
  • 50
  • 1
    +1. I have some clients like that. And I'm not saying they are wrong. Last time I looked, the Google Maps licensing terms do indeed allow Google to introduce advertising into the maps whenever they wish. – MarkJ Jan 27 '10 at 18:03
  • 2
    Also by using GoogleMaps you are granting Google a perpetual, irrevocable, royalty-free, worldwide license to reproduce, adapt and modify your content. – MarkJ Jan 29 '10 at 12:03
6

I have used both APIs. I make a software for corporations and this software requires mapping but not all clients have a GoogleMaps license, so I need to support both types of maps.

I have made a common API for abstracting the differences between them and let me tell you, some stuff is easier to do in one than the other. Like limiting the bounds of where you can pan the map to, it is a lot easier to do in OpenLayers, but heatmaps are easier to use on GoogleMaps (it is officially supported by google, unlike the available OpenLayers plugins).

  1. OpenLayers support offline maps. Some of my users are in private intranets without internet connection.

  2. GoogleMaps has two absolutely must have plugins, MarkCluster and Spiderfier that makes possible visualizing a huge numbers of markers.

  3. GoogleMaps InfoWindows are easier to use and have better usability than the OpenLayers.Popups. These are the little windows that can open when you click in a marker. Googlemaps InfoWindows are also a lot more pretty by default, you have to do some CSS wizardry with the Popups.

  4. GoogleMaps has streetview which is useful sometimes.

  5. GoogleMaps has more features that you might need. Although many features are present in OpenLayers too, but not officially supported.

Usually in the end you should go with OpenLayers because of the reduced headache you might get from licensing and bandwith usage from googlemaps. Both handle basic mapping (ie, displaying markers on top of a map) very well. Unless you can find a specific feature you need from one that is not present on the other you should go for OpenLayers. See this for more information about googlemaps billing and when you can use it for free.

Also GoogleMaps has its basic geolocation type as 'LatLng' and Openlayers use 'LonLat' which drives me freaking nuts because I keep mistaking the order of the parameters in function calls.

Hoffmann
  • 12,871
  • 13
  • 69
  • 87
3

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.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Ruz
  • 246
  • 1
  • 3
3

In addition to those who mentioned speed problems, I would like to add that IE's VML renderer can get really slow with a vector layer with many features. One user mentioned about 200. That's about exactly what I can add before IE slows down considerable to the point of freezing. If you add features that are text labels, you can add half less, probably because internally each text label consists of two VML elements.

In Google you may create a custom GOverlay whose content is a "div", which gets rendered without problems in IE.

Jānis Elmeris
  • 1,794
  • 21
  • 39
2

OL has a large fanbase and is perhaps the most used Opensource geothing used in the world.

You dont see that many threads and posts about it in this cyberplace because people here tend to discuss other kind of techs, like JSF and Mobile (non geo), not because OL is like struts.

However Ol has some drawbacks, mainly that it's so low level that you have to write lots of code to do common ops. That can work in the good way too, because as a developer a: you have all the code upfront and b: tweaking and customizing is very easy.

There are more sophisticated free geotools, but all they do is call openlayers and abstract some of the more boring chores.

So use it confidently. It's mature, robust and it's not going to die in the foreseable future. However if you want to speed up your developing process you should try the other tools that mount in top of it.

have a nice day

demonz demonz
  • 639
  • 1
  • 15
  • 32
  • Hi, could you elaborate on the "more sophisticated free geotools" that sit on top of OpenLayers? GeoExt was mentioned above, but I did not see any others specified yet. Thanks. – Brian B Jun 07 '13 at 20:23
  • @BrianB hi brian, precisely i was thinking about geoext when i wrote "more sophisticated free geotools". That library unites a EXTJS with openlayers. – demonz demonz Jun 17 '13 at 16:20