Book Image

OpenLayers 2.10 Beginner's Guide

Book Image

OpenLayers 2.10 Beginner's Guide

Overview of this book

Table of Contents (18 chapters)
OpenLayers 2.10
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for Action – using Spherical Mercator


Let's set up a map using Spherical Mercator with a Yahoo! Maps Layer. When using the Google Maps Layer (V3), the sphericalMercator property is set to true automatically, so you do not need to do anything extra. However, explicitly specifying it is a good idea when working with other layers that are not in the Spherical Mercator projection.

  1. Since we'll use the Virtual Earth layer type, we need to make sure to include the Microsoft Mapping API:

    <script src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&mkt=en-us"></script>
  2. The first step is to specify the maxExtent, maxResolution, units, and projection properties when creating our map object. If you'll remember from the previous chapter, these are the properties we must set when we specify a map projection other than the default EPSG:4326 projection. We'll also set the displayProjection property to an EPSG:4326 projection object. This displayProjection property specifies...