27.10.2014 Views

Google Maps API 3

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 4 ■ TAKING THE MAP FURTHER WITH MAPOPTIONS<br />

Figure 4-6. The mapTypeControl positioned at the bottom<br />

These positions are relative to the other controls in the map. So, if you have two controls at the same<br />

position, the one added first will be the one closest to the edge of the map.<br />

mapTypeIds<br />

The map type control displays the different map types available for the user. You can control which map<br />

types will appear with the help of the property mapTypeIds. It takes an array containing the different<br />

MapType controls you want to use.<br />

Listing 4-6 shows how to add ROADMAP and SATELLITE as possible choices for the mapControlType<br />

control. Don’t worry if you find the syntax confusing. I will explain how arrays work in more detail in<br />

Chapter 5.<br />

Listing 4-6. The mapTypeControlOptions mapTypeIDs Property<br />

var options = {<br />

zoom: 3,<br />

center: new google.maps.LatLng(37.09, -95.71),<br />

mapTypeId: google.maps.MapTypeId.ROADMAP,<br />

mapTypeControl: true,<br />

mapTypeControlOptions: {<br />

mapTypeIds: [<br />

google.maps.MapTypeId.ROADMAP,<br />

google.maps.MapTypeId.SATELLITE<br />

]<br />

}<br />

};<br />

51

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!