1

I am beginner in OpenLayers and am starting with the www.openlayers.org documents, which use OpenLayers 3 to teach the basics of OpenLayers. Now, I would like to add layers from Google Maps and Mapserver, but I can't find that in the documents.

I have found many site related to my questions, but all of them use different syntax that I guess are related to OpenLayers 2.

  • for a beginner would you recommend ol3 or ol2 ?
  • if you recommend ol3, where I can find what's new in ol3 syntax?
7

If you have to work with a Google base map, OpenLayers 2 will satisfy your needs. As stated in an OpenLayers 3 issue by @ahocevar,

There will be no ol.source.GoogleMaps, unless Google change their policy and allow direct access to their map tiles.

Your only chance to use Google wiht OpenLayers 3 is to make a base map without any controls with Google Maps API, then put an ol.Map instance on the top of it. You have to synchronize the zoom levels and the viewport of the two DOM elements. You can find an example here.

@John Barça's detailed answer on the differences of the two OpenLayers libraries tells everything you have to know about them in the beginning. IMO, you should go with OpenLayers 3, because it will overgrow OL2 very soon. Try to consult with OL3's API, if you're stuck.

If you run into a problem, which you can't resolve with the API or the mailing lists, don't hesitate to share it on GIS StackExchange, the community will try to help you out.

  • 3
    Interesting (and annoying) about ol.source.GoogleMaps. Thanks for that. Answer, updated. – John Powell Oct 18 '14 at 10:28
  • I just tried to unwittingly upgrade my OL version from 2.x to 3.x. The lose of GoogleMaps is a major point of hesitation for me now. WTF. Sigh. – James T Snell Jun 9 '15 at 0:06
  • One must understand when using open source technologies, that Google Maps is a commercial product. They try to protect their income by restricting their tiles to their API (which is a paid service when integrated into a production environment), and using strict tile use policy with other, third party services. – Gabor Farkas Jun 21 '15 at 11:26
7

That is a very hard question to answer. OpenLayers 2 has been very successful and it is easy to find examples for just about everything. OpenLayers 3 is a total rewrite and uses the Google Closure toolkit which provides a number of useful services: code compression, event handling, cross browser support, etc. OpenLayers 3 also uses webGL rendering, when it is available, which provides super slick raster and vector rendering and (soon to come 3D virtual world integration via Caesium).

The main negatives of OpenLayers 3 at this time is that there are less examples and less people with skills to help others out, either on irc, Stack Exchange sites, mailing lists, etc, though this will change quickly with time. I also think that the learning curve is probably steeper, but that it will be more powerful and easier to extend once you have made that step. OpenLayers 3 is a total rewrite, just to be clear, so while some of the concepts will transfer from 2 to 3, tiles, geometries, layers, you will have to start again with 3.

I am tempted to say that for a beginner you should go with OpenLayers 2, but my head says OpenLayers 3 is the future, and to go with a little more pain now for a lot more gain later. Sorry, such an question is bound to produce a sitting on the fence answer.

The boundless blog has some great information on OL3 that might help you decide. EDIT: As noted by Gabor, the Google Maps example does not use Google Map tiles directly, but embeds a Google Map div in the page, and this will not change, unless Google change their policy on tile usage.

Note, about Mapserver: this is server platform that will produce data in a number of formats, vector and raster, eg, WMS, WFS from a number of sources. So, you will not find examples that deal with Mapserver directly. Instead search for examples that use WMS, WFS, and load your Mapserver details as part of the source. The same applies to Geoserver.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.