1. Home
  2. Computing & Technology
  3. JavaScript

Google Maps

Zooming In and Out

Google Maps can show entire countries. Google Maps can also show single buildings or even parts of buildings. How much the map shows depends on the zoom level that you have set for your specific map.

While your visitor can change the zoom level of the map if you add the controls to the map to allow them to do so (which we will look at in a later tutorial), the zoom level of the map when it is first displayed is completely under your control although how you set it is not obvious just from looking at the code.

The zoom level is in fact set in the following command in the code that we have been looking at so far.

map.setCenter(new GLatLng(37.4419, -122.1419), 13);

It is that 13 which determines how big an area is displayed within the map. If we decrease that number then the map shows a larger area at a smaller scale. If we increase the number then we see a smaller area at a larger scale. Here's the same map as the example one provided by Google but with the zoom changes from 13 to 17 which is as high as you can go with their maps (you can zoom in closer with satellite images but more on that in a later tutorial).

Change the zoom level to 1 and you get a map of the entire world displayed which is as far out as Google will allow you to zoom.

Next we'll look at how to display the map you weant to display by defining the Latitude and Longitude.

Explore JavaScript
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. JavaScript

©2009 About.com, a part of The New York Times Company.

All rights reserved.