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.
Declare a new layer:
var blueMarbleLayer = new ol.layer.Tile({ source: new ol.source.TileWMS({ url: 'http://maps.boundlessgeo.com/geowebcache/service/wms', params: { 'TILED' : true, 'VERSION': '1.1.1', 'LAYERS': 'bluemarble', 'FORMAT': 'image/jpeg' } }) });
Then, declare a new view:
var view = new ol.view({ projection: 'EPSG:4326', center: [-1.81185, 52.44314...