O'Reilly logo

Mastering OpenLayers 3 by Gábor Farkas

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

Changing the map's projection

In the next example, called ch06_projection, we close our basic WebGIS client with a final control, which is able to change the map's projection dynamically. First, as we will need the PROJ4JS library for this example, we include it in the HTML file:

<script type="text/javascript" src="../../js/proj4js-2.3.10/proj4.js"></script>

Next, we style the control with CSS:

.notification-bar #projection {
    text-align: center;
}
.notification-bar #projection select {
    background: none;
    border: none;
    outline: 0;
}

The scheme is the same as the one in the previous example. We will strip the natural look of the select element, which will contain the possible projection options. Next, we start building the control by creating two options ...

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