How to set the Google map type?

1k views Asked by At

How do I set the Google map type e.g. SATELLITE or TERRAIN? I tried varitaions of the OpenLayers 2 syntax:

new olgm.layer.Google( { type: google.maps.MapTypeId.SATELLITE });

and

new olgm.layer.Google({ 
    params: { type: google.maps.MapTypeId.SATELLITE }
});

but no joy.

2

There are 2 answers

0
Alexandre Dubé On BEST ANSWER

The correct syntax is this:

new olgm.layer.Google({
    mapTypeId: google.maps.MapTypeId.SATELLITE
};

See a live example (click on the + Satellite button). See also the JavaScript source file of the example

0
Danilo Santos On

See exemple:

const map = new google.maps.Map(document.getElementById("map"), {
        zoom: 21,
        streetViewControl: false,
        center: { lat: ..., lng: ....},
        mapTypeId: google.maps.MapTypeId.SATELLITE
    });