1. Home
  2. Computing & Technology
  3. JavaScript

Google Maps

Satellite Images

As well as displaying maps, Google Maps can also display satellite images of the exact same location. You can look down upon the real thing instead of just a map of the place. The easiest way to allow our visitors to look at a satellite image is to add another control to our map that allows them to switch between the two views.

Here's the code to add such a control:

var mapControl = new GMapTypeControl();
map.addControl(mapControl);

In fact that code allows our visitors to not only select between Map and Satellite views it also has a Hybrid option that overlays one over the other so that you can see the map overlaid on the satellite image. While this Hybrid view may be useful sometimes there will be other times when we don't want to offer that option. Google make it really easy to remove the unwanted button from the control. In fact we remove that type from the map before we add the control to switch between types using the following code in order to prevent the option appearing in the first place (remember this statement goes before the other two).

map.removeMapType(G_HYBRID_MAP);

Here's what my map looks like with this control added to it.

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.