O'Reilly logo

OpenLayers 3 : Beginner's Guide by Erik Hazzard, Paul Spencer, Thomas Gratier

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – using different projection codes

Let's create a basic map using a different projection. Using the usual code from Chapter 1, Getting Started with OpenLayers, recreate your map object the following way. We'll be specifying the projection property, along with the center and zoom properties. The projection we will use is EPSG:4326, a projection used for world data. Usually, when you don't specify a projection, the default projection in OpenLayers is EPSG:3857 (historically, called EPSG:900913), used by Google Maps and other third-party APIs such as Bing Maps or OpenStreetMap.

  1. Declare a new layer:
    var blueMarbleLayer = new ol.layer.Tile({ source: new ol.source.TileWMS({ url: 'http://maps.boundlessgeo.com/geowebcache/service/wms', params: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required