Database Reference
In-Depth Information
empty controls arrayanddeclarethatthemaphasaSphericalMercator's
projection, as shown in the following code:
<script defer="defer" type="text/
javascript">
// instantiate the map object
var map = new OpenLayers.Map("map", {
controls: [],
projection: new
OpenLayers.Projection("EPSG:900913")
});
</script>
4. Right after the map variable is declared, add some OpenLayers controls to
the map. For the Web GIS viewer you are creating, you will add the Nav-
igation control(whichhandlesmapbrowsingwithmouseevents,suchas
dragging, double-clicking, and scrolling the wheel), PanZoomBar control (a
four-direction navigation using the arrows present above the zooming ver-
tical slider), the LayerSwitcher control (which handles the switching on
andoffoflayersaddedtothemap),andthe MousePosition control(which
displays the map coordinates as they change while the user is moving the
mouse), using the following code:
// add some controls on the map
map.addControl(new
OpenLayers.Control.Navigation());
map.addControl(new
OpenLayers.Control.PanZoomBar()),
map.addControl(new
OpenLayers.Control.LayerSwitcher(
{"div":OpenLayers.Util.getElement("layerswitcher")}));
map.addControl(new
OpenLayers.Control.MousePosition());
5. Now,createtwoGooglebaselayers:oneforGoogleHybridandtheotherfor
Google Terrain Base maps, using the following code:
Search WWH ::




Custom Search