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

Get Mastering OpenLayers 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.