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.
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>
The first step is to specify the
maxExtent
,maxResolution
,units
, andprojection
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 defaultEPSG:4326
projection. We'll also set thedisplayProjection
property to anEPSG:4326
projection object. ThisdisplayProjection
property specifies...