Map Types
Learn about the different map types that can be used in projects.
We'll cover the following
Modify a map type
Depending on what best suits the use case, many types of maps within the API can be used. Map types can be modified by using the mapTypeId
property in the mapTypeId
object or dynamically modified using the map.setMapTypeId()
method.
Here’s a code snippet that demonstrates how to set the map type property during the initialization:
const map = new google.maps.Map(document.getElementById("map"), {
...
mapTypeId: '<map_type>',
}
This is how to update the map type dynamically:
map.setMapTypeId('<map_type>');
These are the four basic types of maps in the Google Maps API:
roadmap
satellite
hybrid
terrain
The roadmap
type
The roadmap
type displays the default 2D map type, which is a normal road map. To use it, set the mapTypeId
as roadmap
.
Get hands-on with 1200+ tech skills courses.