Skip to main content
added 5 characters in body; edited tags; edited title
Source Link
Andre Silva
  • 10.3k
  • 12
  • 55
  • 109

OpenLayers 2.13.1 - Google Calling layers from Google Maps API without success?

I'm following the examples of a free on OpenLayers, in the code below I am calling various layers of google maps api. Have checked with the code book and is correct but nothing appears on the broswer Testedbrowser.

Tested with one at a time and appeared, does anyone know what is wrong in the code? Also

Also I've taken the spec version of the api call to google maps and did not work. Nothing appears.

OpenLayers 2.13.1 - Google layers

I'm following the examples of a free on OpenLayers, in the code below I am calling various layers of google maps api. Have checked with the code book and is correct but nothing appears on the broswer Tested with one at a time and appeared, does anyone know what is wrong in the code? Also I've taken the spec version of the api call to google maps and did not work. Nothing appears.

Calling layers from Google Maps API without success?

I'm following the examples of a free on OpenLayers, in the code below I am calling various layers of google maps api. Have checked with the code book and is correct but nothing appears on the browser.

Tested with one at a time and appeared, does anyone know what is wrong in the code?

Also I've taken the spec version of the api call to google maps and did not work. Nothing appears.

Source Link
csf
  • 989
  • 2
  • 13
  • 41

OpenLayers 2.13.1 - Google layers

I'm following the examples of a free on OpenLayers, in the code below I am calling various layers of google maps api. Have checked with the code book and is correct but nothing appears on the broswer Tested with one at a time and appeared, does anyone know what is wrong in the code? Also I've taken the spec version of the api call to google maps and did not work. Nothing appears.

    <!DOCTYPE html>
<html lang='en'>
<head>
 <meta charset='utf-8' />
 <title>My OpenLayers Map</title>
 <script type='text/javascript' src='OpenLayers.js'></script>

 <!-- Chamada a Api Google Maps especificando a versão 3.2 -->
 <script src="http://maps.google.com/maps/api/js?sensor=false&v=3.2"></script>
 
 <script type='text/javascript'>

 //Variável map
 var map;

 //Função a ser chamada para criar o mapa na leitura da página
 function init() {
 
 // A classe Map espera dois argumentos "map_element" que o ID do elemento HTLML geralmente uma DIV e opções de mapa {key:value}
 map = new OpenLayers.Map('map_element', {}); 

 //Função de inicialização  - google.maps.MapTypeId.HYBRID (híbrida)
 var google_hybrid = new OpenLayers.Layer.Google(
    "Google Hybrid",
    {type: google.maps.MapTypeId.HYBRID}
    );

 //Função de inicialização  - google.maps.MapTypeId.TERRAIN (topológica)
 var google_physical = new OpenLayers.Layer.Google(
    "Google Physical",
    {type: google.maps.MapTypeId.TERRAIN}
    );

 //Função de inicialização  - google.maps.MapTypeId.TERRAIN (topológica)
 var google_satellite = new OpenLayers.Layer.Google(
    "Google Satellite",
    {type: google.maps.MapTypeId.SATELLITE}
    );

 //Função de inicialização  - google.maps.MapTypeId.ROADMAP (street layer default)
 var google_streets = new OpenLayers.Layer.Google(
    "Google Streets",
    {
        );

//Adiciona as Google Layers ao mapa
map.addLayers([google_hybrid,google_physical,google_satellite,
    google_streets]);


 //Camada de controle que vai mostrar as camadas no mapa
 map.addControl(new OpenLayers.Control.LayerSwitcher());

 //Verifica se o mapa tem um ponto central e o extende a sua extensão máxima
 if(!map.getCenter()){
 map.zoomToMaxExtent();
 
 }
 }

 </script>
</head>

<body onload='init();'> <!-- Chama a função js init() --> 

<!--Elemento HTML onde o mapa é exibido -->
 <div id='map_element' style='width: 1000px; height: 900px;'>
 </div>

</body>
</html>